added shuffle
This commit is contained in:
parent
b6104c6f32
commit
43b5effcdb
1 changed files with 7 additions and 0 deletions
|
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
#include <utils/eoRNG.h>
|
#include <utils/eoRNG.h>
|
||||||
#include <eoSelectOne.h>
|
#include <eoSelectOne.h>
|
||||||
|
#include <utils/selectors.h>
|
||||||
|
#include <eoPop.h>
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** eoStochasticUniversalSelect: select an individual proportional to her stored fitness
|
/** eoStochasticUniversalSelect: select an individual proportional to her stored fitness
|
||||||
|
|
@ -80,6 +82,11 @@ public:
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// shuffle
|
||||||
|
for (int i = indices.size() - 1; i > 0; --i) {
|
||||||
|
int j = rng.random(i+1);
|
||||||
|
swap(indices[i], indices[j]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** do the selection,
|
/** do the selection,
|
||||||
|
|
|
||||||
Reference in a new issue