3#include "Primitives.cpp"
20int main(
int argc,
char **argv)
22 StateP state (
new State);
34 Tree::PrimitiveP ifl (
new If);
35 tree->addFunction(ifl);
36 Tree::PrimitiveP orp (
new Or);
37 tree->addFunction(orp);
38 Tree::PrimitiveP andp (
new And);
39 tree->addFunction(andp);
40 Tree::PrimitiveP notp (
new Not);
41 tree->addFunction(notp);
42 Tree::PrimitiveP xorp (
new Xor);
43 tree->addFunction(xorp);
44 Tree::PrimitiveP and2p (
new And2);
45 tree->addFunction(and2p);
46 Tree::PrimitiveP xnorp (
new XNor);
47 tree->addFunction(xnorp);
51 for(uint i = 0; i < 20; i++) {
52 Tree::PrimitiveP myTerm = (Tree::PrimitiveP)
new BoolV;
53 std::string name =
"v" + uint2str(i);
54 myTerm->setName(name);
55 tree->addTerminal(myTerm);
59 for(uint i = 0; i < 20; i++) {
60 Tree::PrimitiveP myTerm = (Tree::PrimitiveP)
new BoolV;
61 std::string name =
"f" + uint2str(i);
62 myTerm->setName(name);
63 tree->addTerminal(myTerm);
67 state->addGenotype(tree);
70 state->addOperator((OperatorP) b);
74 if(!state->initialize(argc, argv))
80 XMLNode xInd = XMLNode::parseFile(argv[2],
"Individual");
81 IndividualP ind = (IndividualP)
new Individual(state);
84 evaluateVerbose =
true;
85 state->getAlgorithm()->evalOp_->evaluate(ind);
86 cout << ind->toString();
Individual class - inherits a vector of Genotype objects.
void read(XMLNode &)
read individual from XML node
State class - backbone of the framework.
Tree class - implements genotype as a tree.