Debian Codegraph @

include/BALL/DOCKING/GENETICDOCK/geneticAlgorithm.h

raw symbols SCIP
1 // ----------------------------------------------------
2 // $Maintainer: Marcel Schumann $
3 // $Authors: Jan Fuhrmann, Marcel Schumann $
4 // ----------------------------------------------------
5
6 #ifndef BALL_DOCKING_GENETICDOCK_GENETICALGORITHM_H
7 #define BALL_DOCKING_GENETICDOCK_GENETICALGORITHM_H
8
9 #include "geneticIndividual.h"
10 #include <BALL/DOCKING/GENETICDOCK/parameter.h>
11
12 #include <vector>
13 #include <utility>
14 #include <random>
15
16 namespace BALL
17 {
18
19 class DockProblem;
20
21 class DockingAlgorithm;
22
23 class BALL_EXPORT BALL_DEPRECATED GeneticAlgorithm
24 {
25 friend class EvolutionaryDocking;
26
27 public:
28 //CREATE(GeneticAlgorithm)
29
30 /** default constructor
31 */
32 GeneticAlgorithm();
33
34 /** copy constructor
35 */
36 GeneticAlgorithm(const GeneticAlgorithm& ga);
37
38 /** constructor
39 */
40 GeneticAlgorithm(DockingAlgorithm* docker, DockProblem*,
41 int pop_number,
42 int iter,
43 int init,
44 int pop,
45 int surv,
46 double mrate,
47 int save,
48 int citer,
49 double cvalue,
50 int cstart
51 );
52
53 /** default destructor
54 */
55 virtual ~GeneticAlgorithm();
56
57 /** assignment operator
58 */
59 virtual GeneticAlgorithm& operator= (const GeneticAlgorithm& ga);
60
61 /** clone method
62 */
63 // virtual GeneticAlgorithm* clone();
64
65 /** setup method
66 */
67 void setup(DockProblem*,
68 int pop_number,
69 int iter,
70 int init,
71 int pop,
72 int surv,
73 double mrate,
74 int save,
75 int citer,
76 double cvalue,
77 int cstart
78 );
79
80 /** optimize pool
81 */
82 virtual void start();
83
84 /**
85 */
86 virtual double getValue() { return 0.0; };
87
88 /** get i-th individual?!?!?
89 */
90 GeneticIndividual* getIndividual(Index i);
91
92 /** register a parameter for optimization
93 */
94 bool registerParameter(GenericParameter*);
95
96 protected:
97
98 double calculate(GeneticIndividual*);
99
100 vector<GenericParameter*> parameters_;
101
102 /** select individuals for mating
103 */
104 void select(Size);
105
106 /** produce offsprings
107 */
108 void mate();
109
110 /** random alteration
111 */
112 void mutate();
113
114 /** discard individuals
115 */
116 void cleanUp();
117
118 /** sorts the given pool according to the fitness values of its members and keeps only the best survivors_>ones (#best ones = survivors_) */
119 void cleanPool(vector<GeneticIndividual>& pool);
120
121 /** check for migration between populations
122 */
123 bool multiDemeCheck();
124
125 /** assign fitness score
126 */
127 void updatePool();
128
129 /** size of one population
130 */
131 Size population_size_;
132
133 /** vector of populations
134 */
135 std::vector<std::vector<GeneticIndividual> > pools_;
136
137 /** vector of selected individuals
138 */
139 std::vector<std::pair<GeneticIndividual*, GeneticIndividual*> > selected_;
140
141 /** probabilities for rank weighting
142 */
143 std::vector<double> probabilities_;
144
145 /** assings fitness score to individuals
146 */
147 DockProblem* gp_;
148
149 /** number of iterations
150 */
151 Size max_iterations_;
152
153 /** number of individuals immune to mutation
154 */
155 Size immune_;
156
157 /** fraction of individuals to be mutated
158 */
159 double mutation_rate_;
160
161 /** count iterations during optimizaton
162 */
163 Size iteration_;
164
165 /** number of individuals surviving an iteration
166 */
167 Size survivors_;
168
169 /** iteration for the first convergence test
170 */
171 int conv_start_;
172
173 /** true if algorithm has stopped
174 */
175 bool finished_;
176
177 DockingAlgorithm* docking_algorithm_;
178
179 /** RNG engine
180 */
181 std::mt19937 rng_;
182
183 /** used to initialize new individuals
184 */
185 GeneticIndividual template_individual_;
186 };
187 }
188
189 #endif /* BALL_DOCKING_GENETICDOCK_GENETICALGORITHM_H */