invalidating supported now
This commit is contained in:
parent
ead2ac2c62
commit
492899bfb2
1 changed files with 12 additions and 7 deletions
|
|
@ -78,18 +78,23 @@ public :
|
||||||
for (i=0; i<_pop.size()/2; i++)
|
for (i=0; i<_pop.size()/2; i++)
|
||||||
{
|
{
|
||||||
if ( rng.flip(crossoverRate) )
|
if ( rng.flip(crossoverRate) )
|
||||||
{
|
{
|
||||||
// this crossover generates 2 offspring from two parents
|
// this crossover generates 2 offspring from two parents
|
||||||
cross(offspring[2*i], offspring[2*i+1]);
|
if (cross(offspring[2*i], offspring[2*i+1]))
|
||||||
}
|
{
|
||||||
|
offspring[2*i].invalidate();
|
||||||
|
offspring[2*i+1].invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i < _pop.size(); i++)
|
for (i=0; i < _pop.size(); i++)
|
||||||
{
|
{
|
||||||
if (rng.flip(mutationRate) )
|
if (rng.flip(mutationRate) )
|
||||||
{
|
{
|
||||||
mutate(offspring[i]);
|
if (mutate(offspring[i]))
|
||||||
}
|
offspring[i].invalidate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_pop.swap(offspring);
|
_pop.swap(offspring);
|
||||||
|
|
|
||||||
Reference in a new issue