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