3#include "GPSymbRegEvalOp.h"
4#include "FileDataWriter.h"
19#include "IATerminal.h"
23int main(
int argc,
char **argv)
25 StateP state (
new State);
30 op->dataWriter = &dataWriter;
35 tree->addFunction(sqrtPrimitive);
37 tree->addFunction(logPrimitive);
38 state->addGenotype(tree);
42 Tree::PrimitiveP iaAdd(
new IAAdd);
43 iaTree->addFunction(iaAdd);
44 Tree::PrimitiveP iaSub(
new IASub);
45 iaTree->addFunction(iaSub);
46 Tree::PrimitiveP iaMul(
new IAMul);
47 iaTree->addFunction(iaMul);
48 Tree::PrimitiveP iaDiv(
new IADiv);
49 iaTree->addFunction(iaDiv);
50 Tree::PrimitiveP iaSin(
new IASin);
51 iaTree->addFunction(iaSin);
52 Tree::PrimitiveP iaCos(
new IACos);
53 iaTree->addFunction(iaCos);
54 Tree::PrimitiveP iaSqrt(
new IASqrt);
55 iaTree->addFunction(iaSqrt);
56 Tree::PrimitiveP iaLog(
new IALog);
57 iaTree->addFunction(iaLog);
60 for(uint i = 0; i < 20; i++) {
61 Tree::PrimitiveP myTerm = (Tree::PrimitiveP)
new IATerminal;
62 std::string name =
"x" + uint2str(i);
63 myTerm->setName(name);
64 iaTree->addTerminal(myTerm);
67 state->addGenotype(iaTree);
70 state->addOperator((OperatorP)
new WriteBest);
73 state->initialize(argc, argv);
77 XMLNode xInd = XMLNode::parseFile(argv[2],
"Individual");
78 IndividualP ind = (IndividualP)
new Individual(state);
83 op->printParams =
true;
84 std::string testOutFile(argv[3]);
86 op->dataWriter = &fileDataWriter;
87 state->getEvalOp()->evaluate(ind);
94 std::vector<IndividualP> hof = state->getHoF()->getBest();
95 IndividualP ind = hof[0];
99 op->printParams =
true;
100 state->getEvalOp()->evaluate(ind);
Symbolic regression evaluation operator.
Individual class - inherits a vector of Genotype objects.
void read(XMLNode &)
read individual from XML node
State class - backbone of the framework.
Log function primitive (Tree genotype)
Sqrt function primitive (Tree genotype)
Tree class - implements genotype as a tree.