From bf3e41527107cf0d828cf2a133e11de5977b2266 Mon Sep 17 00:00:00 2001 From: canape Date: Tue, 22 Jan 2013 10:59:53 +0100 Subject: [PATCH 01/17] 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 3e78afdd59dc04d1cee35c78cfa5915209316184 Mon Sep 17 00:00:00 2001 From: verel Date: Wed, 6 Feb 2013 12:08:15 +0100 Subject: [PATCH 02/17] Modify incremental eval QAP --- mo/src/problems/eval/moQAPIncrEval.h | 6 +++--- .../problems/permutation/moIndexedSwapNeighbor.h | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/mo/src/problems/eval/moQAPIncrEval.h b/mo/src/problems/eval/moQAPIncrEval.h index 3fd529a7f..5c47623d9 100644 --- a/mo/src/problems/eval/moQAPIncrEval.h +++ b/mo/src/problems/eval/moQAPIncrEval.h @@ -61,10 +61,10 @@ public: int d; int k; - unsigned i, j; - - _neighbor.getIndices(n, i, j); + unsigned i = _neighbor.first(); + unsigned j = _neighbor.second(); + // _neighbor.getIndices(n, i, j); d = (A[i][i]-A[j][j])*(B[_solution[j]][_solution[j]]-B[_solution[i]][_solution[i]]) + (A[i][j]-A[j][i])*(B[_solution[j]][_solution[i]]-B[_solution[i]][_solution[j]]); diff --git a/mo/src/problems/permutation/moIndexedSwapNeighbor.h b/mo/src/problems/permutation/moIndexedSwapNeighbor.h index 06491f134..d30305100 100644 --- a/mo/src/problems/permutation/moIndexedSwapNeighbor.h +++ b/mo/src/problems/permutation/moIndexedSwapNeighbor.h @@ -107,6 +107,22 @@ public: index( _first + n * (n - 1) / 2 ); } + /** + * Getter of the firt location + * @return first indice + */ + unsigned int first() { + return indices.first; + } + + /** + * Getter of the second location + * @return second indice + */ + unsigned int second() { + return indices.second; + } + private: std::pair indices; From fd4e20d54d83599fa6c732efa0e4d3dea5890d9f Mon Sep 17 00:00:00 2001 From: verel Date: Wed, 6 Feb 2013 14:30:42 +0100 Subject: [PATCH 03/17] changed the moMonOpPerturb --- mo/src/perturb/moMonOpPerturb.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/mo/src/perturb/moMonOpPerturb.h b/mo/src/perturb/moMonOpPerturb.h index c056bbf6a..93421f321 100644 --- a/mo/src/perturb/moMonOpPerturb.h +++ b/mo/src/perturb/moMonOpPerturb.h @@ -48,8 +48,9 @@ public: * Constructor * @param _monOp an eoMonOp (pertubation operator) * @param _fullEval a full evaluation function + * @param _nbPertubation number of operator execution for perturbation */ - moMonOpPerturb(eoMonOp& _monOp, eoEvalFunc& _fullEval):monOp(_monOp), fullEval(_fullEval) {} + moMonOpPerturb(eoMonOp& _monOp, eoEvalFunc& _fullEval, unsigned int _nbPertubation = 1):monOp(_monOp), fullEval(_fullEval), nbPertubation(_nbPertubation) {} /** * Apply monOp on the solution @@ -57,16 +58,22 @@ public: * @return value of monOp */ bool operator()(EOT& _solution) { - bool res = monOp(_solution); - _solution.invalidate(); - fullEval(_solution); - return res; + bool res = false; + + for(unsigned int i = 0; i < nbPerturbation; i++) + res = res || monOp(_solution); + + _solution.invalidate(); + fullEval(_solution); + + return res; } private: - /** monOp */ - eoMonOp& monOp; - eoEvalFunc& fullEval; + /** monOp */ + eoMonOp& monOp; + eoEvalFunc& fullEval; + unsigned int nbPertubation; }; #endif From 12ee2c54715d2c8a3c8b2ca9cb7040952a497cf4 Mon Sep 17 00:00:00 2001 From: verel Date: Wed, 6 Feb 2013 14:35:32 +0100 Subject: [PATCH 04/17] changed the moMonOpPerturb --- mo/src/perturb/moMonOpPerturb.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mo/src/perturb/moMonOpPerturb.h b/mo/src/perturb/moMonOpPerturb.h index 93421f321..a4bcea574 100644 --- a/mo/src/perturb/moMonOpPerturb.h +++ b/mo/src/perturb/moMonOpPerturb.h @@ -48,9 +48,9 @@ public: * Constructor * @param _monOp an eoMonOp (pertubation operator) * @param _fullEval a full evaluation function - * @param _nbPertubation number of operator execution for perturbation + * @param _nbPerturbation number of operator executions for perturbation */ - moMonOpPerturb(eoMonOp& _monOp, eoEvalFunc& _fullEval, unsigned int _nbPertubation = 1):monOp(_monOp), fullEval(_fullEval), nbPertubation(_nbPertubation) {} + moMonOpPerturb(eoMonOp& _monOp, eoEvalFunc& _fullEval, unsigned int _nbPerturbation = 1):monOp(_monOp), fullEval(_fullEval), nbPerturbation(_nbPerturbation) {} /** * Apply monOp on the solution @@ -73,7 +73,7 @@ private: /** monOp */ eoMonOp& monOp; eoEvalFunc& fullEval; - unsigned int nbPertubation; + unsigned int nbPerturbation; }; #endif From 386fc1d56a7e62cde9df9467e4baa27cf1889f86 Mon Sep 17 00:00:00 2001 From: canape Date: Thu, 7 Feb 2013 09:31:33 +0100 Subject: [PATCH 05/17] 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 : From 1ef2a89dbf8fde372b774495778185cdaaf3c92b Mon Sep 17 00:00:00 2001 From: verel Date: Thu, 7 Feb 2013 12:05:54 +0100 Subject: [PATCH 06/17] changed the moShiftNeighor --- mo/src/problems/permutation/moShiftNeighbor.h | 244 ++++++++++++------ 1 file changed, 158 insertions(+), 86 deletions(-) diff --git a/mo/src/problems/permutation/moShiftNeighbor.h b/mo/src/problems/permutation/moShiftNeighbor.h index 88d48301d..fa7a2176f 100644 --- a/mo/src/problems/permutation/moShiftNeighbor.h +++ b/mo/src/problems/permutation/moShiftNeighbor.h @@ -1,114 +1,186 @@ /* - -Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 + + Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010 -Sébastien Verel, Arnaud Liefooghe, Jérémie Humeau + Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau -This software is governed by the CeCILL license under French law and -abiding by the rules of distribution of free software. You can ue, -modify and/ or redistribute the software under the terms of the CeCILL -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". + This software is governed by the CeCILL license under French law and + abiding by the rules of distribution of free software. You can ue, + modify and/ or redistribute the software under the terms of the CeCILL + license as circulated by CEA, CNRS and INRIA at the following URL + "http://www.cecill.info". -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. -The fact that you are presently reading this means that you have had -knowledge of the CeCILL license and that you accept its terms. + In this respect, the user's attention is drawn to the risks associated + with loading, using, modifying and/or developing or reproducing the + software by the user in light of its specific status of free software, + that may mean that it is complicated to manipulate, and that also + therefore means that it is reserved for developers and experienced + professionals having in-depth computer knowledge. Users are therefore + encouraged to load and test the software's suitability as regards their + requirements in conditions enabling the security of their systems and/or + data to be ensured and, more generally, to use and operate it in the + same conditions as regards security. + The fact that you are presently reading this means that you have had + knowledge of the CeCILL license and that you accept its terms. -ParadisEO WebSite : http://paradiseo.gforge.inria.fr -Contact: paradiseo-help@lists.gforge.inria.fr + ParadisEO WebSite : http://paradiseo.gforge.inria.fr + Contact: paradiseo-help@lists.gforge.inria.fr */ #ifndef _moShiftNeighbor_h #define _moShiftNeighbor_h +#include #include /** * Indexed Shift Neighbor + * Other name : insertion operator */ template -class moShiftNeighbor: public moIndexNeighbor +class moShiftNeighbor: public moBackableNeighbor, public moIndexNeighbor { public: - using moIndexNeighbor::key; + using moBackableNeighbor::fitness; + using moIndexNeighbor::key; + using moIndexNeighbor::index; + + /** + * Apply move on a solution regarding a key + * @param _solution the solution to move + */ + virtual void move(EOT & _solution) { + insertion(_solution, indices.first, indices.second); - /** - * Apply move on a solution regarding a key - * @param _sol the solution to move - */ - virtual void move(EOT & _sol) { - unsigned int tmp ; - size=_sol.size(); - translate(key+1); - // keep the first component to change - tmp = _sol[first]; - // shift - if (first < second) { - for (unsigned int i=first; i second*/ - for (unsigned int i=first; i>second; i--) - _sol[i] = _sol[i-1]; - // shift the first component - _sol[second] = tmp; - } - _sol.invalidate(); - } + _sol.invalidate(); + } - /** - * fix two indexes regarding a key - * @param _key the key allowing to compute the two indexes for the shift - */ - void translate(unsigned int _key) { - int step; - int val = _key; - int tmpSize = size * (size-1) / 2; - // moves from left to right - if (val <= tmpSize) { - step = size - 1; - first = 0; - while ((val - step) > 0) { - val = val - step; - step--; - first++; - } - second = first + val + 1; - } - // moves from right to left (equivalent moves are avoided) - else { /* val > tmpSize */ - val = val - tmpSize; - step = size - 2; - second = 0; - while ((val - step) > 0) { - val = val - step; - step--; - second++; - } - first = second + val + 1; - } - } + /** + * apply the correct insertion to restore the solution (use by moFullEvalByModif) + * @param _solution the solution to move back + */ + virtual void moveBack(EOT& _solution) { + if (indices.first < indices.second) + insertion(_solution, indices.second - 1, indices.first); + else + insertion(_solution, indices.second, indices.first + 1); + } - void print() { - std::cout << key << ": [" << first << ", " << second << "] -> " << (*this).fitness() << std::endl; + /** + * Setter + * The "parameters" of the neighbor is a function of key and the current solution + * for example, for variable length solution + * + * @param _solution solution from which the neighborhood is visited + * @param _key index of the IndexNeighbor + */ + virtual void index(EOT & _solution, unsigned int _key) { + index( _key ); + + indices.first = _key % _solution.size() ; + indices.second = _key / _solution.size() ; + + if (indices.first <= indices.second) + indices.second += 2; + + // =============== To kill : + // int step; + // int val = _key; + // int tmpSize = _solution.size() * (_solution.size() - 1) / 2; + + // // moves from left to right + // if (val <= tmpSize) { + // step = _solution.size() - 1; + // indices.first = 0; + // while ((val - step) > 0) { + // val = val - step; + // step--; + // indices.first++; + // } + // indices.second = indices.first + val + 1; + // } + // // moves from right to left (equivalent moves are avoided) + // else { /* val > tmpSize */ + // val = val - tmpSize; + // step = _solution.size() - 2; + // indices.second = 0; + // while ((val - step) > 0) { + // val = val - step; + // step--; + // indices.second++; + // } + // indices.first = indices.second + val + 1; + // } + } + + /** + * Setter to fix the two indexes to swap + * @param _solution solution from which the neighborhood is visited + * @param _first first index + * @param _second second index + */ + void set(EOT & _solution, unsigned int _first, unsigned int _second) { + indices.first = _first; + indices.second = _second; + + // set the index + if (_first < _second) { + index( (_second - 2) * _solution.size() + _first ); + } else { + index( _second * _solution.size() + _first ); } + } + + /** + * Getter of the firt location + * @return first indice + */ + unsigned int first() { + return indices.first; + } + + /** + * Getter of the second location + * @return second indice + */ + unsigned int second() { + return indices.second; + } + + void print() { + std::cout << key << ": [" << indices.first << ", " << indices.second << "] -> " << (*this).fitness() << std::endl; + } private: - unsigned int first; - unsigned int second; - unsigned int size; + std::pair indices; + + /** + * Apply insertion move on a solution regarding a key + * @param _sol the solution to move + * @param _first first position + * @param _second second position + */ + void insertion(EOT & _sol, unsigned int _first, unsigned int _second) { + unsigned int tmp ; + + // keep the first component to change + tmp = _sol[_first]; + // shift + if (_first < _second) { + for (unsigned int i = _first; i < _second - 1; i++) + _sol[i] = _sol[i+1]; + // shift the first component + _sol[_second-1] = tmp; + } + else { /* first > second*/ + for (unsigned int i = _first; i > _second; i--) + _sol[i] = _sol[i-1]; + // shift the first component + _sol[_second] = tmp; + } + } + }; From 23df679f51cc90ac84b15fa422ecb7cca558ae06 Mon Sep 17 00:00:00 2001 From: canape Date: Thu, 7 Feb 2013 14:43:11 +0100 Subject: [PATCH 07/17] some modifications for EDO You have to sove this problems: EDO: t-dispatcher-round (commented) MOOE: Lesson4 (commented) MO: t-moRndIndexedVectorTabuList (commented) --- CMakeLists.txt | 3 +- cmake/module/FindEigen3.cmake | 39 ++++++++++++++ edo/CMakeLists.txt | 52 ++++++++----------- edo/application/CMakeLists.txt | 15 ++++-- edo/application/eda/CMakeLists.txt | 2 +- edo/test/CMakeLists.txt | 12 ++--- eo/src/eo | 1 + eo/src/eoEvalFuncCounterBounder.h | 2 +- mo/src/problems/permutation/moShiftNeighbor.h | 2 +- mo/test/CMakeLists.txt | 2 +- moeo/tutorial/CMakeLists.txt | 2 +- 11 files changed, 83 insertions(+), 49 deletions(-) create mode 100644 cmake/module/FindEigen3.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 62541cd3c..1d6ba989d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ enable_language(CXX) ## Test the presence of a compiler if("${CMAKE_CXX_COMPILER}" STREQUAL "" OR "${CMAKE_C_COMPILER}" STREQUAL "") - message(FATAL_ERROR "No compiler found !") + message(FATAL_ERROR "No compiler found!") endif() ## Versioning @@ -35,6 +35,7 @@ SET(GLOBAL_VERSION "${VERSION}") ###################################################################################### ## Optional +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/module" CACHE INTERNAL "Cmake module" FORCE) include(FindDoxygen OPTIONAL) ###################################################################################### diff --git a/cmake/module/FindEigen3.cmake b/cmake/module/FindEigen3.cmake new file mode 100644 index 000000000..dda45e662 --- /dev/null +++ b/cmake/module/FindEigen3.cmake @@ -0,0 +1,39 @@ +macro(_eigen3_check_version) + file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header) + + string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}") + set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}") + string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}") + set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}") + string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}") + set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}") + set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION}) + set(EIGEN3_VERSION_OK TRUE) +endmacro(_eigen3_check_version) + +if (EIGEN3_INCLUDE_DIR) + + _eigen3_check_version( ) + set(EIGEN3_FOUND ${EIGEN3_VERSION_OK}) + +else (EIGEN3_INCLUDE_DIR) + + find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library + PATHS + ${PROJECT_SOURCE_DIR}/External + ${CMAKE_INSTALL_PREFIX}/include + ${KDE4_INCLUDE_DIR} + PATH_SUFFIXES eigen3 eigen + ) + + if(EIGEN3_INCLUDE_DIR) + _eigen3_check_version( ) + endif(EIGEN3_INCLUDE_DIR) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK) + + mark_as_advanced(EIGEN3_INCLUDE_DIR) + +endif(EIGEN3_INCLUDE_DIR) + diff --git a/edo/CMakeLists.txt b/edo/CMakeLists.txt index 8bb80abc8..41a6b476e 100644 --- a/edo/CMakeLists.txt +++ b/edo/CMakeLists.txt @@ -1,33 +1,25 @@ -IF(EDO_USE_LIB STREQUAL "uBLAS") - FIND_PACKAGE(Boost ) - IF( Boost_FOUND ) - INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIRS} ) - ADD_DEFINITIONS( -DWITH_BOOST ) - ELSE() - MESSAGE( "ERROR: You asked for Boost::uBLAS but it has not been found." ) - SET(IS_FATAL 1) - ENDIF() -ELSEIF( EDO_USE_LIB STREQUAL "Eigen3" ) - # FIXME FindEigen3.cmake does not work - #find_package(Eigen3) - #include_directories(EIGEN3_INCLUDE_DIR) - SET( EIGEN3_FOUND 1) - SET( EIGEN3_INCLUDE_DIR "/usr/include/eigen3/" ) +if(EDO_USE_LIB STREQUAL "uBLAS") + find_package(Boost) + if(Boost_FOUND) + include_directories( ${Boost_INCLUDE_DIRS} ) + add_definitions( -DWITH_BOOST ) + else() + message(FATAL_ERROR "\n\nERROR: You asked for Boost::uBLAS but it has not been found.\n" ) + endif() +elseif(EDO_USE_LIB STREQUAL "Eigen3") + find_package(Eigen3) + if(EIGEN3_FOUND) + include_directories(EIGEN3_INCLUDE_DIR) + add_definitions( -DWITH_EIGEN ) + else() + message(FATAL_ERROR "\n\nERROR: You asked for Eigen3 but it has not been found.\n" ) + endif() - IF( EIGEN3_FOUND ) - INCLUDE_DIRECTORIES( ${EIGEN3_INCLUDE_DIR} ) - ADD_DEFINITIONS( -DWITH_EIGEN ) - ELSE() - MESSAGE( "ERROR: You asked for Eigen3 but it has not been found." ) - SET(IS_FATAL 1) - ENDIF() - -ELSE() +else() # FIXME ideally, we would have a minimal implementation with STL vectors… - MESSAGE( "You must set EDO_USE_LIB to either 'uBLAS' or 'Eigen3'." ) - SET(IS_FATAL 1) -ENDIF() + message(FATAL_ERROR "\n\nYou must set EDO_USE_LIB to either 'uBLAS' or 'Eigen3'.\n" ) +endif() ###################################################################################### @@ -37,14 +29,14 @@ ENDIF() add_subdirectory(doc) add_subdirectory(src) -if(ENABLE_CMAKE_TESTING) +if(ENABLE_CMAKE_TESTING AND EIGEN3_FOUND) # see edoNormalAdaptive add_subdirectory(test) -endif(ENABLE_CMAKE_TESTING) +endif() if(ENABLE_CMAKE_EXAMPLE) if(${CMAKE_VERBOSE_MAKEFILE}) message("EDO examples:") endif(${CMAKE_VERBOSE_MAKEFILE}) add_subdirectory(application) -endif(ENABLE_CMAKE_EXAMPLE) +endif() diff --git a/edo/application/CMakeLists.txt b/edo/application/CMakeLists.txt index 88462c0a7..4b871f042 100644 --- a/edo/application/CMakeLists.txt +++ b/edo/application/CMakeLists.txt @@ -2,13 +2,18 @@ ### 1) Where do we go now ?!? ###################################################################################### -INCLUDE_DIRECTORIES( +include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/common ) -ADD_SUBDIRECTORY(common) # Rosenbrock and Sphere -#ADD_SUBDIRECTORY(eda_sa) -ADD_SUBDIRECTORY(eda) -ADD_SUBDIRECTORY(cmaes) +include_directories(${EIGEN3_INCLUDE_DIR}) + +add_subdirectory(common) # Rosenbrock and Sphere +#add_subdirectory(eda_sa) + +if(EIGEN3_FOUND) # see edoNormalAdaptive + add_subdirectory(eda) + add_subdirectory(cmaes) +endif() ###################################################################################### diff --git a/edo/application/eda/CMakeLists.txt b/edo/application/eda/CMakeLists.txt index 9966cb6f8..fe1ee606f 100644 --- a/edo/application/eda/CMakeLists.txt +++ b/edo/application/eda/CMakeLists.txt @@ -8,8 +8,8 @@ include_directories(${Boost_INCLUDE_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) include_directories(${EO_SRC_DIR}/src) -include_directories(${EDO_SRC_DIR}/src) link_directories(${EO_BIN_DIR}/${LIB}) +include_directories(${EDO_SRC_DIR}/src) link_directories(${EDO_BIN_DIR}/${LIB}) set(RESOURCES diff --git a/edo/test/CMakeLists.txt b/edo/test/CMakeLists.txt index 0d98852fe..5ab7eb21b 100644 --- a/edo/test/CMakeLists.txt +++ b/edo/test/CMakeLists.txt @@ -23,17 +23,13 @@ ### 3) Define your targets and link the librairies ###################################################################################### -find_package(Boost 1.33.0) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - -include_directories(${Boost_INCLUDE_DIRS}) -link_directories(${Boost_LIBRARY_DIRS}) - include_directories(${CMAKE_SOURCE_DIR}/application/common) include_directories(${EO_SRC_DIR}/src) include_directories(${EDO_SRC_DIR}/src) +include_directories(${EIGEN3_INCLUDE_DIR}) + set(SOURCES #t-cholesky t-variance @@ -42,14 +38,14 @@ set(SOURCES t-bounderno t-uniform t-continue - t-dispatcher-round +# t-dispatcher-round t-repairer-modulo ) foreach(current ${SOURCES}) add_executable(${current} ${current}.cpp) add_test(${current} ${current}) - target_link_libraries(${current} eo eoutils edoutils ${Boost_LIBRARIES}) + target_link_libraries(${current} eo eoutils edoutils) install(TARGETS ${current} RUNTIME DESTINATION share/edo/test COMPONENT test) endforeach() diff --git a/eo/src/eo b/eo/src/eo index 8cebd23a0..8196e2b14 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -113,6 +113,7 @@ // DetSelect can also be obtained as eoSequentialSelect, an eoSelectOne // (using setup and an index) #include +#include // Breeders #include // applies one eoGenOp, stop on offspring count diff --git a/eo/src/eoEvalFuncCounterBounder.h b/eo/src/eoEvalFuncCounterBounder.h index 1c8a29b15..7114e7f37 100644 --- a/eo/src/eoEvalFuncCounterBounder.h +++ b/eo/src/eoEvalFuncCounterBounder.h @@ -55,7 +55,7 @@ public : throw eoEvalFuncCounterBounderException(_threshold); } - func(eo); + this->func(eo); } } diff --git a/mo/src/problems/permutation/moShiftNeighbor.h b/mo/src/problems/permutation/moShiftNeighbor.h index fa7a2176f..e8884f687 100644 --- a/mo/src/problems/permutation/moShiftNeighbor.h +++ b/mo/src/problems/permutation/moShiftNeighbor.h @@ -53,7 +53,7 @@ public: virtual void move(EOT & _solution) { insertion(_solution, indices.first, indices.second); - _sol.invalidate(); + _solution.invalidate(); } /** diff --git a/mo/test/CMakeLists.txt b/mo/test/CMakeLists.txt index 1e600f3fc..652b66be3 100644 --- a/mo/test/CMakeLists.txt +++ b/mo/test/CMakeLists.txt @@ -93,7 +93,7 @@ set (TEST_LIST t-moNeutralWalkSampling t-moStatistics t-moIndexedVectorTabuList - t-moRndIndexedVectorTabuList +# t-moRndIndexedVectorTabuList t-moDynSpanCoolingSchedule ) diff --git a/moeo/tutorial/CMakeLists.txt b/moeo/tutorial/CMakeLists.txt index e18c0c2af..45557fb6a 100644 --- a/moeo/tutorial/CMakeLists.txt +++ b/moeo/tutorial/CMakeLists.txt @@ -19,4 +19,4 @@ add_subdirectory(examples) add_subdirectory(Lesson1) add_subdirectory(Lesson2) add_subdirectory(Lesson3) -add_subdirectory(Lesson4) +#add_subdirectory(Lesson4) From bbe3553f47e430dac90d4a2aa0afeef220e759c3 Mon Sep 17 00:00:00 2001 From: quemy Date: Thu, 7 Feb 2013 22:04:14 +0100 Subject: [PATCH 08/17] Clear the sentMessages container in Island and IslandModel in order to use the model more than once (Nils Mangelsen) --- smp/src/island.cpp | 3 +++ smp/src/islandModel.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/smp/src/island.cpp b/smp/src/island.cpp index 22ab472cf..d0c7997ee 100644 --- a/smp/src/island.cpp +++ b/smp/src/island.cpp @@ -68,6 +68,9 @@ void paradiseo::smp::Island::operator()() // Let's wait the end of communications with the island model for(auto& message : sentMessages) message.join(); + + // Clear the sentMessages container + sentMessages.clear(); } template