ECF 1.5
main.cpp
1#include <ECF/ECF.h>
2#include "FunctionMinEvalOp.h"
3
4
5//
6// this main() function optimizes a single COCO function (Id set in config file)
7// function Ids: noiseless 1-24, noisy 101-130
8//
9
10int main(int argc, char **argv)
11{
12 StateP state (new State);
13
14 // set the evaluation operator
15 state->setEvalOp(new FunctionMinEvalOp);
16
17 state->initialize(argc, argv);
18 state->run();
19
20 return 0;
21}
22
23
24
25//
26// this main() function iterates over multiple COCO functions and optimizes each one in turn
27// function Ids: noiseless 1-24, noisy 101-130
28//
29/*
30int main(int argc, char **argv)
31{
32 // run for selected COCO functions
33 for(uint function = 1; function <= 24; function++) {
34
35 // read XML config
36 std::ifstream fin(argv[1]);
37 if (!fin) {
38 std::cerr << "Error opening config file! (" << argv[1] << ")\n";
39 return 1;
40 }
41
42 std::string xmlFile, temp;
43 while (!fin.eof()) {
44 getline(fin, temp);
45 xmlFile += "\n" + temp;
46 }
47 fin.close();
48
49 // set log and stats parameters
50 std::string funcName = uint2str(function);
51 std::string logName = "log", statsName = "stats";
52 if(function < 10) {
53 logName += "0";
54 statsName += "0";
55 }
56 logName += uint2str(function) + ".txt";
57 statsName += uint2str(function) + ".txt";
58
59 // update in XML
60 XMLResults results;
61 XMLNode xConfig = XMLNode::parseString(xmlFile.c_str(), "ECF", &results);
62 XMLNode registry = xConfig.getChildNode("Registry");
63
64 XMLNode func = registry.getChildNodeWithAttribute("Entry", "key", "coco.function");
65 func.updateText(funcName.c_str());
66 XMLNode log = registry.getChildNodeWithAttribute("Entry", "key", "log.filename");
67 log.updateText(logName.c_str());
68 XMLNode stats = registry.getChildNodeWithAttribute("Entry", "key", "batch.statsfile");
69 stats.updateText(statsName.c_str());
70
71 // write back
72 std::ofstream fout(argv[1]);
73 fout << xConfig.createXMLString(true);
74 fout.close();
75
76
77 // finally, run ECF on a single function
78 StateP state (new State);
79
80 // set the evaluation operator
81 state->setEvalOp(new FunctionMinEvalOp);
82
83 state->initialize(argc, argv);
84 state->run();
85 }
86
87 return 0;
88}
89*/
Function minimization evaluation class.
State class - backbone of the framework.
Definition: State.h:39