ECF 1.5
main.cpp
1#include <ecf/ECF.h>
2#include "SymbRegEvalOp.h"
3
4
5
6namespace Tree {
7
8 // primjer novog operatora krizanja (TODO za mutaciju)
10 {
11 public:
13 {
14 myGenotype_->registerParameter(state, "crx.homologous", (voidP) new double(0), ECF::DOUBLE);
15 }
16
17 bool TreeCrxHomologous::initialize(StateP state)
18 {
19 voidP sptr = myGenotype_->getParameterValue(state, "crx.homologous");
20 probability_ = *((double*)sptr.get());
21 return true;
22 }
23
24 bool TreeCrxHomologous::mate(GenotypeP gen1, GenotypeP gen2, GenotypeP ch)
25 {
26 return true;
27 }
28
29 };
30 typedef boost::shared_ptr<TreeCrxHomologous> TreeCrxHomologousP;
31
32
33 class MyTree : public Tree
34 {
35 public:
36
37 MyTree(void) {
38 name_ = "MyTree";
39 }
40
42 {
43 MyTree *newObject = new MyTree(*this);
44 return newObject;
45 }
46
47 vector<CrossoverOpP> getCrossoverOp()
48 {
49 vector<CrossoverOpP> crx;
50
51 // ovo nam ne treba jer necemo koristiti postojece operatore krizanja
52 //crx = Tree::getCrossoverOp();
53
54 // dodavanje crx operatora:
55 crx.push_back((CrossoverOpP)(new TreeCrxHomologous));
56
57 return crx;
58 }
59
60 vector<MutationOpP> getMutationOp()
61 {
62 vector<MutationOpP> mut;
63
64 // TODO: dodati nas operator mutacije
65
66 return mut;
67 }
68
69 bool initialize(StateP state)
70 {
71 // pozovemo originalni initialize:
72 Tree::initialize(state);
73
74 // TODO: a onda pregazimo s nasom inicijalizacijom na temelju signature fajla
75
76 return true;
77 }
78
79 };
80}
81typedef boost::shared_ptr<Tree::MyTree> MyTreeP;
82
83
84int main(int argc, char **argv)
85{
86 StateP state (new State);
87
88 // set the evaluation operator
89 state->setEvalOp(new SymbRegEvalOp);
90
91 // dodamo nas genotip
92 Tree::MyTree* tree = new Tree::MyTree;
93 state->addGenotype((GenotypeP)tree);
94
95 state->initialize(argc, argv);
96 state->run();
97
98 return 0;
99}
CrossoverOp base class.
Definition: Crossover.h:19
double probability_
probability of usage of this crossover operator
Definition: Crossover.h:42
GenotypeP myGenotype_
pointer to the Genotype that defines this CrossoverOp
Definition: Crossover.h:43
virtual void registerParameters(StateP)
Register parameters with the system. Called before CrossoverOp::initialize.
Definition: Crossover.h:35
virtual bool initialize(StateP)
Initialize crossover operator. Called before first crossover operation.
Definition: Crossover.h:31
virtual bool mate(GenotypeP, GenotypeP, GenotypeP)=0
std::string name_
genotype's name
Definition: Genotype.h:109
State class - backbone of the framework.
Definition: State.h:39
Symbolic regression evaluation operator (using AP genotype).
Definition: SymbRegEvalOp.h:29
vector< CrossoverOpP > getCrossoverOp()
Create and return a vector of crossover operators.
Definition: main.cpp:47
MyTree * copy()
Create an identical copy of the genotype object.
Definition: main.cpp:41
vector< MutationOpP > getMutationOp()
Create and return a vector of mutation operators.
Definition: main.cpp:60
bool initialize(StateP state)
Initialize a genotype object (read parameters, perform sanity check, build data)
Definition: main.cpp:69
Tree class - implements genotype as a tree.
Definition: Tree_c.h:29
bool initialize(StateP state)
Initialize a genotype object (read parameters, perform sanity check, build data)
Definition: Tree.cpp:115