Update after the change in replacements
This commit is contained in:
parent
ca586fc799
commit
ed0e76350a
5 changed files with 18 additions and 21 deletions
|
|
@ -79,7 +79,7 @@ void main_function(int argc, char **argv)
|
|||
// Initialization of the population
|
||||
eoPop<Indi> pop(POP_SIZE, random);
|
||||
|
||||
// and evaluate it in one line
|
||||
// and evaluate it in one loop
|
||||
apply<Indi>(eval, pop); // STL syntax
|
||||
|
||||
// OUTPUT
|
||||
|
|
@ -102,7 +102,7 @@ void main_function(int argc, char **argv)
|
|||
// REPLACE
|
||||
// And we now have the full slection/replacement - though with
|
||||
// no replacement (== generational replacement) at the moment :-)
|
||||
eoNoReplacement<Indi> replace;
|
||||
eoGenerationalReplacement<Indi> replace;
|
||||
|
||||
// OPERATORS
|
||||
//////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -45,13 +45,11 @@ void main_function(int argc, char **argv)
|
|||
const float P_MUT = 0.5; // mutation probability
|
||||
|
||||
const double EPSILON = 0.01; // range for real uniform mutation
|
||||
const double SIGMA = 0.01; // std. dev. of normal mutation
|
||||
// some parameters for chosing among different operators
|
||||
const double segmentRate = 0.5; // rate for 1-pt Xover
|
||||
const double arithmeticRate = 0.5; // rate for 2-pt Xover
|
||||
const double uniformMutRate = 0.5; // rate for bit-flip mutation
|
||||
const double detMutRate = 0.5; // rate for one-bit mutation
|
||||
const double normMutRate = 0.5; // rate for normal mutation
|
||||
|
||||
// GENERAL
|
||||
//////////////////////////
|
||||
|
|
@ -79,7 +77,7 @@ void main_function(int argc, char **argv)
|
|||
// Initialization of the population
|
||||
eoPop<Indi> pop(POP_SIZE, random);
|
||||
|
||||
// and evaluate it in one line
|
||||
// and evaluate it in one loop
|
||||
apply<Indi>(eval, pop); // STL syntax
|
||||
|
||||
// OUTPUT
|
||||
|
|
@ -102,7 +100,7 @@ void main_function(int argc, char **argv)
|
|||
// REPLACE
|
||||
// And we now have the full slection/replacement - though with
|
||||
// no replacement (== generational replacement) at the moment :-)
|
||||
eoNoReplacement<Indi> replace;
|
||||
eoGenerationalReplacement<Indi> replace;
|
||||
|
||||
// OPERATORS
|
||||
//////////////////////////////////////
|
||||
|
|
@ -115,19 +113,16 @@ void main_function(int argc, char **argv)
|
|||
eoArithmeticCrossover<Indi> xoverA;
|
||||
// Combine them with relative rates
|
||||
eoPropCombinedQuadOp<Indi> xover(xoverS, segmentRate);
|
||||
xover.add(xoverA, arithmeticRate, eo_verbose);
|
||||
xover.add(xoverA, arithmeticRate, true);
|
||||
|
||||
// MUTATION
|
||||
// Gaussian mutation - std dev as argument
|
||||
eoNormalMutation<Indi> mutationN(SIGMA);
|
||||
// offspring(i) uniformly chosen in [parent(i)-epsilon, parent(i)+epsilon]
|
||||
eoUniformMutation<Indi> mutationU(EPSILON);
|
||||
// k (=1) coordinates of parents are uniformly modified
|
||||
eoDetUniformMutation<Indi> mutationD(EPSILON);
|
||||
// Combine them with relative rates
|
||||
eoPropCombinedMonOp<Indi> mutation(mutationU, uniformMutRate);
|
||||
mutation.add(mutationD, detMutRate);
|
||||
mutation.add(mutationN, normMutRate, eo_verbose);
|
||||
mutation.add(mutationD, detMutRate, true);
|
||||
|
||||
// STOP
|
||||
// CHECKPOINT
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void main_function(int argc, char **argv)
|
|||
// PARAMETRES
|
||||
const unsigned int SEED = 42; // seed for random number generator
|
||||
const unsigned int T_SIZE = 3; // size for tournament selection
|
||||
const unsigned int VEC_SIZE = 8; // Number of bits in genotypes
|
||||
const unsigned int VEC_SIZE = 20; // Number of bits in genotypes
|
||||
const unsigned int POP_SIZE = 20; // Size of population
|
||||
|
||||
const unsigned int MAX_GEN = 500; // Maximum number of generation before STOP
|
||||
|
|
@ -98,7 +98,7 @@ void main_function(int argc, char **argv)
|
|||
eoDetTournament<Indi> selectOne(T_SIZE); // T_SIZE in [2,POP_SIZE]
|
||||
// solution solution solution solution solution solution solution
|
||||
// modify the rate in the constructor
|
||||
eoSelectPerc<Indi> select(selectOne,2.0);// rate is second arg.
|
||||
eoSelectMany<Indi> select(selectOne,2, eo_is_an_integer);// rate is second arg.
|
||||
|
||||
// REPLACE
|
||||
// solution solution solution solution solution solution solution
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue