modification and correction of moShiftNeighbor
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/paradiseo/paradiseo
This commit is contained in:
commit
dea818c2b5
3 changed files with 34 additions and 62 deletions
|
|
@ -38,7 +38,7 @@ endif()
|
||||||
|
|
||||||
# enabled components
|
# enabled components
|
||||||
if ("${Paradiseo_FIND_COMPONENTS}" STREQUAL "")
|
if ("${Paradiseo_FIND_COMPONENTS}" STREQUAL "")
|
||||||
set(PARADISEO_LIBRARIES_TO_FIND eo eoutils edoutils cma es flowshop ga moeo)
|
set(PARADISEO_LIBRARIES_TO_FIND eo eoutils cma es flowshop ga moeo)
|
||||||
else()
|
else()
|
||||||
set(PARADISEO_LIBRARIES_TO_FIND ${Paradiseo_FIND_COMPONENTS})
|
set(PARADISEO_LIBRARIES_TO_FIND ${Paradiseo_FIND_COMPONENTS})
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -64,10 +64,6 @@ find_path(EO_INCLUDE_DIR eo
|
||||||
PATH_SUFFIXES include${INSTALL_SUB_DIR}/eo eo/src
|
PATH_SUFFIXES include${INSTALL_SUB_DIR}/eo eo/src
|
||||||
PATHS ${PARADISEO_SRC_PATHS})
|
PATHS ${PARADISEO_SRC_PATHS})
|
||||||
|
|
||||||
find_path(EDO_INCLUDE_DIR edo
|
|
||||||
PATH_SUFFIXES include${INSTALL_SUB_DIR}/edo edo/src
|
|
||||||
PATHS ${PARADISEO_SRC_PATHS})
|
|
||||||
|
|
||||||
find_path(MO_INCLUDE_DIR mo
|
find_path(MO_INCLUDE_DIR mo
|
||||||
PATH_SUFFIXES include${INSTALL_SUB_DIR}/mo mo/src
|
PATH_SUFFIXES include${INSTALL_SUB_DIR}/mo mo/src
|
||||||
PATHS ${PARADISEO_SRC_PATHS})
|
PATHS ${PARADISEO_SRC_PATHS})
|
||||||
|
|
@ -85,7 +81,12 @@ foreach(COMP ${PARADISEO_LIBRARIES_TO_FIND})
|
||||||
PATHS ${PARADISEO_SRC_PATHS})
|
PATHS ${PARADISEO_SRC_PATHS})
|
||||||
elseif(${COMP} STREQUAL "peo")
|
elseif(${COMP} STREQUAL "peo")
|
||||||
set(PEO_FOUND true)
|
set(PEO_FOUND true)
|
||||||
find_path(PEO_INCLUDE_DIR peo
|
find_path(EDO_INCLUDE_DIR edo
|
||||||
|
PATH_SUFFIXES include${INSTALL_SUB_DIR}/edo edo/src
|
||||||
|
PATHS ${PARADISEO_SRC_PATHS})
|
||||||
|
elseif(${COMP} STREQUAL "edo")
|
||||||
|
set(EDO_FOUND true)
|
||||||
|
find_path(EDO_INCLUDE_DIR peo
|
||||||
PATH_SUFFIXES include${INSTALL_SUB_DIR}/peo peo/src
|
PATH_SUFFIXES include${INSTALL_SUB_DIR}/peo peo/src
|
||||||
PATHS ${PARADISEO_SRC_PATHS})
|
PATHS ${PARADISEO_SRC_PATHS})
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,6 @@
|
||||||
#include <eoEvalCounterThrowException.h>
|
#include <eoEvalCounterThrowException.h>
|
||||||
#include <eoEvalTimeThrowException.h>
|
#include <eoEvalTimeThrowException.h>
|
||||||
#include <eoEvalUserTimeThrowException.h>
|
#include <eoEvalUserTimeThrowException.h>
|
||||||
#include <eoEvalKeepBest.h>
|
|
||||||
|
|
||||||
// Continuators - all include eoContinue.h
|
// Continuators - all include eoContinue.h
|
||||||
#include <eoCombinedContinue.h>
|
#include <eoCombinedContinue.h>
|
||||||
|
|
@ -103,7 +102,6 @@
|
||||||
#include <eoSharingSelect.h>
|
#include <eoSharingSelect.h>
|
||||||
// Embedding truncation selection
|
// Embedding truncation selection
|
||||||
#include <eoTruncatedSelectOne.h>
|
#include <eoTruncatedSelectOne.h>
|
||||||
#include <eoRankMuSelect.h>
|
|
||||||
|
|
||||||
// the batch selection - from an eoSelectOne
|
// the batch selection - from an eoSelectOne
|
||||||
#include <eoSelectPerc.h>
|
#include <eoSelectPerc.h>
|
||||||
|
|
@ -143,9 +141,6 @@
|
||||||
#include <utils/eoRealVectorBounds.h> // includes eoRealBounds.h
|
#include <utils/eoRealVectorBounds.h> // includes eoRealBounds.h
|
||||||
#include <utils/eoIntBounds.h> // no eoIntVectorBounds
|
#include <utils/eoIntBounds.h> // no eoIntVectorBounds
|
||||||
|
|
||||||
// Serialization stuff
|
|
||||||
#include <serial/eoSerial.h>
|
|
||||||
|
|
||||||
// aliens
|
// aliens
|
||||||
#include <other/external_eo>
|
#include <other/external_eo>
|
||||||
#include <eoCounter.h>
|
#include <eoCounter.h>
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@
|
||||||
#include <eoMergeReduce.h>
|
#include <eoMergeReduce.h>
|
||||||
#include <eoReplacement.h>
|
#include <eoReplacement.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class EOT> class eoIslandsEasyEA ;
|
template <class EOT> class eoIslandsEasyEA ;
|
||||||
|
|
||||||
template <class EOT> class eoDistEvalEasyEA ;
|
template <class EOT> class eoDistEvalEasyEA ;
|
||||||
|
|
@ -100,33 +102,6 @@ template<class EOT> class eoEasyEA: public eoAlgo<EOT>
|
||||||
offspring.reserve(_offspringSize); // This line avoids an incremental resize of offsprings.
|
offspring.reserve(_offspringSize); // This line avoids an incremental resize of offsprings.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Ctor allowing to specify which pop eval function we're going to use.
|
|
||||||
*
|
|
||||||
* Ctor taking a breed and merge, an overload of ctor to define an offspring size, and
|
|
||||||
* the pop eval function used. This allows to precise if we would like to use the
|
|
||||||
* parallel evaluation, for instance.
|
|
||||||
*/
|
|
||||||
eoEasyEA(
|
|
||||||
eoContinue<EOT>& _continuator,
|
|
||||||
eoEvalFunc<EOT>& _eval,
|
|
||||||
eoPopEvalFunc<EOT>& _pop_eval,
|
|
||||||
eoBreed<EOT>& _breed,
|
|
||||||
eoReplacement<EOT>& _replace,
|
|
||||||
unsigned _offspringSize
|
|
||||||
) : continuator(_continuator),
|
|
||||||
eval (_eval),
|
|
||||||
loopEval(_eval),
|
|
||||||
popEval(_pop_eval),
|
|
||||||
selectTransform(dummySelect, dummyTransform),
|
|
||||||
breed(_breed),
|
|
||||||
mergeReduce(dummyMerge, dummyReduce),
|
|
||||||
replace(_replace),
|
|
||||||
isFirstCall(true)
|
|
||||||
{
|
|
||||||
offspring.reserve(_offspringSize); // This line avoids an incremental resize of offsprings.
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
eoEasyEA(eoContinue <EOT> & _continuator,
|
eoEasyEA(eoContinue <EOT> & _continuator,
|
||||||
eoPopEvalFunc <EOT> & _pop_eval,
|
eoPopEvalFunc <EOT> & _pop_eval,
|
||||||
|
|
@ -244,44 +219,45 @@ template<class EOT> class eoEasyEA: public eoAlgo<EOT>
|
||||||
/// Apply a few generation of evolution to the population.
|
/// Apply a few generation of evolution to the population.
|
||||||
virtual void operator()(eoPop<EOT>& _pop)
|
virtual void operator()(eoPop<EOT>& _pop)
|
||||||
{
|
{
|
||||||
|
if (isFirstCall)
|
||||||
|
{
|
||||||
|
size_t total_capacity = _pop.capacity() + offspring.capacity();
|
||||||
|
_pop.reserve(total_capacity);
|
||||||
|
offspring.reserve(total_capacity);
|
||||||
|
isFirstCall = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (isFirstCall)
|
eoPop<EOT> empty_pop;
|
||||||
|
|
||||||
|
popEval(empty_pop, _pop); // A first eval of pop.
|
||||||
|
|
||||||
|
do
|
||||||
{
|
{
|
||||||
size_t total_capacity = _pop.capacity() + offspring.capacity();
|
try
|
||||||
_pop.reserve(total_capacity);
|
|
||||||
offspring.reserve(total_capacity);
|
|
||||||
isFirstCall = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
eoPop<EOT> empty_pop;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
unsigned pSize = _pop.size();
|
unsigned pSize = _pop.size();
|
||||||
|
offspring.clear(); // new offspring
|
||||||
|
|
||||||
offspring.clear(); // new offspring
|
breed(_pop, offspring);
|
||||||
|
|
||||||
breed(_pop, offspring);
|
popEval(_pop, offspring); // eval of parents + offspring if necessary
|
||||||
|
|
||||||
popEval(_pop, offspring); // eval of parents + offspring if necessary
|
replace(_pop, offspring); // after replace, the new pop. is in _pop
|
||||||
|
|
||||||
replace(_pop, offspring); // after replace, the new pop. is in _pop
|
if (pSize > _pop.size())
|
||||||
|
throw std::runtime_error("Population shrinking!");
|
||||||
|
else if (pSize < _pop.size())
|
||||||
|
throw std::runtime_error("Population growing!");
|
||||||
|
|
||||||
if (pSize > _pop.size())
|
|
||||||
throw std::runtime_error("Population shrinking!");
|
|
||||||
else if (pSize < _pop.size())
|
|
||||||
throw std::runtime_error("Population growing!");
|
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
std::string s = e.what();
|
std::string s = e.what();
|
||||||
s.append( " in eoEasyEA");
|
s.append( " in eoEasyEA");
|
||||||
throw std::runtime_error( s );
|
throw std::runtime_error( s );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ( continuator( _pop ) );
|
while ( continuator( _pop ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue