prepare vecInitSize

This commit is contained in:
kuepper 2005-10-10 21:59:57 +00:00
commit 89b76ab261
4 changed files with 395 additions and 277 deletions

View file

@ -1,33 +1,32 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- //
/* (c) Maarten Keijzer 2000, GeNeura Team, 1998 - EEAAX 1999
//----------------------------------------------------------------------------- This library is free software; you can redistribute it and/or modify it under
// eoEsChromInit.h the terms of the GNU Lesser General Public License as published by the Free
// (c) Maarten Keijzer 2000, GeNeura Team, 1998 - EEAAX 1999 Software Foundation; either version 2 of the License, or (at your option) any
/* later version.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful, but WITHOUT ANY
but WITHOUT ANY WARRANTY; without even the implied warranty of WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public License along
License along with this library; if not, write to the Free Software with this library; if not, write to the Free Software Foundation, Inc., 59
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es Contact: http://eodev.sourceforge.net
Marc.Schoenauer@polytechnique.fr todos@geneura.ugr.es, http://geneura.ugr.es
mak@dhi.dk Marc.Schoenauer@polytechnique.fr
mak@dhi.dk
*/ */
//-----------------------------------------------------------------------------
#ifndef _eoEsChromInit_H #ifndef _eoEsChromInit_H
#define _eoEsChromInit_H #define _eoEsChromInit_H
#include <cmath> #include <cmath>
#include <vector>
#include <es/eoRealInitBounded.h> #include <es/eoRealInitBounded.h>
#include <es/eoEsSimple.h> #include <es/eoEsSimple.h>
#include <es/eoEsStdev.h> #include <es/eoEsStdev.h>
@ -37,116 +36,167 @@
#define M_PI 3.1415926535897932384626433832795 #define M_PI 3.1415926535897932384626433832795
#endif #endif
/** /** Random Es-chromosome initializer (therefore derived from eoInit)
\ingroup EvolutionStrategies
Random Es-chromosome initializer (therefore derived from eoInit) @ingroup EvolutionStrategies
This class can initialize four types of real-valued genotypes
thanks to tempate specialization of private method create
eoReal just an eoVector<double> This class can initialize four types of real-valued genotypes thanks
eoEsSimple + one self-adapting single sigma for all variables to tempate specialization of private method create:
eoEsStdev a whole std::vector of self-adapting sigmas
eoEsFull a full self-adapting correlation matrix
@see eoReal eoEsSimple eoEsStdev eoEsFull eoInit - eoReal just an eoVector<double>
- eoEsSimple + one self-adapting single sigma for all variables
- eoEsStdev a whole std::vector of self-adapting sigmas
- eoEsFull a full self-adapting correlation matrix
@see eoReal eoEsSimple eoEsStdev eoEsFull eoInit
*/ */
template <class EOT> template <class EOT>
class eoEsChromInit : public eoRealInitBounded<EOT> class eoEsChromInit : public eoRealInitBounded<EOT>
{ {
public: public:
using eoEsChromInit< EOT >::size; using eoEsChromInit<EOT>::size;
using eoEsChromInit< EOT >::theBounds; using eoEsChromInit<EOT>::theBounds;
typedef typename EOT::Fitness FitT; typedef typename EOT::Fitness FitT;
/** Ctor: /** Constructor
@param eoRealVectorBounds& _bounds : bounds for uniform initialization @param _bounds bounds for uniform initialization
@param _sigma : initial value for the stddev @param _sigma initial value for the stddev
@param _to_scale : wether sigma should be multiplied by the range of each variable @param _to_scale wether sigma should be multiplied by the range of each variable
added December 2004 - MS (together with the whole comment :-) added December 2004 - MS (together with the whole comment :-)
*/ */
eoEsChromInit(eoRealVectorBounds& _bounds, double _sigma = 0.3, bool _to_scale=false) eoEsChromInit(eoRealVectorBounds& _bounds, double _sigma = 0.3, bool _to_scale=false)
: eoRealInitBounded<EOT>(_bounds) : eoRealInitBounded<EOT>(_bounds)
{ {
// a bit of pre-computations, to save time later (even if some are useless) // a bit of pre-computations, to save time later (even if some are useless)
//
// first, in the case of one unique sigma
// sigma is scaled by the average range (if that means anything!)
if (_to_scale)
{
double scaleUnique = 0;
for (unsigned i=0; i<size(); i++)
scaleUnique += theBounds().range(i);
scaleUnique /= size();
uniqueSigma = _sigma * scaleUnique;
}
else
uniqueSigma = _sigma;
// now the case of a vector of sigmas first allocate space according
// to the size of the bounds (see eoRealInitBounded)
vecSigma.resize(size());
// each sigma is scaled by the range of the corresponding variable
for(unsigned i=0; i<size(); i++)
if(_to_scale)
vecSigma[i] = _sigma * theBounds().range(i);
else
vecSigma[i] = _sigma;
}
// first, the case of one unique sigma
if (_to_scale) // sigma is scaled by the average range (if that means anything!)
{
double scaleUnique = 0;
for (unsigned i=0; i<size(); i++)
scaleUnique += theBounds().range(i);
scaleUnique /= size();
uniqueSigma = _sigma * scaleUnique;
}
else
uniqueSigma = _sigma;
// now the case of a vector of sigmas /** Constructor
// first allocate
lesSigmas.resize(size()); // size() is the size of the bounds (see eoRealInitBounded)
for (unsigned i=0; i<size(); i++) @overload
if (_to_scale) // each sigma is scaled by the range of the corresponding variable
{
lesSigmas[i] = _sigma * theBounds().range(i);
}
else
lesSigmas[i] = _sigma;
}
void operator()(EOT& _eo) Specify individual initial sigmas for each variable.
{
eoRealInitBounded<EOT>::operator()(_eo);
create_self_adapt(_eo);
_eo.invalidate(); // was MISSING!!!!
}
// accessor to sigma @param _bounds bounds for uniform initialization
// double sigmaInit() {return sigma;} @param _sigma initial value for the stddev
*/
eoEsChromInit(eoRealVectorBounds& _bounds, std::vector<double> _vecSigma)
: eoRealInitBounded<EOT>(_bounds), uniqueSigma(_vecSigma[0]), vecSigma(_vecSigma)
{}
private :
// No adaptive mutation at all void operator()(EOT& _eo)
void create_self_adapt(eoReal<FitT>&)// nothing to do here ... {
{ } eoRealInitBounded<EOT>::operator()(_eo);
create_self_adapt(_eo);
_eo.invalidate();
}
// Adaptive mutation through a unique sigma
void create_self_adapt(eoEsSimple<FitT>& result)
{
// pre-computed in the Ctor
result.stdev = uniqueSigma;
}
// Adaptive mutation through a std::vector of sigmas private:
void create_self_adapt(eoEsStdev<FitT>& result)
{
result.stdevs = lesSigmas;
}
// Adaptive mutation through a whole correlation matrix /** Create intializer
void create_self_adapt(eoEsFull<FitT>& result)
{
// first the stdevs (pre-computed in the Ctor)
result.stdevs = lesSigmas;
unsigned int theSize = size();
// nb of rotation angles: N*(N-1)/2 (in general!)
result.correlations.resize(theSize*(theSize - 1) / 2);
for (unsigned i=0; i<result.correlations.size(); ++i)
{
// uniform in [-PI, PI)
result.correlations[i] = rng.uniform(2 * M_PI) - M_PI;
}
}
// the DATA No adaptive mutation at all
double uniqueSigma; // initial value in case of a unique sigma */
std::vector<double> lesSigmas; // initial values in case of a vector fo sigmas void create_self_adapt(eoReal<FitT>&)
{}
/** Create intializer
@overload
Adaptive mutation through a unique sigma
*/
void create_self_adapt(eoEsSimple<FitT>& result)
{
// pre-computed in the Ctor
result.stdev = uniqueSigma;
}
/** Create intializer
@overload
Adaptive mutation through a std::vector of sigmas
@todo Should we scale sigmas to the corresponding object variable range?
*/
void create_self_adapt(eoEsStdev<FitT>& result)
{
// pre-computed in the constructor
result.stdevs = vecSigma;
}
/** Create intializer
@overload
Adaptive mutation through a whole correlation matrix
*/
void create_self_adapt(eoEsFull<FitT>& result)
{
// first the stdevs (pre-computed in the Ctor)
result.stdevs = vecSigma;
unsigned int theSize = size();
// nb of rotation angles: N*(N-1)/2 (in general!)
result.correlations.resize(theSize*(theSize - 1) / 2);
for (unsigned i=0; i<result.correlations.size(); ++i)
{
// uniform in [-PI, PI)
result.correlations[i] = rng.uniform(2 * M_PI) - M_PI;
}
}
/** Initial value in case of a unique sigma */
double uniqueSigma;
/** Initial values in case of a vector of sigmas */
std::vector<double> vecSigma;
}; };
#endif #endif
// Local Variables:
// coding: iso-8859-1
// mode:C++
// c-file-style: "Stroustrup"
// comment-column: 35
// fill-column: 80
// End:

View file

@ -1,86 +1,121 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- /* (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
//----------------------------------------------------------------------------- This library is free software; you can redistribute it and/or modify it under
// make_genotype_real.cpp the terms of the GNU Lesser General Public License as published by the Free
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001 Software Foundation; either version 2 of the License, or (at your option) any
/* later version.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful, but WITHOUT ANY
but WITHOUT ANY WARRANTY; without even the implied warranty of WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public License along
License along with this library; if not, write to the Free Software with this library; if not, write to the Free Software Foundation, Inc., 59
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: http://eodev.sourceforge.net
todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
#ifdef _MSC_VER #ifdef _MSC_VER
// to avoid long name warnings // to avoid long name warnings
#pragma warning(disable:4786) #pragma warning(disable:4786)
#endif #endif
/** This file contains ***INSTANCIATED DEFINITIONS*** of eoReal Init fns
* It should be included in the file that calls any of the corresponding fns /** Init functions
* Compiling this file allows one to generate part of the library (i.e. object
* files that you just need to link with your own main and fitness code). This file contains ***INSTANCIATED DEFINITIONS*** of eoReal Init fns
* It should be included in the file that calls any of the corresponding
* The corresponding ***INSTANCIATED DECLARATIONS*** are contained fns Compiling this file allows one to generate part of the library
* in src/es/make_real.h (i.e. object files that you just need to link with your own main and
* while the TEMPLATIZED code is define in make_genotype_real.h fitness code).
*
* It is instanciated in src/es/make_genotype_real.cpp - The corresponding ***INSTANCIATED DECLARATIONS*** are contained in
* and incorporated in the ga/libga.a src/es/make_real.h while the TEMPLATIZED code is define in
* make_genotype_real.h
* It returns an eoInit<EOT> that can later be used to initialize
* the population (see make_pop.h). It is instanciated in src/es/make_genotype_real.cpp - and incorporated
* in the ga/libga.a
* 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. It returns an eoInit<EOT> that can later be used to initialize the
* population (see make_pop.h).
* WARNING: that last argument will generally be the result of calling
* the default ctor of EOT, resulting in most cases in an EOT It uses a parser (to get user parameters) and a state (to store the
* that is ***not properly initialized*** 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***
*/ */
// the templatized code (same for real and es here) // the templatized code (same for real and es here)
#include <es/make_genotype_real.h> #include <es/make_genotype_real.h>
/// The following function merely call the templatized do_* functions /// The following function merely call the templatized do_* functions
eoRealInitBounded<eoEsSimple<double> >& make_genotype(eoParser& _parser,
eoRealInitBounded<eoEsSimple<double> > & make_genotype(eoParser& _parser, eoState& _state, eoEsSimple<double> _eo) eoState& _state,
eoEsSimple<double> _eo)
{ {
return do_make_genotype(_parser, _state, _eo); return do_make_genotype(_parser, _state, _eo);
}
eoRealInitBounded<eoEsSimple<eoMinimizingFitness> > & make_genotype(eoParser& _parser, eoState& _state, eoEsSimple<eoMinimizingFitness> _eo)
{
return do_make_genotype(_parser, _state, _eo);
} }
eoRealInitBounded<eoEsStdev<double> > & make_genotype(eoParser& _parser, eoState& _state, eoEsStdev<double> _eo)
eoRealInitBounded<eoEsSimple<eoMinimizingFitness> >& make_genotype(eoParser& _parser,
eoState& _state,
eoEsSimple<eoMinimizingFitness> _eo)
{ {
return do_make_genotype(_parser, _state, _eo); return do_make_genotype(_parser, _state, _eo);
}
eoRealInitBounded<eoEsStdev<eoMinimizingFitness> > & make_genotype(eoParser& _parser, eoState& _state, eoEsStdev<eoMinimizingFitness> _eo)
{
return do_make_genotype(_parser, _state, _eo);
} }
eoRealInitBounded<eoEsFull<double> > & make_genotype(eoParser& _parser, eoState& _state, eoEsFull<double> _eo)
eoRealInitBounded<eoEsStdev<double> >& make_genotype(eoParser& _parser,
eoState& _state,
eoEsStdev<double> _eo)
{ {
return do_make_genotype(_parser, _state, _eo); return do_make_genotype(_parser, _state, _eo);
}
eoRealInitBounded<eoEsFull<eoMinimizingFitness> > & make_genotype(eoParser& _parser, eoState& _state, eoEsFull<eoMinimizingFitness> _eo)
{
return do_make_genotype(_parser, _state, _eo);
} }
eoRealInitBounded<eoEsStdev<eoMinimizingFitness> >& make_genotype(eoParser& _parser,
eoState& _state,
eoEsStdev<eoMinimizingFitness> _eo)
{
return do_make_genotype(_parser, _state, _eo);
}
eoRealInitBounded<eoEsFull<double> > & make_genotype(eoParser& _parser,
eoState& _state,
eoEsFull<double> _eo)
{
return do_make_genotype(_parser, _state, _eo);
}
eoRealInitBounded<eoEsFull<eoMinimizingFitness> >& make_genotype(eoParser& _parser,
eoState& _state,
eoEsFull<eoMinimizingFitness> _eo)
{
return do_make_genotype(_parser, _state, _eo);
}
// Local Variables:
// coding: iso-8859-1
// c-file-style: "Stroustrup"
// comment-column: 35
// fill-column: 80
// End:

