added a second ctor with more didactic ordering of parameters (for tutorial)
This commit is contained in:
parent
2a0a3e074d
commit
5e31ae1338
1 changed files with 24 additions and 0 deletions
|
|
@ -35,6 +35,14 @@
|
|||
#include <eoEvalFunc.h>
|
||||
#include <eoAlgo.h>
|
||||
|
||||
/** The Simple Genetic Algorithm, following Holland and Goldberg
|
||||
* Needs a selector (class eoSelectOne) a crossover (eoQuadratic,
|
||||
* i.e. a 2->2 operator) and a mutation with their respective rates,
|
||||
* of course an evaluation function (eoEvalFunc) and a continuator
|
||||
* (eoContinue) which gives the stopping criterion. Performs full
|
||||
* generational replacement.
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
class eoSGA : public eoAlgo<EOT>
|
||||
{
|
||||
|
|
@ -53,6 +61,22 @@ public :
|
|||
select(_select),
|
||||
eval(_eval) {}
|
||||
|
||||
// added this second ctor as I didn't like the ordering of the parameters
|
||||
// in the one above. Any objection :-) MS
|
||||
eoSGA(
|
||||
eoSelectOne<EOT>& _select,
|
||||
eoQuadraticOp<EOT>& _cross, float _crate,
|
||||
eoMonOp<EOT>& _mutate, float _mrate,
|
||||
eoEvalFunc<EOT>& _eval,
|
||||
eoContinue<EOT>& _cont)
|
||||
: cont(_cont),
|
||||
mutate(_mutate),
|
||||
mutationRate(_mrate),
|
||||
cross(_cross),
|
||||
crossoverRate(_crate),
|
||||
select(_select),
|
||||
eval(_eval) {}
|
||||
|
||||
void operator()(eoPop<EOT>& _pop)
|
||||
{
|
||||
eoPop<EOT> offspring;
|
||||
|
|
|
|||
Reference in a new issue