ECF 1.7
main.cpp
1#include <ECF/ECF.h>
2#include "SymbRegEvalOp.h"
3
4
5int main(int argc, char **argv)
6{
7 StateP state(new State);
8
9 state->setEvalOp(new CGPSymbRegEvalOp);
10
11 if (!state->initialize(argc, argv))
12 return 1;
13 state->run();
14
15 return 0;
16
17 // optional block: write best individual to 'best.txt'
18 std::vector<IndividualP> hof = state->getHoF()->getBest();
19 IndividualP best = hof[0];
20 ofstream outfile("./best.txt");
21 outfile << best->toString();
22 outfile.close();
23
24 // optional block: read individual from 'best.txt' (for subsequent simulation)
25 XMLNode xInd = XMLNode::parseFile("./best.txt", "Individual");
26 IndividualP ind = (IndividualP) new Individual(state);
27 ind->read(xInd);
28 state->getAlgorithm()->evaluate(ind);
29 std::cout << ind->toString() << "\n";
30
31 return 0;
32}
CGP symbolic regression evaluation operator.
Individual class - inherits a vector of Genotype objects.
Definition Individual.h:12
void read(XMLNode &)
read individual from XML node
State class - backbone of the framework.
Definition State.h:38