View file

@ -1,34 +1,32 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// make_genotype.h /** (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is free software; you can redistribute it and/or modify it under
but WITHOUT ANY WARRANTY; without even the implied warranty of the terms of the GNU Lesser General Public License as published by the Free
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Software Foundation; either version 2 of the License, or (at your option) any
Lesser General Public License for more details. later version.
You should have received a copy of the GNU Lesser General Public This library is distributed in the hope that it will be useful, but WITHOUT ANY
License along with this library; if not, write to the Free Software WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
Contact: todos@geneura.ugr.es, http://geneura.ugr.es You should have received a copy of the GNU Lesser General Public License along
Marc.Schoenauer@polytechnique.fr with this library; if not, write to the Free Software Foundation, Inc., 59
mkeijzer@dhi.dk Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//-----------------------------------------------------------------------------
#ifndef _make_genotype_h Contact: http://eodev.sourceforge.net
#define _make_genotype_h todos@geneura.ugr.es, http://geneura.ugr.es
Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/
#ifndef EO_make_genotype_h
#define EO_make_genotype_h
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <vector>
#include "es/eoReal.h" #include "es/eoReal.h"
#include "es/eoEsChromInit.h" #include "es/eoEsChromInit.h"
@ -37,34 +35,34 @@
#include "utils/eoState.h" #include "utils/eoState.h"
/* /** Initialize genotype
* This fuction does the initialization of what's needed for a particular
* genotype (here, std::vector<double> == eoReal).
* 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 src/es/make_genotyupe_real.cpp
* and incorporated in the src/es/libes.a
*
* It returns an eoInit<EOT> tha can later be used to initialize
* the population (see make_pop.h).
*
* 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***
*/
This fuction does the initialization of what's needed for a particular genotype
(here, std::vector<double> == eoReal). 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 src/es/make_genotyupe_real.cpp and incorporated in the
src/es/libes.a
It returns an eoInit<EOT> tha can later be used to initialize the population
(see make_pop.h).
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 <class EOT> template <class EOT>
eoEsChromInit<EOT> & do_make_genotype(eoParser& _parser, eoState& _state, EOT) eoEsChromInit<EOT> & do_make_genotype(eoParser& _parser, eoState& _state, EOT)
{ {
// the fitness type // the fitness type
typedef typename EOT::Fitness FitT; typedef typename EOT::Fitness FitT;
eoEsChromInit<EOT> *init;
// for eoReal, only thing needed is the size - but might have been created elswhere ... // for eoReal, only thing needed is the size - but might have been created elswhere ...
eoValueParam<unsigned>& vecSize eoValueParam<unsigned>& vecSize
@ -77,31 +75,56 @@ eoEsChromInit<EOT> & do_make_genotype(eoParser& _parser, eoState& _state, EOT)
"initBounds", "initBounds",
"Bounds for initialization (MUST be bounded)", "Bounds for initialization (MUST be bounded)",
'B', "Genotype Initialization"); 'B', "Genotype Initialization");
// now some initial value for sigmas - even if useless? // check if there is a vecSigmaInit
// shoudl be used in Normal mutation eoParam *vecSigmaParam = _parser.getParamWithLongName("vecSigmaInit");
std::string& sigmaString if(vecSigmaParam) {
= _parser.getORcreateParam(std::string("0.3"), "sigmaInit", eoValueParam<std::vector<double> >& vecSigmaParam
"Initial value for Sigmas (with a '%' -> scaled by the range of each variable)", = _parser.getORcreateParam(std::vector<double>(vecSize.value(), 0.3),
's',"Genotype Initialization").value(); "vecSigmaInit", "Initial value for Sigma(s)",
// check for % 'V',"Genotype Initialization");
bool to_scale = false; init = new eoEsChromInit<EOT>(boundsParam.value(), vecSigmaParam.value());
size_t pos = sigmaString.find('%'); } else {
if (pos < sigmaString.size()) // now some initial value for sigmas - even if useless?
{ // should be used in Normal mutation
// found a % - use scaling and get rid of '%' eoValueParam<std::string>& sigmaParam
to_scale = true; = _parser.getORcreateParam(std::string("0.3"), "sigmaInit",
sigmaString.resize(pos); "Initial value for Sigmas "
"(with '%' scaled by the range of each variable)",
's',"Genotype Initialization");
// check for %
bool to_scale = false;
size_t pos = sigmaParam.value().find('%');
if(pos < sigmaParam.value().size())
{
// found a % - use scaling and get rid of '%'
to_scale = true;
sigmaParam.value().resize(pos);
}
std::istringstream is(sigmaParam.value());
double sigma;
is >> sigma;
// minimum check
if(sigma < 0)
throw std::runtime_error("Negative sigma in make_genotype");
init = new eoEsChromInit<EOT>(boundsParam.value(), sigma, to_scale);
// define parameter
_parser.getORcreateParam(std::vector<double>(vecSize.value(), 0.3),
"vecSigmaInit", "Initial value for Sigma(s)",
'V',"Genotype Initialization");
} }
std::istringstream is(sigmaString);
double sigma;
is >> sigma;
// minimum check
if ( (sigma < 0) )
throw std::runtime_error("Negative sigma in make_genotype");
eoEsChromInit<EOT> * init = new eoEsChromInit<EOT>(boundsParam.value(), sigma, to_scale);
// store in state // store in state
_state.storeFunctor(init); _state.storeFunctor(init);
return *init; return *init;
} }
#endif #endif // EO_make_genotype_h
// Local Variables:
// coding: iso-8859-1
// mode:C++
// c-file-style: "Stroustrup"
// comment-column: 35
// fill-column: 80
// End:

