A full working version of ES is now available in tutorial/Lesson4,

that makes full use of libes.a.
The user guide is in Lesson4 of the tutorial - programmer's guide
will come later.
Plus many small changes here and there
This commit is contained in:
evomarc 2001-05-04 16:51:29 +00:00
commit 5508869d00
19 changed files with 653 additions and 189 deletions

View file

@ -90,10 +90,10 @@ class eoEsMutationInit
virtual std::string section(void)
{ return repSection; }
virtual std::string TauLclName(void) const { return "TauLcL"; }
virtual std::string TauLclName(void) const { return "TauLoc"; }
virtual char TauLclShort(void) const { return 'l'; }
virtual std::string TauGlbName(void) const { return "TauGlb"; }
virtual std::string TauGlbName(void) const { return "TauGlob"; }
virtual char TauGlbShort(void) const { return 'g'; }
virtual std::string TauBetaName(void) const { return "Beta"; }

View file

@ -329,13 +329,13 @@ protected:
double range; // == 1+2*alpha
};
/** eoArithmeticCrossover --> uniform choice in hypercube
/** eoHypercubeCrossover --> uniform choice in hypercube
== arithmetical with different values for each coordinate
\class eoArithmeticCrossover eoRealOp.h Tutorial/eoRealOp.h
\ingroup parameteric
*/
template<class EOT> class eoArithmeticCrossover: public eoQuadOp<EOT>
template<class EOT> class eoHypercubeCrossover: public eoQuadOp<EOT>
{
public:
/**
@ -347,7 +347,7 @@ template<class EOT> class eoArithmeticCrossover: public eoQuadOp<EOT>
* 0 == contractive application
* Must be positive
*/
eoArithmeticCrossover(const double& _alpha = 0.0):
eoHypercubeCrossover(const double& _alpha = 0.0):
bounds(eoDummyVectorNoBounds), alpha(_alpha), range(1+2*_alpha)
{
if (_alpha < 0)
@ -362,7 +362,7 @@ template<class EOT> class eoArithmeticCrossover: public eoQuadOp<EOT>
* 0 == contractive application
* Must be positive
*/
eoArithmeticCrossover(eoRealVectorBounds & _bounds,
eoHypercubeCrossover(eoRealVectorBounds & _bounds,
const double& _alpha = 0.0):
bounds(_bounds), alpha(_alpha), range(1+2*_alpha)
{
@ -371,10 +371,10 @@ template<class EOT> class eoArithmeticCrossover: public eoQuadOp<EOT>
}
/// The class name.
virtual string className() const { return "eoArithmeticCrossover"; }
virtual string className() const { return "eoHypercubeCrossover"; }
/**
* arithmetical crossover - modifies both parents
* hypercube crossover - modifies both parents
* @param _eo1 The first parent
* @param _eo2 The first parent
*/
@ -434,21 +434,21 @@ protected:
\ingroup parameteric
*/
template<class EOT> class eoRealUxOver: public eoQuadOp<EOT>
template<class EOT> class eoRealUXover: public eoQuadOp<EOT>
{
public:
/**
* (Default) Constructor.
* @param _preference bias in the choice (usually, no bias == 0.5)
*/
eoRealUxOver(const float& _preference = 0.5): preference(_preference)
eoRealUXover(const float& _preference = 0.5): preference(_preference)
{
if ( (_preference <= 0.0) || (_preference >= 1.0) )
runtime_error("UxOver --> invalid preference");
}
/// The class name.
virtual string className() const { return "eoRealUxOver"; }
virtual string className() const { return "eoRealUXover"; }
/**
* Uniform crossover for real vectors

View file

@ -130,10 +130,10 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoRealIni
// crossover
/////////////
// ES crossover
eoValueParam<string>& crossTypeParam = _parser.createParam(string("Global"), "crossType", "Type of ES recombination (gloabl or local)", 'C', "Variation Operators");
eoValueParam<string>& crossTypeParam = _parser.createParam(string("global"), "crossType", "Type of ES recombination (global or standard)", 'C', "Variation Operators");
eoValueParam<string>& crossObjParam = _parser.createParam(string("Discrete"), "crossObj", "Recombination of object variables (Discrete or Intermediate)", 'O', "Variation Operators");
eoValueParam<string>& crossStdevParam = _parser.createParam(string("Intermediate"), "crossStdev", "Recombination of mutation strategy parameters (Intermediate or Discrete)", 'S', "Variation Operators");
eoValueParam<string>& crossObjParam = _parser.createParam(string("discrete"), "crossObj", "Recombination of object variables (discrete or intermediate)", 'O', "Variation Operators");
eoValueParam<string>& crossStdevParam = _parser.createParam(string("intermediate"), "crossStdev", "Recombination of mutation strategy parameters (intermediate or discrete)", 'S', "Variation Operators");
// The pointers: first the atom Xover
eoBinOp<double> *ptObjAtomCross = NULL;
@ -142,22 +142,22 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoRealIni
eoGenOp<EOT> *ptCross;
// check for the atom Xovers
if (crossObjParam.value() == string("Discrete"))
if (crossObjParam.value() == string("discrete"))
ptObjAtomCross = new eoRealAtomExchange;
else if (crossObjParam.value() == string("Intermediate"))
else if (crossObjParam.value() == string("intermediate"))
ptObjAtomCross = new eoRealAtomExchange;
else throw runtime_error("Invalid Object variable crossover type");
if (crossStdevParam.value() == string("Discrete"))
if (crossStdevParam.value() == string("discrete"))
ptStdevAtomCross = new eoRealAtomExchange;
else if (crossStdevParam.value() == string("Intermediate"))
else if (crossStdevParam.value() == string("intermediate"))
ptStdevAtomCross = new eoRealAtomExchange;
else throw runtime_error("Invalid mutation strategy parameter crossover type");
// and build the indi Xover
if (crossTypeParam.value() == string("Global"))
if (crossTypeParam.value() == string("global"))
ptCross = new eoEsGlobalXover<EOT>(*ptObjAtomCross, *ptStdevAtomCross);
else if (crossTypeParam.value() == string("Local"))
else if (crossTypeParam.value() == string("standard"))
ptCross = new eoEsLocalXover<EOT>(*ptObjAtomCross, *ptStdevAtomCross);
else throw runtime_error("Invalide Object variable crossover type");

View file

@ -131,19 +131,30 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoRealIni
// the crossovers
/////////////////
// the parameters
eoValueParam<double>& alphaParam = _parser.createParam(double(0.0), "alpha", "Bound for factor of linear recombinations", 'a', "Variation Operators" );
// minimum check
if ( (alphaParam.value() < 0) )
throw runtime_error("Invalid BLX coefficient alpha");
eoValueParam<double>& segmentRateParam = _parser.createParam(double(1.0), "segmentRate", "Relative rate for segment crossover", 's', "Variation Operators" );
// minimum check
if ( (segmentRateParam.value() < 0) )
throw runtime_error("Invalid segmentRate");
eoValueParam<double>& arithmeticRateParam = _parser.createParam(double(2.0), "arithmeticRate", "Relative rate for arithmetic crossover", 'A', "Variation Operators" );
eoValueParam<double>& hypercubeRateParam = _parser.createParam(double(1.0), "hypercubeRate", "Relative rate for hypercube crossover", 'A', "Variation Operators" );
// minimum check
if ( (arithmeticRateParam.value() < 0) )
throw runtime_error("Invalid arithmeticRate");
if ( (hypercubeRateParam.value() < 0) )
throw runtime_error("Invalid hypercubeRate");
eoValueParam<double>& uxoverRateParam = _parser.createParam(double(1.0), "uxoverRate", "Relative rate for uniform crossover", 'A', "Variation Operators" );
// minimum check
if ( (uxoverRateParam.value() < 0) )
throw runtime_error("Invalid uxoverRate");
// minimum check
bool bCross = true;
if (segmentRateParam.value()+arithmeticRateParam.value()==0)
if (segmentRateParam.value()+hypercubeRateParam.value()+uxoverRateParam.value()==0)
{
cerr << "Warning: no crossover" << endl;
bCross = false;
@ -156,14 +167,19 @@ eoGenOp<EOT> & do_make_op(eoParameterLoader& _parser, eoState& _state, eoRealIni
if (bCross)
{
// segment crossover for bitstring - pass it the bounds
ptQuad = new eoSegmentCrossover<EOT>(*ptBounds);
ptQuad = new eoSegmentCrossover<EOT>(*ptBounds, alphaParam.value());
_state.storeFunctor(ptQuad);
ptCombinedQuadOp = new eoPropCombinedQuadOp<EOT>(*ptQuad, segmentRateParam.value());
// arithmetic crossover
ptQuad = new eoArithmeticCrossover<EOT>(*ptBounds);
// hypercube crossover
ptQuad = new eoHypercubeCrossover<EOT>(*ptBounds, alphaParam.value());
_state.storeFunctor(ptQuad);
ptCombinedQuadOp->add(*ptQuad, arithmeticRateParam.value());
ptCombinedQuadOp->add(*ptQuad, hypercubeRateParam.value());
// uniform crossover
ptQuad = new eoRealUXover<EOT>();
_state.storeFunctor(ptQuad);
ptCombinedQuadOp->add(*ptQuad, uxoverRateParam.value());
// don't forget to store the CombinedQuadOp
_state.storeFunctor(ptCombinedQuadOp);