Ejemplo n.º 1
0
void TransfersDialog::OnbtnAddTransferClick(wxCommandEvent& event)
{
    wxString wxstrId = TextCtrl1->GetValue();       // c
    wxString wxstrDescr = TextCtrl2->GetValue();    // consumption
    //string strId = string(TextCtrl2->GetValue().mb_str(wxConvISO8859_1));
    //string strDescr = string(TextCtrl1->GetValue().mb_str(wxConvISO8859_1));
    wxString wxstrFrom = ddFrom->GetString(ddFrom->GetCurrentSelection());
    wxStringTokenizer tok1(wxstrFrom, _("\t"));
    wxString wxstrFromShort = tok1.GetNextToken();
    wxString wxstrFromLong = tok1.GetNextToken();

    wxString wxstrTo = ddTo->GetString(ddTo->GetCurrentSelection());
    wxStringTokenizer tok2(wxstrTo, _("\t"));
    wxString wxstrToShort = tok2.GetNextToken();
    wxString wxstrToLong= tok2.GetNextToken();
    //wxString wxstrTo = ddTo->GetData(ddTo->GetCurrentSelection());

    string strVar = ws2s(wxstrId);
    string strDescr = ws2s(wxstrDescr);
    string strFrom = ws2s(wxstrFromShort);
    string strTo = ws2s(wxstrToShort);

    // USE CREATETRANSFER FUNCTION AND REMOVE CALL ON GETTRANSFERS

    createTransfer(wxstrToShort, wxstrFromShort, wxstrId, wxstrDescr);

    // Expression::makeToken(strVar); // moved to Transfer::create(...)

    populateList();
    TextCtrl1->Clear();
    TextCtrl2->Clear();
    TextCtrl1->SetFocus();
}
Ejemplo n.º 2
0
string format(const string& str1, const unsigned int& arg1, const unsigned int& arg2, const string& arg3, const string& arg4)
{
    string tok1("{0}");
    string tok2("{1}");
    string tok3("{2}");
    string tok4("{2}");
    string newString(str1);

    newString = substitute(newString, tok1, arg1);
    newString = substitute(newString, tok2, arg2);
      newString = substitute(newString, tok3, arg3);
      newString = substitute(newString, tok4, arg4);

    return newString;
}
Ejemplo n.º 3
0
void TestsPnlHigh::TestConditionalGaussianGetJPD()
{
    printf("TestConditionalGaussianGetJPD\n");

    BayesNet *net = SimpleCGM1();
    
    net->SetPGaussian("Cont0", "1.5 -0.5", "1.0 0.3 0.3 2.0", TokArr(), TokArr());
    net->SetPGaussian("Cont1", "0.0", "2.5", "1.0 3.0", "Tab0^State0");
    net->SetPGaussian("Cont1", "-1.5", "0.75", "0.5 2.5", "Tab0^State1");

    net->SetProperty("Inference", "naive");

    net->EditEvidence("Tab0^State0");
    net->GetJPD("Cont0");
    net->GetJPD("Cont1");
    net->GetJPD("Cont2");

    net->ClearEvid();

    Tok tok0("Cont0^Dim0^0.0");
    Tok tok1("Cont0^Dim1^0.0");

    TokIdNode *id0 = tok0.Node();
    TokIdNode *id1 = tok1.Node();

    bool is_int0 = id0->id[id0->id.size()-1].is_int; 
    bool is_int1 = id1->id[id1->id.size()-1].is_int;

    int int_id0 = id0->id[id0->id.size()-1].int_id;
    int int_id1 = id1->id[id1->id.size()-1].int_id;

    TokIdNode *id = net->Net().Token().Node(Tok("Cont0"))->v_next;
    TokIdNode *id2 = net->Net().Token().Node(Tok("Cont1"))->v_next;
    TokIdNode *id3 = net->Net().Token().Node(Tok("Cont2"))->v_next;
    TokIdNode *id4 = net->Net().Token().Node(Tok("Tab0"))->v_next;

    //TokIdNode *a1 = id->v_next;
    //TokIdNode *a2 = a1->h_next;

    net->EditEvidence("Cont0^Dim0^0.0 Cont0^Dim1^1.0");
    net->EditEvidence("Cont1^Dim0^0.0");
    net->EditEvidence("Cont2^Dim0^0.0");

    net->GetJPD("Tab0");

    delete net;
};  
Ejemplo n.º 4
0
	static
	std::vector<mm::mastermind_t::remote_t>
	parse_remotes(const std::string &remotes) {
		typedef boost::char_separator<char> separator_t;
		typedef boost::tokenizer<separator_t> tokenizer_t;

		std::vector<mm::mastermind_t::remote_t> result;

		separator_t sep1(",");
		tokenizer_t tok1(remotes, sep1);

		separator_t sep2(":");

		for (auto it = tok1.begin(), end = tok1.end(); it != end; ++it) {
			tokenizer_t tok2(*it, sep2);
			auto jt = tok2.begin();

			if (tok2.end() == jt) {
				throw std::runtime_error("remotes are malformed");
			}

			auto host = *jt++;
			uint16_t port = 10053;

			if (tok2.end() != jt) {
				port = boost::lexical_cast<uint16_t>(*jt++);
			}

			if (tok2.end() != jt) {
				throw std::runtime_error("remotes are malformed");
			}

			result.emplace_back(std::make_pair(std::move(host), port));
		}

		return result;
	}
