本文整理汇总了C++中StateP::addAlgorithm方法的典型用法代码示例。如果您正苦于以下问题:C++ StateP::addAlgorithm方法的具体用法?C++ StateP::addAlgorithm怎么用?C++ StateP::addAlgorithm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateP
的用法示例。
在下文中一共展示了StateP::addAlgorithm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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;
}
示例2: main
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;
}