Some changes for the use in paradisEO

This commit is contained in:
cahon 2002-03-27 17:31:05 +00:00
commit e95578b3fc

View file

@ -28,7 +28,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <apply.h> #include <apply.h>
#include <eoAlgo.h> #include <eoPopAlgo.h>
#include <eoPopEvalFunc.h> #include <eoPopEvalFunc.h>
#include <eoContinue.h> #include <eoContinue.h>
#include <eoSelect.h> #include <eoSelect.h>
@ -55,7 +55,11 @@ Note: it looks ugly only because we wanted to authorize many different
constructors. Please only look at the operator() and there shall be light constructors. Please only look at the operator() and there shall be light
*/ */
template<class EOT> class eoEasyEA: public eoAlgo<EOT> template <class EOT> class eoIslandsEasyEA ;
template <class EOT> class eoDistEvalEasyEA ;
template<class EOT> class eoEasyEA: public eoPopAlgo<EOT>
{ {
public: public:
@ -66,14 +70,33 @@ template<class EOT> class eoEasyEA: public eoAlgo<EOT>
eoBreed<EOT>& _breed, eoBreed<EOT>& _breed,
eoReplacement<EOT>& _replace eoReplacement<EOT>& _replace
) : continuator(_continuator), ) : continuator(_continuator),
eval (_eval),
loopEval(_eval), loopEval(_eval),
popEval(loopEval), popEval(loopEval),
selectTransform(dummySelect, dummyTransform), selectTransform(dummySelect, dummyTransform),
breed(_breed), breed(_breed),
mergeReduce(dummyMerge, dummyReduce), mergeReduce(dummyMerge, dummyReduce),
replace(_replace) replace(_replace)
{} {}
/*
eoEasyEA(eoContinue <EOT> & _continuator,
eoPopEvalFunc <EOT> & _pop_eval,
eoBreed <EOT> & _breed,
eoReplacement <EOT> & _replace
) :
continuator (_continuator),
eval (dummyEval),
loopEval(dummyEval),
popEval (_pop_eval),
selectTransform (dummySelect, dummyTransform),
breed (_breed),
mergeReduce (dummyMerge, dummyReduce),
replace (_replace) {
}
*/
/** NEW Ctor taking a breed and merge and an eoPopEval */ /** NEW Ctor taking a breed and merge and an eoPopEval */
eoEasyEA( eoEasyEA(
eoContinue<EOT>& _continuator, eoContinue<EOT>& _continuator,
@ -81,6 +104,7 @@ template<class EOT> class eoEasyEA: public eoAlgo<EOT>
eoBreed<EOT>& _breed, eoBreed<EOT>& _breed,
eoReplacement<EOT>& _replace eoReplacement<EOT>& _replace
) : continuator(_continuator), ) : continuator(_continuator),
eval (dummyEval),
loopEval(dummyEval), loopEval(dummyEval),
popEval(_eval), popEval(_eval),
selectTransform(dummySelect, dummyTransform), selectTransform(dummySelect, dummyTransform),
@ -97,6 +121,7 @@ template<class EOT> class eoEasyEA: public eoAlgo<EOT>
eoMerge<EOT>& _merge, eoMerge<EOT>& _merge,
eoReduce<EOT>& _reduce eoReduce<EOT>& _reduce
) : continuator(_continuator), ) : continuator(_continuator),
eval (_eval),
loopEval(_eval), loopEval(_eval),
popEval(loopEval), popEval(loopEval),
selectTransform(dummySelect, dummyTransform), selectTransform(dummySelect, dummyTransform),
@ -113,6 +138,7 @@ template<class EOT> class eoEasyEA: public eoAlgo<EOT>
eoTransform<EOT>& _transform, eoTransform<EOT>& _transform,
eoReplacement<EOT>& _replace eoReplacement<EOT>& _replace
) : continuator(_continuator), ) : continuator(_continuator),
eval (_eval),
loopEval(_eval), loopEval(_eval),
popEval(loopEval), popEval(loopEval),
selectTransform(_select, _transform), selectTransform(_select, _transform),
@ -130,6 +156,7 @@ template<class EOT> class eoEasyEA: public eoAlgo<EOT>
eoMerge<EOT>& _merge, eoMerge<EOT>& _merge,
eoReduce<EOT>& _reduce eoReduce<EOT>& _reduce
) : continuator(_continuator), ) : continuator(_continuator),
eval (_eval),
loopEval(_eval), loopEval(_eval),
popEval(loopEval), popEval(loopEval),
selectTransform(_select, _transform), selectTransform(_select, _transform),
@ -145,7 +172,6 @@ template<class EOT> class eoEasyEA: public eoAlgo<EOT>
virtual void operator()(eoPop<EOT>& _pop) virtual void operator()(eoPop<EOT>& _pop)
{ {
eoPop<EOT> offspring; eoPop<EOT> offspring;
do do
{ {
try try
@ -174,11 +200,11 @@ template<class EOT> class eoEasyEA: public eoAlgo<EOT>
} while ( continuator( _pop ) ); } while ( continuator( _pop ) );
} }
private: protected :
// If selectTransform needs not be used, dummySelect and dummyTransform are used // If selectTransform needs not be used, dummySelect and dummyTransform are used
// to instantiate it. // to instantiate it.
class eoDummySelect : public eoSelect<EOT> class eoDummySelect : public eoSelect<EOT>
{ public : void operator()(const eoPop<EOT>&, eoPop<EOT>&) {} } dummySelect; { public : void operator()(const eoPop<EOT>&, eoPop<EOT>&) {} } dummySelect;
class eoDummyTransform : public eoTransform<EOT> class eoDummyTransform : public eoTransform<EOT>
@ -189,7 +215,9 @@ template<class EOT> class eoEasyEA: public eoAlgo<EOT>
eoContinue<EOT>& continuator; eoContinue<EOT>& continuator;
eoEvalFunc <EOT> & eval ;
eoPopLoopEval<EOT> loopEval; eoPopLoopEval<EOT> loopEval;
eoPopEvalFunc<EOT>& popEval; eoPopEvalFunc<EOT>& popEval;
eoSelectTransform<EOT> selectTransform; eoSelectTransform<EOT> selectTransform;
@ -202,6 +230,10 @@ template<class EOT> class eoEasyEA: public eoAlgo<EOT>
eoMergeReduce<EOT> mergeReduce; eoMergeReduce<EOT> mergeReduce;
eoReplacement<EOT>& replace; eoReplacement<EOT>& replace;
// Friend classes
friend class eoIslandsEasyEA <EOT> ;
friend class eoDistEvalEasyEA <EOT> ;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------