Ejemplo n.º 5
0
int main(int argc, char** argv)
{
  std::string top20_name;
  std::string verified_query_name;

  if (argc != 3){
    LOG(INFO) << "score.bin top20.txt valid_image.txt";
    return -1;
  }
  else{
    top20_name = argv[1];
    verified_query_name = argv[2];
  }

  std::ifstream fr(top20_name.c_str());
  std::string stringLine;
  std::vector<std::vector<std::string> > top20_Mat;
  while (!fr.eof()){
    std::getline(fr, stringLine);
    boost::char_separator<char> sep(";");
    boost::tokenizer<boost::char_separator<char> > tok(stringLine, sep);

    std::vector<std::string> tmp_ver_line;

    boost::tokenizer<boost::char_separator<char> >::iterator beg = tok.begin();
    std::string first_name = *beg;
    boost::char_separator<char> sep1(",");
    boost::tokenizer<boost::char_separator<char> > tok1(first_name, sep1);
    boost::tokenizer<boost::char_separator<char> >::iterator beg1 = tok1.begin();
    tmp_ver_line.push_back(*beg1);
    beg1++;
    tmp_ver_line.push_back(*beg1);
    beg++;
    tmp_ver_line.push_back(*beg1);
    for (; beg != tok.end(); ++beg)
    {
      tmp_ver_line.push_back(*beg);
    }
    top20_Mat.push_back(tmp_ver_line);
  }
  fr.close();

  std::ifstream fr_ver(verified_query_name.c_str());
  std::vector<std::vector<std::string> > verify_Mat;
  while (!fr_ver.eof()){
    std::getline(fr_ver, stringLine);
    boost::char_separator<char> sep(";");
    boost::tokenizer<boost::char_separator<char> > tok(stringLine, sep);

    std::vector<std::string> tmp_ver_line;
    boost::tokenizer<boost::char_separator<char> >::iterator beg = tok.begin();
    std::string first_name = *beg;
    boost::char_separator<char> sep1(",");
    boost::tokenizer<boost::char_separator<char> > tok1(first_name, sep1);
    boost::tokenizer<boost::char_separator<char> >::iterator beg1 = tok1.begin();
    tmp_ver_line.push_back(*beg1);
    beg1++;
    tmp_ver_line.push_back(*beg1);
    beg++;
    for (; beg != tok.end(); ++beg)
    {
      tmp_ver_line.push_back(*beg);
    }
    verify_Mat.push_back(tmp_ver_line);
  }
  fr_ver.close();

  const int num = top20_Mat.size();
  const int ver_num = verify_Mat.size();
  double score = 0.;
  for (size_t i = 0; i < num; ++i){
    std::string imageName = top20_Mat[i][0];

    double tmp_score = 0.;

    size_t j;
    for (j = 0; j < ver_num; ++j){
      if (verify_Mat[j][0] == imageName) break;
    }

    int count = 1;
    if (j < ver_num) {
      for (size_t m = 1; m < top20_Mat[i].size(); ++m) {
        std::string tmpName = top20_Mat[i][m];
        size_t n;
        for (n = 1; n < verify_Mat[j].size(); ++n){
          if (tmpName == verify_Mat[j][n]) break;
        }
        if (n < verify_Mat[j].size()){
          count++;
          tmp_score += (count / static_cast<double>(m));
        }
      }
    }
    tmp_score /= 20.;
    score += tmp_score;
  }
  score /= num;

  LOG(INFO) << "MAP20 score: " << score;
  LOG(INFO) << "map20 computing finished!";
}