diff --git a/eo/src/es/eoNormalMutation.h b/eo/src/es/eoNormalMutation.h index cb4ef551..3b9b4888 100644 --- a/eo/src/es/eoNormalMutation.h +++ b/eo/src/es/eoNormalMutation.h @@ -36,6 +36,74 @@ #include //----------------------------------------------------------------------------- +/** Simple normal mutation of a std::vector of real values. + * The stDev is fixed - but it is passed ans stored as a reference, + * to enable dynamic mutations (see eoOenFithMutation below). + * + * As for the bounds, the values are here folded back into the bounds. + * The other possiblity would be to iterate until we fall inside the bounds - + * but this sometimes takes a long time!!! + */ + +template class eoNormalVecMutation: public eoMonOp +{ + public: + /** + * (Default) Constructor. + * The bounds are initialized with the global object that says: no bounds. + * + * @param _sigma the range for uniform nutation + * @param _p_change the probability to change a given coordinate + */ + eoNormalVecMutation(double _sigma, const double& _p_change = 1.0): + sigma(_sigma), bounds(eoDummyVectorNoBounds), p_change(_p_change) {} + + /** + * Constructor with bounds + * @param _bounds an eoRealVectorBounds that contains the bounds + * @param _sigma the range for uniform nutation + * @param _p_change the probability to change a given coordinate + * + * for each component, the sigma is scaled to the range of the bound, if bounded + */ + eoNormalVecMutation(eoRealVectorBounds & _bounds, + double _sigma, const double& _p_change = 1.0): + sigma(_bounds.size(), _sigma), bounds(_bounds), p_change(_p_change) + { + // scale to the range - if any + for (unsigned i=0; i sigma; + eoRealVectorBounds & bounds; + double p_change; +}; + /** Simple normal mutation of a std::vector of real values. * The stDev is fixed - but it is passed ans stored as a reference, * to enable dynamic mutations (see eoOenFithMutation below).