Added the includes ga.h and es.h
Removed the old eoEsObjectiveBounds and evolutionar_strategies from es dir
This commit is contained in:
parent
508a5b9215
commit
8d35fad136
9 changed files with 225 additions and 16 deletions
|
|
@ -4,12 +4,11 @@
|
|||
##
|
||||
###############################################################################
|
||||
|
||||
SUBDIRS = es ga utils other
|
||||
SUBDIRS = es ga gp utils other
|
||||
CPPFLAGS = -O2
|
||||
|
||||
lib_LIBRARIES = libeo.a
|
||||
libeo_a_SOURCES = eoPrintable.cpp eoPersistent.cpp eoFunctorStore.cpp
|
||||
|
||||
libeoincdir = $(includedir)/eo
|
||||
libeoinc_HEADERS = eo EO.h apply.h eoAlgo.h eoBackInserter.h eoBreed.h eoCombinedContinue.h eoContinue.h eoCounter.h eoDetTournamentSelect.h eoDetTournamentInserter.h eoEasyEA.h eoEvalFunc.h eoEvalFuncPtr.h eoEvolutionStrategy.h eoFactory.h eoFitContinue.h eoFixedLength.h eoFunctor.h eoFunctorStore.h eoGOpBreeder.h eoGOpSelector.h eoGenContinue.h eoIndiSelector.h eoInit.h eoInplaceTransform.h eoInserter.h eoMerge.h eoObject.h eoOp.h eoOpFactory.h eoOpSelMason.h eoOpSelector.h eoPersistent.h eoPop.h eoPrintable.h eoProportionalSelect.h eoProportionalGOpSel.h eoProportionalOpSel.h eoRandomSelect.h eoReduce.h eoReplacement.h eoSGA.h eoScalarFitness.h eoSelect.h eoSelectFactory.h eoSelectOne.h eoSelectPerc.h eoSequentialGOpSel.h eoSteadyStateEA.h eoSteadyStateInserter.h eoSteadyStateTransform.h eoStochTournamentSelect.h eoStochTournamentInserter.h eoTransform.h eoVariableLength.h eoWrappedOps.h
|
||||
|
||||
libeoinc_HEADERS = eo EO.h apply.h eoAlgo.h eoBackInserter.h eoBreed.h eoCombinedContinue.h eoContinue.h eoCounter.h eoDetSelect.h eoDetTournamentInserter.h eoDetTournamentSelect.h eoEasyEA.h eoEvalFunc.h eoEvalFuncPtr.h eoEvolutionStrategy.h eoFactory.h eoFitContinue.h eoFitnessScalingSelect.h eoFixedLength.h eoFunctor.h eoFunctorStore.h eoGOpBreeder.h eoGOpSelector.h eoGenContinue.h eoGenericBinOp.h eoGenericMonOp.h eoGenericQuadOp.h eoIndiSelector.h eoInit.h eoInplaceTransform.h eoInserter.h eoMerge.h eoMergeReduce.h eoObject.h eoOp.h eoOpFactory.h eoOpSelMason.h eoOpSelector.h eoPersistent.h eoPop.h eoPrintable.h eoProportionalCombinedOp.h eoProportionalGOpSel.h eoProportionalOpSel.h eoProportionalSelect.h eoQud2BinOp.h eoRandomSelect.h eoRankingSelect.h eoReduce.h eoReduceMerge.h eoReplacement.h eoSGA.h eoSGATransform.h eoScalarFitness.h eoSelect.h eoSelectFactory.h eoSelectMany.h eoSelectNumber.h eoSelectOne.h eoSelectPerc.h eoSequentialGOpSel.h eoSteadyFitContinue.h eoSteadyStateEA.h eoSteadyStateInserter.h eoSteadyStateTransform.h eoStochTournamentInserter.h eoStochTournamentSelect.h eoSurviveAndDie.h eoTransform.h eoVariableLength.h eoVariableLengthCrossover.h eoVariableLengthMutation.h eoWrappedOps.h es.h ga.h
|
||||
|
|
|
|||
65
eo/src/es.h
Normal file
65
eo/src/es.h
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// es.h
|
||||
// (c) GeNeura Team 1998 - Maarten Keijzer 2000 - Marc Schoenauer 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,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: Marc.Schoenauer@polytechnique.fr
|
||||
mak@dhi.dk
|
||||
todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// to avoid long name warnings
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
#ifndef _es_h
|
||||
#define _es_h
|
||||
|
||||
// contains the include specific to real representations, i.e. in src/es dir
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// the genotypes - from plain vector<double> to full correlated mutation
|
||||
#include <es/eoReal.h>
|
||||
#include <es/eoEsSimple.h>
|
||||
#include <es/eoEsStdev.h>
|
||||
#include <es/eoEsFull.h>
|
||||
|
||||
// the initialization
|
||||
#include <es/eoEsChromInit.h>
|
||||
|
||||
// general operators
|
||||
#include <es/eoRealOp.h>
|
||||
#include <es/eoNormalMutation.h>
|
||||
|
||||
// and their generic counterparts
|
||||
#include <es/eoGenericRealOp.h>
|
||||
|
||||
// the ES-mutations
|
||||
#include <es/eoEsMutationInit.h>
|
||||
#include <es/eoEsMutate.h>
|
||||
|
||||
// the crossover - to be continued
|
||||
#include <es/eoEsStdevXOver.h>
|
||||
|
||||
#endif _es_h
|
||||
|
||||
// Local Variables:
|
||||
// mode: C++
|
||||
// End:
|
||||
|
|
@ -5,7 +5,4 @@
|
|||
###############################################################################
|
||||
|
||||
libeoincdir = $(includedir)/eo/es
|
||||
libeoinc_HEADERS = evolution_strategies eoEsChromInit.h eoEsFull.h eoEsMutate.h eoEsMutationInit.h eoEsObjectiveBounds.h eoEsSimple.h eoEsStdev.h
|
||||
|
||||
|
||||
|
||||
libeoinc_HEADERS = eoEsChromInit.h eoEsFull.h eoEsMutate.h eoEsMutationInit.h eoEsSimple.h eoEsStdev.h eoEsStdevXOver.h eoGenericRealOp.h eoNormalMutation.h eoReal.h eoRealBounds.h eoRealOp.h
|
||||
|
|
|
|||
46
eo/src/ga.h
Normal file
46
eo/src/ga.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// ga.h
|
||||
// (c) GeNeura Team 1998 - 2000, Marc Schoenauer 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,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// to avoid long name warnings
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
#ifndef _ga_h
|
||||
#define _ga_h
|
||||
|
||||
// all bitstring-specific files
|
||||
#include <ga/eoBin.h>
|
||||
|
||||
// the operators
|
||||
#include <ga/eoBitOp.h>
|
||||
|
||||
// #include <ga/eoBitOpFactory.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#endif _ga_h
|
||||
|
||||
// Local Variables:
|
||||
// mode: C++
|
||||
// End:
|
||||
|
|
@ -10,4 +10,5 @@ lib_LIBRARIES = libeoobsolete.a
|
|||
libeoobsolete_a_SOURCES = eoParserUtils.cpp
|
||||
|
||||
libeoobsoleteincdir = $(includedir)/eo/obsolete
|
||||
libeoobsoleteinc_HEADERS = eoProblem.h eoParser.h eoParserUtils.h
|
||||
libeoobsoleteinc_HEADERS = eo1d.h eo1dWDistance.h eo2d.h eo2dVector.h eoAtomBitFlip.h eoAtomCreep.h eoAtomMutation.h eoAtomMutator.h eoAtomRandom.h eoBin.h eoBreeder.h eoCopyElite.h eoDetTournament.h eoDetTournamentIndiSelector.h eoDistance.h eoDup.h eoES.h eoESChrom.h eoESFullChrom.h eoESFullMut.h eoEsObjectiveBounds.h eoEvalFuncPtrCnt.h eoFitTerm.h eoFitness.h eoGenTerm.h eoGeneration.h eoID.h eoInclusion.h eoInsertion.h eoKill.h eoLottery.h eoMutation.h eoNegExp.h eoNonUniform.h eoNormal.h eoParser.h eoParserUtils.h eoPopOps.h eoProblem.h eoProportional.h eoRandomBreed.h eoRandomIndiSelector.h eoRandomSelect.h eoRank.h eoRnd.h eoScheme.h eoSelectRandom.h eoStochTournament.h eoStringMutation.h eoTerm.h eoTournament.h eoTranspose.h eoUniform.h eoUniformXOver.h eoVector.h eoXOver2.h
|
||||
|
||||
|
|
|
|||
81
eo/src/obsolete/eoEsObjectiveBounds.h
Normal file
81
eo/src/obsolete/eoEsObjectiveBounds.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// eoEsObjectiveBounds.h
|
||||
// (c) Maarten Keijzer 2000, GeNeura Team, 1998 - EEAAX 1999
|
||||
/*
|
||||
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,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
Marc.Schoenauer@polytechnique.fr
|
||||
mak@dhi.dk
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _eoEsObjectiveBounds_h
|
||||
#define _eoEsObjectiveBounds_h
|
||||
|
||||
/**
|
||||
\defgroup EvolutionStrategies
|
||||
|
||||
Various classes for the initialization and mutation of real valued vectors.
|
||||
|
||||
Supports simple mutations and various more adaptable mutations, including
|
||||
correlated mutations.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
\class eoEsObjectiveBounds eoEsObjectiveBounds.h es/eoEsObjectiveBounds.h
|
||||
\ingroup EvolutionStrategies
|
||||
|
||||
Defines the minima and maxima of the object variables. Needed by eoEsChromInit
|
||||
and eoEsMutate
|
||||
|
||||
@see eoEsChromInit eoEsMutate
|
||||
*/
|
||||
class eoEsObjectiveBounds
|
||||
{
|
||||
public :
|
||||
|
||||
/**
|
||||
Objective bounds for a global minimum and maximum
|
||||
*/
|
||||
eoEsObjectiveBounds(int _nGenes, double _min, double _max) : repMinimum(_nGenes), repMaximum(_nGenes)
|
||||
{
|
||||
std::fill(repMinimum.begin(), repMinimum.end(), _min);
|
||||
std::fill(repMaximum.begin(), repMaximum.end(), _max);
|
||||
}
|
||||
|
||||
/**
|
||||
Objective bounds for a per gene minimum and maximum
|
||||
*/
|
||||
eoEsObjectiveBounds(const std::vector<double>& _min, const std::vector<double>& _max)
|
||||
: repMinimum(_min), repMaximum(_max) {}
|
||||
|
||||
typedef double doubleype;
|
||||
|
||||
double minimum(size_t i) { return repMinimum[i]; }
|
||||
double maximum(size_t i) { return repMaximum[i]; }
|
||||
|
||||
unsigned chromSize(void) const { return repMinimum.size(); }
|
||||
|
||||
private :
|
||||
std::vector<double> repMinimum;
|
||||
std::vector<double> repMaximum;
|
||||
};
|
||||
|
||||
#endif
|
||||
15
eo/src/obsolete/evolution_strategies
Normal file
15
eo/src/obsolete/evolution_strategies
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef _eoEs_h
|
||||
#define _eoEs_h
|
||||
|
||||
#include <es/eoEsObjectiveBounds.h>
|
||||
#include <es/eoEsSimple.h>
|
||||
#include <es/eoEsStdev.h>
|
||||
#include <es/eoEsFull.h>
|
||||
|
||||
#include <es/eoEsChromInit.h>
|
||||
#include <es/eoEsMutationInit.h>
|
||||
|
||||
#include <es/eoEsMutate.h>
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -10,6 +10,7 @@ lib_LIBRARIES = libeoutils.a
|
|||
libeoutils_a_SOURCES = eoParser.cpp eoRNG.cpp eoState.cpp eoUpdater.cpp eoFileMonitor.cpp eoStdoutMonitor.cpp
|
||||
|
||||
libeoincdir = $(includedir)/eo/utils
|
||||
libeoinc_HEADERS = compatibility.h eoParam.h eoRNG.h rnd_generators.h eoData.h eoParser.h eoState.h selectors.h eoStat.h eoMonitor.h eoFileMonitor.h eoUpdater.h checkpointing eoCheckPoint.h eoStdoutMonitor.h eoGnuplot1DMonitor.h
|
||||
libeoinc_HEADERS = compatibility.h eoCheckPoint.h eoData.h eoDistance.h eoFileMonitor.h eoGnuplot1DMonitor.h eoHowMany.h eoMonitor.h eoParam.h eoParser.h eoRNG.h eoStat.h eoState.h eoStdoutMonitor.h eoUpdatable.h eoUpdater.h rnd_generators.h selectors.h
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ using namespace std;
|
|||
#include <eo>
|
||||
|
||||
// representation specific
|
||||
#include <es/evolution_strategies>
|
||||
#include <es.h>
|
||||
|
||||
#include "real_value.h" // the sphere fitness
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ using namespace std;
|
|||
typedef eoMinimizingFitness FitT;
|
||||
|
||||
template <class EOT>
|
||||
void runAlgorithm(EOT, eoParser& _parser, eoState& _state, eoEsObjectiveBounds& _bounds, eoValueParam<string> _load_name);
|
||||
void runAlgorithm(EOT, eoParser& _parser, eoState& _state, eoRealVectorBounds& _bounds, eoValueParam<string> _load_name);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
|
@ -39,8 +39,8 @@ int main(int argc, char *argv[])
|
|||
eoValueParam<bool>& stdevs = parser.createParam(false, "Stdev", "Use adaptive mutation rates", 's');
|
||||
eoValueParam<bool>& corr = parser.createParam(false, "Correl", "Use correlated mutations", 'c');
|
||||
eoValueParam<unsigned>& chromSize = parser.createParam(unsigned(50), "ChromSize", "Number of chromosomes", 'n');
|
||||
eoValueParam<double>& minimum = parser.createParam(-1.e5, "Min", "Minimum for Objective Variables", 'l');
|
||||
eoValueParam<double>& maximum = parser.createParam(1.e5, "Max", "Maximum for Objective Variables", 'h');
|
||||
eoValueParam<double>& minimum = parser.createParam(-1.0, "Min", "Minimum for Objective Variables", 'l');
|
||||
eoValueParam<double>& maximum = parser.createParam(1.0, "Max", "Maximum for Objective Variables", 'h');
|
||||
|
||||
eoState state;
|
||||
state.registerObject(parser);
|
||||
|
|
@ -56,7 +56,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
state.registerObject(rng);
|
||||
|
||||
eoEsObjectiveBounds bounds(chromSize.value(), minimum.value(), maximum.value());
|
||||
eoRealVectorBounds bounds(chromSize.value(), minimum.value(), maximum.value());
|
||||
|
||||
// Run the appropriate algorithm
|
||||
if (stdevs.value() == false && corr.value() == false)
|
||||
|
|
@ -84,7 +84,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
template <class EOT>
|
||||
void runAlgorithm(EOT, eoParser& _parser, eoState& _state, eoEsObjectiveBounds& _bounds, eoValueParam<string> _load_name)
|
||||
void runAlgorithm(EOT, eoParser& _parser, eoState& _state, eoRealVectorBounds& _bounds, eoValueParam<string> _load_name)
|
||||
{
|
||||
// evaluation
|
||||
eoEvalFuncPtr<EOT, double, const vector<double>&> eval( real_value );
|
||||
|
|
@ -128,7 +128,7 @@ void runAlgorithm(EOT, eoParser& _parser, eoState& _state, eoEsObjectiveBounds&
|
|||
|
||||
monitor.add(average);
|
||||
|
||||
eoGenContinue<EOT> cnt(20);
|
||||
eoGenContinue<EOT> cnt(100);
|
||||
eoCheckPoint<EOT> checkpoint(cnt);
|
||||
checkpoint.add(monitor);
|
||||
checkpoint.add(average);
|
||||
|
|
@ -140,4 +140,8 @@ void runAlgorithm(EOT, eoParser& _parser, eoState& _state, eoEsObjectiveBounds&
|
|||
eoEvolutionStrategy<EOT> es(checkpoint, eval, opSel, lambda_rate.value(), eoEvolutionStrategy<EOT>::comma_strategy());
|
||||
|
||||
es(pop);
|
||||
|
||||
pop.sort();
|
||||
cout << "Final population\n" << pop << endl;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue