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
|
||||
////////////////////////////////
|
||||
|
||||
// based on boolean_generator class (see utils/rnd_generator.h)
|
||||
eoInitFixedLength<Indi, boolean_generator>
|
||||
random(VEC_SIZE, boolean_generator());
|
||||
// based on boolean_generator class (see utils/eoRndGenerators.h)
|
||||
eoUniformGenerator<bool> uGen;
|
||||
eoInitFixedLength<Indi> random(VEC_SIZE, uGen);
|
||||
// Initialization of the population
|
||||
eoPop<Indi> pop(POP_SIZE, random);
|
||||
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ void main_function(int argc, char **argv)
|
|||
// Initilisation of population
|
||||
////////////////////////////////
|
||||
// based on a uniform generator
|
||||
eoInitFixedLength<Indi, uniform_generator<double> >
|
||||
random(VEC_SIZE, uniform_generator<double>(-1.0, 1.0));
|
||||
eoUniformGenerator<double> uGen(-1.0, 1.0);
|
||||
eoInitFixedLength<Indi> random(VEC_SIZE, uGen);
|
||||
// Initialization of the population
|
||||
eoPop<Indi> pop(POP_SIZE, random);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,3 +12,7 @@ all : $(ALL)
|
|||
|
||||
clean :
|
||||
@/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)
|
||||
eoInitFixedLength<Indi, boolean_generator>
|
||||
random(VEC_SIZE, boolean_generator());
|
||||
eoUniformGenerator<bool> uGen;
|
||||
eoInitFixedLength<Indi> random(VEC_SIZE, uGen);
|
||||
// Initialization of the population
|
||||
eoPop<Indi> pop(POP_SIZE, random);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ double real_value(const std::vector<double>& _ind)
|
|||
double sum = 0;
|
||||
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];
|
||||
}
|
||||
return -sum;
|
||||
|
|
|
|||
|
|
@ -164,8 +164,8 @@ void main_function(int argc, char **argv)
|
|||
rng.reseed(seed);
|
||||
// a Indi random initializer
|
||||
// based on boolean_generator class (see utils/rnd_generator.h)
|
||||
eoInitFixedLength<Indi, boolean_generator>
|
||||
random(vecSize, boolean_generator());
|
||||
eoUniformGenerator<bool> uGen;
|
||||
eoInitFixedLength<Indi> random(vecSize, uGen);
|
||||
|
||||
// Init pop from the randomizer: need to use the append function
|
||||
pop.append(popSize, random);
|
||||
|
|
|
|||
|
|
@ -165,8 +165,8 @@ void main_function(int argc, char **argv)
|
|||
rng.reseed(seed);
|
||||
// a Indi random initializer
|
||||
// based on boolean_generator class (see utils/rnd_generator.h)
|
||||
eoInitFixedLength<Indi, boolean_generator>
|
||||
random(vecSize, boolean_generator());
|
||||
eoUniformGenerator<bool> uGen;
|
||||
eoInitFixedLength<Indi> random(vecSize, uGen);
|
||||
|
||||
// Init pop from the randomizer: need to use the append function
|
||||
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>// Initilisation of population<br>
|
||||
<b> </b>////////////////////////////////<br>
|
||||
<b> </b>// based on boolean_generator class (see utils/rnd_generator.h)<br>
|
||||
<b> eoInitFixedLength<Indi, boolean_generator> </b><br>
|
||||
<b> random(VEC_SIZE, boolean_generator());</b><br>
|
||||
<b> </b>// based on eoUniformGenerator class (see utils/eoRndGenerators.h)<br>
|
||||
<b> eoUniformGenerator<bool> uGen;</b><br>
|
||||
<b> eoInitFixedLength<Indi> random(VEC_SIZE, uGen);</b><br>
|
||||
<b> </b>// Initialization of the population<br>
|
||||
<b> eoPop<Indi> pop(POP_SIZE, random);</b><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>//
|
||||
a Indi random initializer</font></tt>
|
||||
<br><tt><font color="#993399"><b> </b>//
|
||||
based on boolean_generator class (see utils/rnd_generator.h)</font></tt>
|
||||
<br><b><tt><font color="#993399">
|
||||
eoInitFixedLength<Indi, boolean_generator> </font></tt></b>
|
||||
<br><b><tt><font color="#993399">
|
||||
random(vecSize, boolean_generator());</font></tt></b>
|
||||
based on eoUniformGenerator class (see utils/eoRndGenerators.h)</font></tt>
|
||||
<br><b><tt><font color="#993399"> eoUniformGenerator<bool>
|
||||
uGen;</font></tt></b>
|
||||
<br><b><tt><font color="#993399"> eoInitFixedLength<Indi>
|
||||
random(vecSize, uGen);</font></tt></b>
|
||||
<br><tt><font color="#993399"><b> </b>//
|
||||
Init pop from the randomizer: need to use the append function</font></tt>
|
||||
<br><b><tt><font color="#993399">
|
||||
|
|
@ -284,7 +284,7 @@ and evaluate pop (STL syntax) </font></tt>
|
|||
<br><b><tt><font color="#993399">
|
||||
apply<Indi>(eval, pop);</font></tt></b>
|
||||
<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>
|
||||
</table>
|
||||
<a NAME="output"></a>
|
||||
|
|
@ -311,7 +311,6 @@ of initializatio of the population</font></tt></td>
|
|||
<tr>
|
||||
<td><tt><font color="#009900"><b> </b>// The robust tournament selection</font></tt>
|
||||
<br><tt><font color="#009900"><b> eoDetTournamentSelect<Indi> selectOne(tSize);
|
||||
|
||||
</b>// tSize in [2,POPSIZE]</font></tt>
|
||||
<br><tt><font color="#009900"><b> </b>// is now encapsulated in a
|
||||
eoSelectPerc (entage)</font></tt>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue