Modified all init sequences in Lesson2 and Lesson3 - and all corresponding
files in html dir - after the return of eoRndGenerators and subsequent modifications of eoInit
This commit is contained in:
parent
a79075f673
commit
72b6692f9b
9 changed files with 24 additions and 23 deletions
|
|
@ -74,9 +74,9 @@ void main_function(int argc, char **argv)
|
||||||
// Initilisation of population
|
// Initilisation of population
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
// based on boolean_generator class (see utils/rnd_generator.h)
|
// based on boolean_generator class (see utils/eoRndGenerators.h)
|
||||||
eoInitFixedLength<Indi, boolean_generator>
|
eoUniformGenerator<bool> uGen;
|
||||||
random(VEC_SIZE, boolean_generator());
|
eoInitFixedLength<Indi> random(VEC_SIZE, uGen);
|
||||||
// Initialization of the population
|
// Initialization of the population
|
||||||
eoPop<Indi> pop(POP_SIZE, random);
|
eoPop<Indi> pop(POP_SIZE, random);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,8 @@ void main_function(int argc, char **argv)
|
||||||
// Initilisation of population
|
// Initilisation of population
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
// based on a uniform generator
|
// based on a uniform generator
|
||||||
eoInitFixedLength<Indi, uniform_generator<double> >
|
eoUniformGenerator<double> uGen(-1.0, 1.0);
|
||||||
random(VEC_SIZE, uniform_generator<double>(-1.0, 1.0));
|
eoInitFixedLength<Indi> random(VEC_SIZE, uGen);
|
||||||
// Initialization of the population
|
// Initialization of the population
|
||||||
eoPop<Indi> pop(POP_SIZE, random);
|
eoPop<Indi> pop(POP_SIZE, random);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,7 @@ all : $(ALL)
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
@/bin/rm $(ALL) *.o *~
|
@/bin/rm $(ALL) *.o *~
|
||||||
|
|
||||||
|
FirstRealEA : real_value.h
|
||||||
|
|
||||||
|
FirstBitEA : binary_value.h
|
||||||
|
|
@ -76,8 +76,8 @@ void main_function(int argc, char **argv)
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
// based on boolean_generator class (see utils/rnd_generator.h)
|
// based on boolean_generator class (see utils/rnd_generator.h)
|
||||||
eoInitFixedLength<Indi, boolean_generator>
|
eoUniformGenerator<bool> uGen;
|
||||||
random(VEC_SIZE, boolean_generator());
|
eoInitFixedLength<Indi> random(VEC_SIZE, uGen);
|
||||||
// Initialization of the population
|
// Initialization of the population
|
||||||
eoPop<Indi> pop(POP_SIZE, random);
|
eoPop<Indi> pop(POP_SIZE, random);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@ double real_value(const std::vector<double>& _ind)
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
for (unsigned i = 0; i < _ind.size(); i++)
|
for (unsigned i = 0; i < _ind.size(); i++)
|
||||||
{
|
{
|
||||||
if ( (_ind[i]<0) || (_ind[i]>1) )
|
|
||||||
cout << "Sorti des bornes: " << _ind[i] << " ";
|
|
||||||
sum += _ind[i] * _ind[i];
|
sum += _ind[i] * _ind[i];
|
||||||
}
|
}
|
||||||
return -sum;
|
return -sum;
|
||||||
|
|
|
||||||
|
|
@ -164,8 +164,8 @@ void main_function(int argc, char **argv)
|
||||||
rng.reseed(seed);
|
rng.reseed(seed);
|
||||||
// a Indi random initializer
|
// a Indi random initializer
|
||||||
// based on boolean_generator class (see utils/rnd_generator.h)
|
// based on boolean_generator class (see utils/rnd_generator.h)
|
||||||
eoInitFixedLength<Indi, boolean_generator>
|
eoUniformGenerator<bool> uGen;
|
||||||
random(vecSize, boolean_generator());
|
eoInitFixedLength<Indi> random(vecSize, uGen);
|
||||||
|
|
||||||
// Init pop from the randomizer: need to use the append function
|
// Init pop from the randomizer: need to use the append function
|
||||||
pop.append(popSize, random);
|
pop.append(popSize, random);
|
||||||
|
|
|
||||||
|
|
@ -165,8 +165,8 @@ void main_function(int argc, char **argv)
|
||||||
rng.reseed(seed);
|
rng.reseed(seed);
|
||||||
// a Indi random initializer
|
// a Indi random initializer
|
||||||
// based on boolean_generator class (see utils/rnd_generator.h)
|
// based on boolean_generator class (see utils/rnd_generator.h)
|
||||||
eoInitFixedLength<Indi, boolean_generator>
|
eoUniformGenerator<bool> uGen;
|
||||||
random(vecSize, boolean_generator());
|
eoInitFixedLength<Indi> random(vecSize, uGen);
|
||||||
|
|
||||||
// Init pop from the randomizer: need to use the append function
|
// Init pop from the randomizer: need to use the append function
|
||||||
pop.append(popSize, random);
|
pop.append(popSize, random);
|
||||||
|
|
|
||||||
|
|
@ -162,9 +162,9 @@ The actual code is in boldface and the comment in normal face.
|
||||||
<b> </b>////////////////////////////////<br>
|
<b> </b>////////////////////////////////<br>
|
||||||
<b> </b>// Initilisation of population<br>
|
<b> </b>// Initilisation of population<br>
|
||||||
<b> </b>////////////////////////////////<br>
|
<b> </b>////////////////////////////////<br>
|
||||||
<b> </b>// based on boolean_generator class (see utils/rnd_generator.h)<br>
|
<b> </b>// based on eoUniformGenerator class (see utils/eoRndGenerators.h)<br>
|
||||||
<b> eoInitFixedLength<Indi, boolean_generator> </b><br>
|
<b> eoUniformGenerator<bool> uGen;</b><br>
|
||||||
<b> random(VEC_SIZE, boolean_generator());</b><br>
|
<b> eoInitFixedLength<Indi> random(VEC_SIZE, uGen);</b><br>
|
||||||
<b> </b>// Initialization of the population<br>
|
<b> </b>// Initialization of the population<br>
|
||||||
<b> eoPop<Indi> pop(POP_SIZE, random);</b><br>
|
<b> eoPop<Indi> pop(POP_SIZE, random);</b><br>
|
||||||
<b> </b>// and evaluate it in one line<br>
|
<b> </b>// and evaluate it in one line<br>
|
||||||
|
|
|
||||||
|
|
@ -270,11 +270,11 @@ rng.reseed(seed);</font></tt></b>
|
||||||
<br><tt><font color="#993399"><b> </b>//
|
<br><tt><font color="#993399"><b> </b>//
|
||||||
a Indi random initializer</font></tt>
|
a Indi random initializer</font></tt>
|
||||||
<br><tt><font color="#993399"><b> </b>//
|
<br><tt><font color="#993399"><b> </b>//
|
||||||
based on boolean_generator class (see utils/rnd_generator.h)</font></tt>
|
based on eoUniformGenerator class (see utils/eoRndGenerators.h)</font></tt>
|
||||||
<br><b><tt><font color="#993399">
|
<br><b><tt><font color="#993399"> eoUniformGenerator<bool>
|
||||||
eoInitFixedLength<Indi, boolean_generator> </font></tt></b>
|
uGen;</font></tt></b>
|
||||||
<br><b><tt><font color="#993399">
|
<br><b><tt><font color="#993399"> eoInitFixedLength<Indi>
|
||||||
random(vecSize, boolean_generator());</font></tt></b>
|
random(vecSize, uGen);</font></tt></b>
|
||||||
<br><tt><font color="#993399"><b> </b>//
|
<br><tt><font color="#993399"><b> </b>//
|
||||||
Init pop from the randomizer: need to use the append function</font></tt>
|
Init pop from the randomizer: need to use the append function</font></tt>
|
||||||
<br><b><tt><font color="#993399">
|
<br><b><tt><font color="#993399">
|
||||||
|
|
@ -284,7 +284,7 @@ and evaluate pop (STL syntax) </font></tt>
|
||||||
<br><b><tt><font color="#993399">
|
<br><b><tt><font color="#993399">
|
||||||
apply<Indi>(eval, pop);</font></tt></b>
|
apply<Indi>(eval, pop);</font></tt></b>
|
||||||
<br><tt><font color="#993399"><b> } </b>// end
|
<br><tt><font color="#993399"><b> } </b>// end
|
||||||
of initializatio of the population</font></tt></td>
|
of initialization of the population</font></tt></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<a NAME="output"></a>
|
<a NAME="output"></a>
|
||||||
|
|
@ -311,7 +311,6 @@ of initializatio of the population</font></tt></td>
|
||||||
<tr>
|
<tr>
|
||||||
<td><tt><font color="#009900"><b> </b>// The robust tournament selection</font></tt>
|
<td><tt><font color="#009900"><b> </b>// The robust tournament selection</font></tt>
|
||||||
<br><tt><font color="#009900"><b> eoDetTournamentSelect<Indi> selectOne(tSize);
|
<br><tt><font color="#009900"><b> eoDetTournamentSelect<Indi> selectOne(tSize);
|
||||||
|
|
||||||
</b>// tSize in [2,POPSIZE]</font></tt>
|
</b>// tSize in [2,POPSIZE]</font></tt>
|
||||||
<br><tt><font color="#009900"><b> </b>// is now encapsulated in a
|
<br><tt><font color="#009900"><b> </b>// is now encapsulated in a
|
||||||
eoSelectPerc (entage)</font></tt>
|
eoSelectPerc (entage)</font></tt>
|
||||||
|
|
|
||||||
Reference in a new issue