ECF 1.5
main - promjena_genotipa.cpp
1#include <ecf/ECF.h>
2#include "SymbRegEvalOp.h"
3
4int main(int argc, char **argv)
5{
6 StateP state (new State);
7
8 // set the evaluation operator
9 state->setEvalOp(new SymbRegEvalOp);
10
11 state->initialize(argc, argv);
12 state->run();
13
14 // prvo dohvatimo najbolju jedinku
15 IndividualP ind = state->getHoF()->getBest().at(0);
16 // pa izvadimo string:
17 Tree::Tree* tree = (Tree::Tree*) ind->getGenotype().get();
18 std::string stablo = tree->toString();
19 // pa napravimo novi string...
20 stablo = "<Tree size=\"3\">+ X X </Tree>";
21 // i vratimo u Tree
22 XMLNode xTree = XMLNode::parseString(stablo.c_str());
23 tree->read(xTree);
24 // pa ispisemo ili evaluiramo ili sto vec
25 cout << tree->toString() << endl;
26 ind->fitness = state->getEvalOp()->evaluate(ind);
27 cout << ind->toString() << endl;
28
29 return 0;
30}
std::string toString()
Output genotype to string.
Definition: Genotype.h:98
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
void read(XMLNode &)
Read genotype data from XMLNode.
Definition: Tree.cpp:550