int main(int argc, char **argv) { // argc = 2; // argv[1] = "./examples/GAFunctionMin/parametri.txt"; // PSO algoritam: //argv[1] = "./examples/GAFunctionMin/parameters_DE.txt"; GenHookeJeevesP alg (new GenHookeJeeves); StateP state (new State); state->addAlgorithm(alg); state->setEvalOp(static_cast<EvaluateOpP> (new FunctionMinEvalOp)); state->initialize(argc, argv); state->run(); return 0; }
int main(int argc, char **argv) { // run for selected COCO functions for(uint function = 1; function < 25; function++) { // read XML config std::ifstream fin(argv[1]); if (!fin) { throw std::string("Error opening file! "); } std::string xmlFile, temp; while (!fin.eof()) { getline(fin, temp); xmlFile += "\n" + temp; } fin.close(); // set log and stats parameters std::string funcName = uint2str(function); std::string logName = "log", statsName = "stats"; if(function < 10) { logName += "0"; statsName += "0"; } logName += uint2str(function) + ".txt"; statsName += uint2str(function) + ".txt"; // update in XML XMLResults results; XMLNode xConfig = XMLNode::parseString(xmlFile.c_str(), "ECF", &results); XMLNode registry = xConfig.getChildNode("Registry"); XMLNode func = registry.getChildNodeWithAttribute("Entry", "key", "coco.function"); func.updateText(funcName.c_str()); XMLNode log = registry.getChildNodeWithAttribute("Entry", "key", "log.filename"); log.updateText(logName.c_str()); XMLNode stats = registry.getChildNodeWithAttribute("Entry", "key", "batch.statsfile"); stats.updateText(statsName.c_str()); // write back std::ofstream fout(argv[1]); fout << xConfig.createXMLString(true); fout.close(); // finally, run ECF on single function StateP state (new State); //set newAlg MyAlgP alg = (MyAlgP) new MyAlg; state->addAlgorithm(alg); // set the evaluation operator state->setEvalOp(new FunctionMinEvalOp); state->initialize(argc, argv); state->run(); } return 0; }