| 1 |
|
| 2 |
|
| 3 |
|
| 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 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
GeneticAlgorithm(); |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
GeneticAlgorithm(const GeneticAlgorithm& ga); |
| 37 |
|
| 38 |
|
| 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 |
|
| 54 |
|
| 55 |
virtual ~GeneticAlgorithm(); |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
virtual GeneticAlgorithm& operator= (const GeneticAlgorithm& ga); |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 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 |
|
| 81 |
|
| 82 |
virtual void start(); |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
virtual double getValue() { return 0.0; }; |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
GeneticIndividual* getIndividual(Index i); |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
bool registerParameter(GenericParameter*); |
| 95 |
|
| 96 |
protected: |
| 97 |
|
| 98 |
double calculate(GeneticIndividual*); |
| 99 |
|
| 100 |
vector<GenericParameter*> parameters_; |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
void select(Size); |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
void mate(); |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
void mutate(); |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
void cleanUp(); |
| 117 |
|
| 118 |
|
| 119 |
void cleanPool(vector<GeneticIndividual>& pool); |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
bool multiDemeCheck(); |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
void updatePool(); |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
Size population_size_; |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
std::vector<std::vector<GeneticIndividual> > pools_; |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
std::vector<std::pair<GeneticIndividual*, GeneticIndividual*> > selected_; |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
std::vector<double> probabilities_; |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
DockProblem* gp_; |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
Size max_iterations_; |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
Size immune_; |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
double mutation_rate_; |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
Size iteration_; |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
Size survivors_; |
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
int conv_start_; |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
bool finished_; |
| 176 |
|
| 177 |
DockingAlgorithm* docking_algorithm_; |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
std::mt19937 rng_; |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
GeneticIndividual template_individual_; |
| 186 |
}; |
| 187 |
} |
| 188 |
|
| 189 |
#endif |