ECF 1.5
main.cpp
1#include <ecf/ECF.h>
2#include "SymbRegEvalOp.h"
3#include "infixTree.h"
4
5
6int main(int argc, char **argv)
7{
8 StateP state (new State);
9
10 // set the evaluation operator
11 state->setEvalOp(new SymbRegEvalOp);
12
13 state->initialize(argc, argv);
14
15 if(argc > 2) {
16 XMLNode xInd = XMLNode::parseFile(argv[2], "Individual");
17 IndividualP ind = (IndividualP) new Individual(state);
18 ind->read(xInd);
19 ind->fitness = state->getEvalOp()->evaluate(ind);
20 std::cout << ind->toString();
21 string output;
22 showTree(output, (Tree::Tree*) ind->getGenotype().get());
23 std::cout << output << endl;
24 return 0;
25 }
26
27 state->run();
28
29 // after the evolution: show best
30 std::vector<IndividualP> hof = state->getHoF()->getBest();
31 IndividualP ind = hof[0];
32 std::cout << ind->toString();
33 string output;
34 showTree(output, (Tree::Tree*) ind->getGenotype().get());
35 std::cout << output << endl;
36
37
38 return 0;
39}
Individual class - inherits a vector of Genotype objects.
Definition: Individual.h:12
void read(XMLNode &)
read individual from XML node
Definition: Individual.cpp:103
State class - backbone of the framework.
Definition: State.h:39
Symbolic regression evaluation operator (using AP genotype).
Definition: SymbRegEvalOp.h:29
Tree class - implements genotype as a tree.
Definition: Tree_c.h:29