diff --git a/eo/src/ga/Makefile.am b/eo/src/ga/Makefile.am index 783e68f3..08bc0498 100644 --- a/eo/src/ga/Makefile.am +++ b/eo/src/ga/Makefile.am @@ -17,4 +17,4 @@ libga_a_SOURCES = make_algo_scalar_ga.cpp \ CPPFLAGS = -Wall CXXFLAGS = -g libeoincdir = $(includedir)/eo/ga -libeoinc_HEADERS = eoBit.h eoBitOp.h eoBitOpFactory.h ga.h +libeoinc_HEADERS = eoBit.h eoBitOp.h eoBitOpFactory.h make_ga.h diff --git a/eo/src/ga/ga.h b/eo/src/ga/make_ga.h similarity index 97% rename from eo/src/ga/ga.h rename to eo/src/ga/make_ga.h index 244a3050..861cbb77 100644 --- a/eo/src/ga/ga.h +++ b/eo/src/ga/make_ga.h @@ -52,8 +52,8 @@ ////////////////////////// // the genotypes -eoInit > & make_genotype(eoParameterLoader& _parser, eoState& _state, double _d); - eoInit > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoMinimizingFitness _d); +eoInit > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoBit _eo); + eoInit > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoBit _eo); // the operators eoGenOp >& make_op(eoParameterLoader& _parser, eoState& _state, eoInit >& _init); diff --git a/eo/src/ga/make_genotype_ga.cpp b/eo/src/ga/make_genotype_ga.cpp index d6ed1b83..6903e426 100644 --- a/eo/src/ga/make_genotype_ga.cpp +++ b/eo/src/ga/make_genotype_ga.cpp @@ -31,23 +31,20 @@ * files that you just need to link with your own main and fitness code). * * The corresponding ***INSTANCIATED DECLARATIONS*** are contained - * in make_genotype_ga.h - * while the TEMPLATIZED code is define in make_genotype.h in the ga dir - * - * Unlike most EO .h files, it does not (and should not) contain any code, - * just declarations + * in ga.h in src/ga dir + * while the TEMPLATIZED code is define in make_genotype_ga.h */ // the templatized code -#include +#include /// The following function merely call the templatized do_* functions above -eoInit > & make_genotype(eoParameterLoader& _parser, eoState& _state, double _d) +eoInit > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoBit _eo) { - return do_make_genotype(_parser, _state, _d); + return do_make_genotype(_parser, _state, _eo); } -eoInit > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoMinimizingFitness _d) +eoInit > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoBit _eo) { - return do_make_genotype(_parser, _state, _d); + return do_make_genotype(_parser, _state, _eo); } diff --git a/eo/src/ga/make_genotype.h b/eo/src/ga/make_genotype_ga.h similarity index 77% rename from eo/src/ga/make_genotype.h rename to eo/src/ga/make_genotype_ga.h index ce8270e1..a0d5d92b 100644 --- a/eo/src/ga/make_genotype.h +++ b/eo/src/ga/make_genotype_ga.h @@ -38,8 +38,12 @@ /* * This fuciont does the initialization of what's needed for a particular * genotype (here, bitstrings). - * It is templatized ***olny on the fitness*** so it can be used to evolve + * It could be here tempatied only on the fitness, as it can be used to evolve * bitstrings with any fitness. + * However, for consistency reasons, it was finally chosen, as in + * the rest of EO, to templatize by the full EOT, as this eventually + * allows to choose the type of genotype at run time (see in es dir) + * * It is instanciated in ga/ga.cpp - and incorporated in the ga/libga.a * * It returns an eoInit > tha can later be used to initialize @@ -47,10 +51,15 @@ * * It uses a parser (to get user parameters) and a state (to store the memory) * the last argument is to disambiguate the call upon different instanciations. + * + * WARNING: that last argument will generally be the result of calling + * the default ctor of EOT, resulting in most cases in an EOT + * that is ***not properly initialized*** + */ -template -eoInit > & do_make_genotype(eoParameterLoader& _parser, eoState& _state, FitT) +template +eoInit & do_make_genotype(eoParameterLoader& _parser, eoState& _state, EOT) { // for bitstring, only thing needed is the size eoValueParam& chromSize = _parser.createParam(unsigned(10), "ChromSize", "The length of the bitstrings", 'n',"initialization"); @@ -59,8 +68,8 @@ eoInit > & do_make_genotype(eoParameterLoader& _parser, eoState& _st // based on boolean_generator class (see utils/rnd_generator.h) eoBooleanGenerator * gen = new eoBooleanGenerator; _state.storeFunctor(gen); - eoInitFixedLength >* init = new eoInitFixedLength >(chromSize.value(), *gen); - // satore in state + eoInitFixedLength* init = new eoInitFixedLength(chromSize.value(), *gen); + // store in state _state.storeFunctor(init); return *init; }