View file

@ -1,31 +1,27 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- /* (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
//----------------------------------------------------------------------------- This library is free software; you can redistribute it and/or modify it under
// make_op.h - the real-valued version the terms of the GNU Lesser General Public License as published by the Free
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001 Software Foundation; either version 2 of the License, or (at your option) any
/* later version.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful, but WITHOUT ANY
but WITHOUT ANY WARRANTY; without even the implied warranty of WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public License along
License along with this library; if not, write to the Free Software with this library; if not, write to the Free Software Foundation, Inc., 59
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Temple Place, Suite 330, Boston, MA 02111-1307 USA
Contact: todos@geneura.ugr.es, http://geneura.ugr.es Contact: http://eodev.sourceforge.net
Marc.Schoenauer@polytechnique.fr todos@geneura.ugr.es, http://geneura.ugr.es
mkeijzer@dhi.dk Marc.Schoenauer@polytechnique.fr
mkeijzer@dhi.dk
*/ */
//-----------------------------------------------------------------------------
#ifndef _make_op_h
#define _make_op_h #ifndef EO_make_op_h
#define EO_make_op_h
// the operators // the operators
#include <eoOp.h> #include <eoOp.h>
@ -76,7 +72,10 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
// First, decide whether the objective variables are bounded // First, decide whether the objective variables are bounded
eoValueParam<eoRealVectorBounds>& boundsParam eoValueParam<eoRealVectorBounds>& boundsParam
= _parser.getORcreateParam(eoRealVectorBounds(vecSize,eoDummyRealNoBounds), = _parser.getORcreateParam(eoRealVectorBounds(vecSize,eoDummyRealNoBounds),
"objectBounds", "Bounds for variables", 'B', "Variation Operators"); "objectBounds", "Bounds for variables",
'B', "Variation Operators");
std::cerr << boundsParam.value() << std::endl;
// now we read Pcross and Pmut, // now we read Pcross and Pmut,
eoValueParam<std::string>& operatorParam eoValueParam<std::string>& operatorParam
@ -120,7 +119,8 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
'O', "Variation Operators"); 'O', "Variation Operators");
eoValueParam<std::string>& crossStdevParam eoValueParam<std::string>& crossStdevParam
= _parser.getORcreateParam(std::string("intermediate"), "crossStdev", = _parser.getORcreateParam(std::string("intermediate"), "crossStdev",
"Recombination of mutation strategy parameters (intermediate, discrete or none)", "Recombination of mutation strategy parameters "
"(intermediate, discrete or none)",
'S', "Variation Operators"); 'S', "Variation Operators");
// The pointers: first the atom Xover // The pointers: first the atom Xover
@ -171,7 +171,7 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
eoEsMutationInit mutateInit(_parser, "Variation Operators"); eoEsMutationInit mutateInit(_parser, "Variation Operators");
eoEsMutate<EOT> & mut = _state.storeFunctor( eoEsMutate<EOT> & mut = _state.storeFunctor(
new eoEsMutate<EOT>(mutateInit, boundsParam.value())); new eoEsMutate<EOT>(mutateInit, boundsParam.value()));
// now the general op - a sequential application of crossover and mutatation // now the general op - a sequential application of crossover and mutatation
// no need to first have crossover combined with a clone as it is an // no need to first have crossover combined with a clone as it is an
@ -184,4 +184,14 @@ eoGenOp<EOT> & do_make_op(eoParser& _parser, eoState& _state, eoRealInitBounded<
// that's it! // that's it!
return op; return op;
} }
#endif #endif // EO_make_op_h
// Local Variables:
// coding: iso-8859-1
// mode:C++
// c-file-style: "Stroustrup"
// comment-column: 35
// fill-column: 80
// End: