From bf3e41527107cf0d828cf2a133e11de5977b2266 Mon Sep 17 00:00:00 2001 From: canape Date: Tue, 22 Jan 2013 10:59:53 +0100 Subject: [PATCH 1/2] corrected Find --- cmake/module/FindParadiseo.cmake | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cmake/module/FindParadiseo.cmake b/cmake/module/FindParadiseo.cmake index 0f476e092..59b85a864 100644 --- a/cmake/module/FindParadiseo.cmake +++ b/cmake/module/FindParadiseo.cmake @@ -38,7 +38,7 @@ endif() # enabled components 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() set(PARADISEO_LIBRARIES_TO_FIND ${Paradiseo_FIND_COMPONENTS}) endif() @@ -64,10 +64,6 @@ find_path(EO_INCLUDE_DIR eo PATH_SUFFIXES include${INSTALL_SUB_DIR}/eo eo/src 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 PATH_SUFFIXES include${INSTALL_SUB_DIR}/mo mo/src PATHS ${PARADISEO_SRC_PATHS}) @@ -85,7 +81,12 @@ foreach(COMP ${PARADISEO_LIBRARIES_TO_FIND}) PATHS ${PARADISEO_SRC_PATHS}) elseif(${COMP} STREQUAL "peo") 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 PATHS ${PARADISEO_SRC_PATHS}) endif() From 386fc1d56a7e62cde9df9467e4baa27cf1889f86 Mon Sep 17 00:00:00 2001 From: canape Date: Thu, 7 Feb 2013 09:31:33 +0100 Subject: [PATCH 2/2] To fix a "bug" in smp --- eo/src/eo | 5 --- eo/src/eoEasyEA.h | 82 +++++++++++++++++------------------------------ 2 files changed, 29 insertions(+), 58 deletions(-) diff --git a/eo/src/eo b/eo/src/eo index b87ca57f1..8cebd23a0 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -78,7 +78,6 @@ #include #include #include -#include // Continuators - all include eoContinue.h #include @@ -103,7 +102,6 @@ #include // Embedding truncation selection #include -#include // the batch selection - from an eoSelectOne #include @@ -143,9 +141,6 @@ #include // includes eoRealBounds.h #include // no eoIntVectorBounds -// Serialization stuff -#include - // aliens #include #include diff --git a/eo/src/eoEasyEA.h b/eo/src/eoEasyEA.h index 4d9c7b6da..2c7c5474c 100644 --- a/eo/src/eoEasyEA.h +++ b/eo/src/eoEasyEA.h @@ -37,6 +37,8 @@ #include #include + + template class eoIslandsEasyEA ; template class eoDistEvalEasyEA ; @@ -100,33 +102,6 @@ template class eoEasyEA: public eoAlgo 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& _continuator, - eoEvalFunc& _eval, - eoPopEvalFunc& _pop_eval, - eoBreed& _breed, - eoReplacement& _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 & _continuator, eoPopEvalFunc & _pop_eval, @@ -244,44 +219,45 @@ template class eoEasyEA: public eoAlgo /// Apply a few generation of evolution to the population. virtual void operator()(eoPop& _pop) { + if (isFirstCall) + { + size_t total_capacity = _pop.capacity() + offspring.capacity(); + _pop.reserve(total_capacity); + offspring.reserve(total_capacity); + isFirstCall = false; + } - if (isFirstCall) + eoPop empty_pop; + + popEval(empty_pop, _pop); // A first eval of pop. + + do { - size_t total_capacity = _pop.capacity() + offspring.capacity(); - _pop.reserve(total_capacity); - offspring.reserve(total_capacity); - isFirstCall = false; - } - - eoPop empty_pop; - - do - { - try + 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(); - s.append( " in eoEasyEA"); - throw std::runtime_error( s ); + std::string s = e.what(); + s.append( " in eoEasyEA"); + throw std::runtime_error( s ); } } - while ( continuator( _pop ) ); + while ( continuator( _pop ) ); } protected :