From 23df679f51cc90ac84b15fa422ecb7cca558ae06 Mon Sep 17 00:00:00 2001 From: canape Date: Thu, 7 Feb 2013 14:43:11 +0100 Subject: [PATCH] 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)