From 5e31ae1338ef8eb3a855b598c4b4b0aa32ed00ce Mon Sep 17 00:00:00 2001 From: evomarc Date: Fri, 27 Oct 2000 04:38:29 +0000 Subject: [PATCH] added a second ctor with more didactic ordering of parameters (for tutorial) --- eo/src/eoSGA.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/eo/src/eoSGA.h b/eo/src/eoSGA.h index 1dcfe6101..110430b45 100644 --- a/eo/src/eoSGA.h +++ b/eo/src/eoSGA.h @@ -35,6 +35,14 @@ #include #include +/** 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 eoSGA : public eoAlgo { @@ -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& _select, + eoQuadraticOp& _cross, float _crate, + eoMonOp& _mutate, float _mrate, + eoEvalFunc& _eval, + eoContinue& _cont) + : cont(_cont), + mutate(_mutate), + mutationRate(_mrate), + cross(_cross), + crossoverRate(_crate), + select(_select), + eval(_eval) {} + void operator()(eoPop& _pop) { eoPop offspring;