I have changed all calls to use an eoParser rather than an eoParameterLoader
This is required if you want to use the method getParamWithLongName that allows one to get a value of a parameter read somewhere else. After changing 3 calls due to that, I decided to change ALL calls within the make_xxx functions
This commit is contained in:
parent
03045f2d58
commit
9b7556d81e
24 changed files with 104 additions and 92 deletions
|
|
@ -47,12 +47,12 @@
|
|||
|
||||
// Algo
|
||||
///////
|
||||
eoAlgo<eoBit<double> >& make_algo_scalar(eoParameterLoader& _parser, eoState& _state, eoEvalFunc<eoBit<double> >& _eval, eoContinue<eoBit<double> >& _continue, eoGenOp<eoBit<double> >& _op)
|
||||
eoAlgo<eoBit<double> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoBit<double> >& _eval, eoContinue<eoBit<double> >& _continue, eoGenOp<eoBit<double> >& _op)
|
||||
{
|
||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||
}
|
||||
|
||||
eoAlgo<eoBit<eoMinimizingFitness> >& make_algo_scalar(eoParameterLoader& _parser, eoState& _state, eoEvalFunc<eoBit<eoMinimizingFitness> >& _eval, eoContinue<eoBit<eoMinimizingFitness> >& _continue, eoGenOp<eoBit<eoMinimizingFitness> >& _op)
|
||||
eoAlgo<eoBit<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoBit<eoMinimizingFitness> >& _eval, eoContinue<eoBit<eoMinimizingFitness> >& _continue, eoGenOp<eoBit<eoMinimizingFitness> >& _op)
|
||||
{
|
||||
return do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@
|
|||
|
||||
// checkpoint
|
||||
/////////////
|
||||
eoCheckPoint<eoBit<double> >& make_checkpoint(eoParameterLoader& _parser, eoState& _state, eoEvalFuncCounter<eoBit<double> >& _eval, eoContinue<eoBit<double> >& _continue)
|
||||
eoCheckPoint<eoBit<double> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoBit<double> >& _eval, eoContinue<eoBit<double> >& _continue)
|
||||
{
|
||||
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||
}
|
||||
eoCheckPoint<eoBit<eoMinimizingFitness> >& make_checkpoint(eoParameterLoader& _parser, eoState& _state, eoEvalFuncCounter<eoBit<eoMinimizingFitness> >& _eval, eoContinue<eoBit<eoMinimizingFitness> >& _continue)
|
||||
eoCheckPoint<eoBit<eoMinimizingFitness> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoBit<eoMinimizingFitness> >& _eval, eoContinue<eoBit<eoMinimizingFitness> >& _continue)
|
||||
{
|
||||
return do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,12 +52,12 @@
|
|||
//////////////////////////
|
||||
|
||||
// the genotypes
|
||||
eoInit<eoBit<double> > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoBit<double> _eo);
|
||||
eoInit<eoBit<eoMinimizingFitness> > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoBit<eoMinimizingFitness> _eo);
|
||||
eoInit<eoBit<double> > & make_genotype(eoParser& _parser, eoState& _state, eoBit<double> _eo);
|
||||
eoInit<eoBit<eoMinimizingFitness> > & make_genotype(eoParser& _parser, eoState& _state, eoBit<eoMinimizingFitness> _eo);
|
||||
|
||||
// the operators
|
||||
eoGenOp<eoBit<double> >& make_op(eoParameterLoader& _parser, eoState& _state, eoInit<eoBit<double> >& _init);
|
||||
eoGenOp<eoBit<eoMinimizingFitness> >& make_op(eoParameterLoader& _parser, eoState& _state, eoInit<eoBit<eoMinimizingFitness> >& _init);
|
||||
eoGenOp<eoBit<double> >& make_op(eoParser& _parser, eoState& _state, eoInit<eoBit<double> >& _init);
|
||||
eoGenOp<eoBit<eoMinimizingFitness> >& make_op(eoParser& _parser, eoState& _state, eoInit<eoBit<eoMinimizingFitness> >& _init);
|
||||
|
||||
//Representation INdependent
|
||||
////////////////////////////
|
||||
|
|
@ -72,14 +72,14 @@ eoContinue<eoBit<double> >& make_continue(eoParser& _parser, eoState& _state, eo
|
|||
eoContinue<eoBit<eoMinimizingFitness> >& make_continue(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoBit<eoMinimizingFitness> > & _eval);
|
||||
|
||||
// the checkpoint
|
||||
eoCheckPoint<eoBit<double> >& make_checkpoint(eoParameterLoader& _parser, eoState& _state, eoEvalFuncCounter<eoBit<double> >& _eval, eoContinue<eoBit<double> >& _continue);
|
||||
eoCheckPoint<eoBit<eoMinimizingFitness> >& make_checkpoint(eoParameterLoader& _parser, eoState& _state, eoEvalFuncCounter<eoBit<eoMinimizingFitness> >& _eval, eoContinue<eoBit<eoMinimizingFitness> >& _continue);
|
||||
eoCheckPoint<eoBit<double> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoBit<double> >& _eval, eoContinue<eoBit<double> >& _continue);
|
||||
eoCheckPoint<eoBit<eoMinimizingFitness> >& make_checkpoint(eoParser& _parser, eoState& _state, eoEvalFuncCounter<eoBit<eoMinimizingFitness> >& _eval, eoContinue<eoBit<eoMinimizingFitness> >& _continue);
|
||||
|
||||
|
||||
// the algo
|
||||
eoAlgo<eoBit<double> >& make_algo_scalar(eoParameterLoader& _parser, eoState& _state, eoEvalFunc<eoBit<double> >& _eval, eoContinue<eoBit<double> >& _ccontinue, eoGenOp<eoBit<double> >& _op);
|
||||
eoAlgo<eoBit<double> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoBit<double> >& _eval, eoContinue<eoBit<double> >& _ccontinue, eoGenOp<eoBit<double> >& _op);
|
||||
|
||||
eoAlgo<eoBit<eoMinimizingFitness> >& make_algo_scalar(eoParameterLoader& _parser, eoState& _state, eoEvalFunc<eoBit<eoMinimizingFitness> >& _eval, eoContinue<eoBit<eoMinimizingFitness> >& _ccontinue, eoGenOp<eoBit<eoMinimizingFitness> >& _op);
|
||||
eoAlgo<eoBit<eoMinimizingFitness> >& make_algo_scalar(eoParser& _parser, eoState& _state, eoEvalFunc<eoBit<eoMinimizingFitness> >& _eval, eoContinue<eoBit<eoMinimizingFitness> >& _ccontinue, eoGenOp<eoBit<eoMinimizingFitness> >& _op);
|
||||
|
||||
// run
|
||||
void run_ea(eoAlgo<eoBit<double> >& _ga, eoPop<eoBit<double> >& _pop);
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@
|
|||
|
||||
/// The following function merely call the templatized do_* functions above
|
||||
|
||||
eoInit<eoBit<double> > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoBit<double> _eo)
|
||||
eoInit<eoBit<double> > & make_genotype(eoParser& _parser, eoState& _state, eoBit<double> _eo)
|
||||
{
|
||||
return do_make_genotype(_parser, _state, _eo);
|
||||
}
|
||||
eoInit<eoBit<eoMinimizingFitness> > & make_genotype(eoParameterLoader& _parser, eoState& _state, eoBit<eoMinimizingFitness> _eo)
|
||||
eoInit<eoBit<eoMinimizingFitness> > & make_genotype(eoParser& _parser, eoState& _state, eoBit<eoMinimizingFitness> _eo)
|
||||
{
|
||||
return do_make_genotype(_parser, _state, _eo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,16 +58,28 @@
|
|||
*/
|
||||
|
||||
template <class EOT>
|
||||
eoInit<EOT> & do_make_genotype(eoParameterLoader& _parser, eoState& _state, EOT)
|
||||
eoInit<EOT> & do_make_genotype(eoParser& _parser, eoState& _state, EOT)
|
||||
{
|
||||
// for bitstring, only thing needed is the size
|
||||
eoValueParam<unsigned>& chromSize = _parser.createParam(unsigned(10), "ChromSize", "The length of the bitstrings", 'n',"Genotype Initialization");
|
||||
unsigned theSize;
|
||||
// but it might have been already read in the definition fo the performance
|
||||
eoParam* ptParam = _parser.getParamWithLongName(string("ChromSize"));
|
||||
|
||||
if (!ptParam) // not already defined: read it here
|
||||
{
|
||||
theSize = _parser.createParam(unsigned(10), "ChromSize", "The length of the bitstrings", 'n',"Problem").value();
|
||||
}
|
||||
else // it was read before, get its value
|
||||
{
|
||||
eoValueParam<unsigned>* ptChromSize = dynamic_cast<eoValueParam<unsigned>*>(ptParam);
|
||||
theSize = ptChromSize->value();
|
||||
}
|
||||
|
||||
// Then we can built a bitstring random initializer
|
||||
// based on boolean_generator class (see utils/rnd_generator.h)
|
||||
eoBooleanGenerator * gen = new eoBooleanGenerator;
|
||||
_state.storeFunctor(gen);
|
||||
eoInitFixedLength<EOT>* init = new eoInitFixedLength<EOT>(chromSize.value(), *gen);
|
||||
eoInitFixedLength<EOT>* init = new eoInitFixedLength<EOT>(theSize, *gen);
|
||||
// store in state
|
||||
_state.storeFunctor(init);
|
||||
return *init;
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
*/
|
||||
|
||||
template <class EOT>
|
||||
eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoInit<EOT>& _init)
|
||||
eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoInit<EOT>& _init)
|
||||
{
|
||||
// this is a temporary version, while Maarten codes the full tree-structured
|
||||
// general operator input
|
||||
|
|
|
|||
|
|
@ -45,12 +45,12 @@
|
|||
|
||||
// oeprators
|
||||
////////////
|
||||
eoGenOp<eoBit<double> >& make_op(eoParameterLoader& _parser, eoState& _state, eoInit<eoBit<double> >& _init)
|
||||
eoGenOp<eoBit<double> >& make_op(eoParser& _parser, eoState& _state, eoInit<eoBit<double> >& _init)
|
||||
{
|
||||
return do_make_op(_parser, _state, _init);
|
||||
}
|
||||
|
||||
eoGenOp<eoBit<eoMinimizingFitness> >& make_op(eoParameterLoader& _parser, eoState& _state, eoInit<eoBit<eoMinimizingFitness> >& _init)
|
||||
eoGenOp<eoBit<eoMinimizingFitness> >& make_op(eoParser& _parser, eoState& _state, eoInit<eoBit<eoMinimizingFitness> >& _init)
|
||||
{
|
||||
return do_make_op(_parser, _state, _init);
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue