From a56bea8edb33b6c281cb780c0a08e546ed97a7ad Mon Sep 17 00:00:00 2001 From: legillon Date: Wed, 29 Jun 2011 12:16:01 +0000 Subject: [PATCH] adding bilevel contribution git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2281 331e1502-861f-0410-8da2-ba01fb791d7f --- .../branches/bilevel/CMakeLists.txt | 112 +++++++ .../branches/bilevel/CTestConfig.cmake | 7 + .../contribution/branches/bilevel/README.txt | 18 + .../bilevel/application/CMakeLists.txt | 81 +++++ .../bilevel/application/bilevelGen.cpp | 109 +++++++ .../branches/bilevel/application/mbiMDVRP.cpp | 108 ++++++ .../bilevel/application/multirepair.cpp | 217 ++++++++++++ .../bilevel/application/multitemp.cpp | 209 ++++++++++++ .../bilevel/application/simpleRepair.cpp | 172 ++++++++++ .../bilevel/application/simpletemp.cpp | 186 +++++++++++ .../branches/bilevel/application/verifRat.cpp | 181 ++++++++++ .../bilevel/application/verifRat2.cpp | 183 +++++++++++ .../bilevel/application/verifRatmulti.cpp | 167 ++++++++++ .../bilevel/application/verifRatmulti2.cpp | 156 +++++++++ .../branches/bilevel/install.cmake | 28 ++ .../branches/bilevel/instances/bipr01 | 61 ++++ .../branches/bilevel/instances/bipr02 | 109 +++++++ .../branches/bilevel/instances/bipr03 | 157 +++++++++ .../branches/bilevel/instances/bipr04 | 205 ++++++++++++ .../branches/bilevel/instances/bipr05 | 253 ++++++++++++++ .../branches/bilevel/instances/bipr06 | 301 +++++++++++++++++ .../branches/bilevel/instances/bipr07 | 91 ++++++ .../branches/bilevel/instances/bipr08 | 163 +++++++++ .../branches/bilevel/instances/bipr09 | 235 +++++++++++++ .../branches/bilevel/instances/bipr10 | 307 +++++++++++++++++ .../branches/bilevel/instances/mbipr01 | 62 ++++ .../branches/bilevel/instances/mbipr02 | 110 +++++++ .../branches/bilevel/instances/mbipr03 | 158 +++++++++ .../branches/bilevel/instances/mbipr04 | 206 ++++++++++++ .../branches/bilevel/instances/mbipr05 | 254 +++++++++++++++ .../branches/bilevel/instances/mbipr06 | 302 +++++++++++++++++ .../branches/bilevel/instances/mbipr07 | 92 ++++++ .../branches/bilevel/instances/mbipr08 | 164 ++++++++++ .../branches/bilevel/instances/mbipr09 | 236 ++++++++++++++ .../branches/bilevel/instances/mbipr10 | 308 ++++++++++++++++++ branches/contribution/branches/bilevel/run.sh | 2 + .../contribution/branches/bilevel/src/BEO.h | 132 ++++++++ .../branches/bilevel/src/CMakeLists.txt | 39 +++ .../branches/bilevel/src/DistMat.h | 41 +++ .../branches/bilevel/src/Makefile | 152 +++++++++ .../contribution/branches/bilevel/src/PLA.h | 107 ++++++ .../branches/bilevel/src/PLAInitResp.h | 50 +++ .../branches/bilevel/src/PLARandInit.h | 19 ++ .../contribution/branches/bilevel/src/VRP2.h | 148 +++++++++ .../branches/bilevel/src/VRP2Eval.h | 51 +++ .../branches/bilevel/src/VRP2InitNN.h | 125 +++++++ .../bilevel/src/beoBLAISArchivemulti.cpp | 199 +++++++++++ .../bilevel/src/beoBLAISArchivemulti.h | 135 ++++++++ .../bilevel/src/beoBLAISArchivetemp.cpp | 199 +++++++++++ .../bilevel/src/beoBLAISArchivetemp.h | 135 ++++++++ .../branches/bilevel/src/beoCoevoAllPop.h | 61 ++++ .../branches/bilevel/src/beoCoevoLinePop.h | 57 ++++ .../branches/bilevel/src/beoCoevoOp.h | 43 +++ .../branches/bilevel/src/beoCoevoPop.h | 42 +++ .../branches/bilevel/src/beoDummyCoevoPop.h | 43 +++ .../branches/bilevel/src/beoEval.h | 71 ++++ .../branches/bilevel/src/beoInit.h | 54 +++ .../branches/bilevel/src/beoLexContinue.h | 96 ++++++ .../branches/bilevel/src/beoLowComparator.h | 47 +++ .../branches/bilevel/src/beoLowMut.h | 58 ++++ .../branches/bilevel/src/beoLowQuad.h | 60 ++++ .../branches/bilevel/src/beoObjectiveVector.h | 181 ++++++++++ .../bilevel/src/beoObjectiveVectorTraits.h | 64 ++++ .../branches/bilevel/src/beoRepairEval.h | 64 ++++ .../branches/bilevel/src/beoSelectCoevoPop.h | 71 ++++ .../branches/bilevel/src/beoSelectLow.h | 56 ++++ .../branches/bilevel/src/beoSelectOneLow.h | 56 ++++ .../branches/bilevel/src/beoSelectOneUp.h | 56 ++++ .../branches/bilevel/src/beoSelectUp.h | 56 ++++ .../branches/bilevel/src/beoUpComparator.h | 47 +++ .../branches/bilevel/src/beoUpMut.h | 56 ++++ .../branches/bilevel/src/beoUpQuad.h | 60 ++++ .../contribution/branches/bilevel/src/biVRP.h | 14 + .../branches/bilevel/src/biVRPDistMat.cpp | 201 ++++++++++++ .../branches/bilevel/src/biVRPDistMat.h | 68 ++++ .../branches/bilevel/src/biVRPInit.h | 19 ++ .../branches/bilevel/src/biVRPLowEval.h | 34 ++ .../branches/bilevel/src/biVRPPerf2Worth.h | 10 + .../branches/bilevel/src/biVRPUpEval.h | 29 ++ .../branches/bilevel/src/mbiVRPDistMat.cpp | 210 ++++++++++++ .../branches/bilevel/src/mbiVRPDistMat.h | 69 ++++ .../branches/bilevel/src/mbiVRPLowEval.h | 43 +++ .../branches/bilevel/src/moeoSteadyContinue.h | 62 ++++ .../bilevel/src/op/PolynomialMutation.h | 123 +++++++ .../branches/bilevel/src/op/SBXCrossover.h | 194 +++++++++++ .../branches/bilevel/src/op/VRP2RBX.h | 65 ++++ .../branches/bilevel/src/op/VRP2Repair.h | 119 +++++++ .../branches/bilevel/src/op/VRP2SBX.h | 82 +++++ .../branches/bilevel/src/op/VRPXover.h | 39 +++ .../branches/bilevel/src/op/beoBestExchange.h | 50 +++ .../bilevel/src/op/beoCoevoLowExchange.h | 50 +++ .../bilevel/src/op/beoCoevoUpExchange.h | 50 +++ .../bilevel/src/op/beoLeftieExchange.h | 47 +++ .../bilevel/src/op/beoRateContainerCoevoOp.h | 62 ++++ .../bilevel/src/op/beoRightieExchange.h | 47 +++ .../branches/bilevel/src/op/biVRPRBX.h | 72 ++++ .../branches/bilevel/src/op/biVRPSBX.h | 79 +++++ 97 files changed, 10479 insertions(+) create mode 100644 branches/contribution/branches/bilevel/CMakeLists.txt create mode 100644 branches/contribution/branches/bilevel/CTestConfig.cmake create mode 100644 branches/contribution/branches/bilevel/README.txt create mode 100644 branches/contribution/branches/bilevel/application/CMakeLists.txt create mode 100644 branches/contribution/branches/bilevel/application/bilevelGen.cpp create mode 100644 branches/contribution/branches/bilevel/application/mbiMDVRP.cpp create mode 100644 branches/contribution/branches/bilevel/application/multirepair.cpp create mode 100644 branches/contribution/branches/bilevel/application/multitemp.cpp create mode 100644 branches/contribution/branches/bilevel/application/simpleRepair.cpp create mode 100644 branches/contribution/branches/bilevel/application/simpletemp.cpp create mode 100644 branches/contribution/branches/bilevel/application/verifRat.cpp create mode 100644 branches/contribution/branches/bilevel/application/verifRat2.cpp create mode 100644 branches/contribution/branches/bilevel/application/verifRatmulti.cpp create mode 100644 branches/contribution/branches/bilevel/application/verifRatmulti2.cpp create mode 100644 branches/contribution/branches/bilevel/install.cmake create mode 100644 branches/contribution/branches/bilevel/instances/bipr01 create mode 100644 branches/contribution/branches/bilevel/instances/bipr02 create mode 100644 branches/contribution/branches/bilevel/instances/bipr03 create mode 100644 branches/contribution/branches/bilevel/instances/bipr04 create mode 100644 branches/contribution/branches/bilevel/instances/bipr05 create mode 100644 branches/contribution/branches/bilevel/instances/bipr06 create mode 100644 branches/contribution/branches/bilevel/instances/bipr07 create mode 100644 branches/contribution/branches/bilevel/instances/bipr08 create mode 100644 branches/contribution/branches/bilevel/instances/bipr09 create mode 100644 branches/contribution/branches/bilevel/instances/bipr10 create mode 100644 branches/contribution/branches/bilevel/instances/mbipr01 create mode 100644 branches/contribution/branches/bilevel/instances/mbipr02 create mode 100644 branches/contribution/branches/bilevel/instances/mbipr03 create mode 100644 branches/contribution/branches/bilevel/instances/mbipr04 create mode 100644 branches/contribution/branches/bilevel/instances/mbipr05 create mode 100644 branches/contribution/branches/bilevel/instances/mbipr06 create mode 100644 branches/contribution/branches/bilevel/instances/mbipr07 create mode 100644 branches/contribution/branches/bilevel/instances/mbipr08 create mode 100644 branches/contribution/branches/bilevel/instances/mbipr09 create mode 100644 branches/contribution/branches/bilevel/instances/mbipr10 create mode 100755 branches/contribution/branches/bilevel/run.sh create mode 100644 branches/contribution/branches/bilevel/src/BEO.h create mode 100644 branches/contribution/branches/bilevel/src/CMakeLists.txt create mode 100644 branches/contribution/branches/bilevel/src/DistMat.h create mode 100644 branches/contribution/branches/bilevel/src/Makefile create mode 100644 branches/contribution/branches/bilevel/src/PLA.h create mode 100644 branches/contribution/branches/bilevel/src/PLAInitResp.h create mode 100644 branches/contribution/branches/bilevel/src/PLARandInit.h create mode 100644 branches/contribution/branches/bilevel/src/VRP2.h create mode 100644 branches/contribution/branches/bilevel/src/VRP2Eval.h create mode 100644 branches/contribution/branches/bilevel/src/VRP2InitNN.h create mode 100644 branches/contribution/branches/bilevel/src/beoBLAISArchivemulti.cpp create mode 100644 branches/contribution/branches/bilevel/src/beoBLAISArchivemulti.h create mode 100644 branches/contribution/branches/bilevel/src/beoBLAISArchivetemp.cpp create mode 100644 branches/contribution/branches/bilevel/src/beoBLAISArchivetemp.h create mode 100644 branches/contribution/branches/bilevel/src/beoCoevoAllPop.h create mode 100644 branches/contribution/branches/bilevel/src/beoCoevoLinePop.h create mode 100644 branches/contribution/branches/bilevel/src/beoCoevoOp.h create mode 100644 branches/contribution/branches/bilevel/src/beoCoevoPop.h create mode 100644 branches/contribution/branches/bilevel/src/beoDummyCoevoPop.h create mode 100644 branches/contribution/branches/bilevel/src/beoEval.h create mode 100644 branches/contribution/branches/bilevel/src/beoInit.h create mode 100644 branches/contribution/branches/bilevel/src/beoLexContinue.h create mode 100644 branches/contribution/branches/bilevel/src/beoLowComparator.h create mode 100644 branches/contribution/branches/bilevel/src/beoLowMut.h create mode 100644 branches/contribution/branches/bilevel/src/beoLowQuad.h create mode 100644 branches/contribution/branches/bilevel/src/beoObjectiveVector.h create mode 100644 branches/contribution/branches/bilevel/src/beoObjectiveVectorTraits.h create mode 100644 branches/contribution/branches/bilevel/src/beoRepairEval.h create mode 100644 branches/contribution/branches/bilevel/src/beoSelectCoevoPop.h create mode 100644 branches/contribution/branches/bilevel/src/beoSelectLow.h create mode 100644 branches/contribution/branches/bilevel/src/beoSelectOneLow.h create mode 100644 branches/contribution/branches/bilevel/src/beoSelectOneUp.h create mode 100644 branches/contribution/branches/bilevel/src/beoSelectUp.h create mode 100644 branches/contribution/branches/bilevel/src/beoUpComparator.h create mode 100644 branches/contribution/branches/bilevel/src/beoUpMut.h create mode 100644 branches/contribution/branches/bilevel/src/beoUpQuad.h create mode 100644 branches/contribution/branches/bilevel/src/biVRP.h create mode 100644 branches/contribution/branches/bilevel/src/biVRPDistMat.cpp create mode 100644 branches/contribution/branches/bilevel/src/biVRPDistMat.h create mode 100644 branches/contribution/branches/bilevel/src/biVRPInit.h create mode 100644 branches/contribution/branches/bilevel/src/biVRPLowEval.h create mode 100644 branches/contribution/branches/bilevel/src/biVRPPerf2Worth.h create mode 100644 branches/contribution/branches/bilevel/src/biVRPUpEval.h create mode 100644 branches/contribution/branches/bilevel/src/mbiVRPDistMat.cpp create mode 100644 branches/contribution/branches/bilevel/src/mbiVRPDistMat.h create mode 100644 branches/contribution/branches/bilevel/src/mbiVRPLowEval.h create mode 100644 branches/contribution/branches/bilevel/src/moeoSteadyContinue.h create mode 100644 branches/contribution/branches/bilevel/src/op/PolynomialMutation.h create mode 100644 branches/contribution/branches/bilevel/src/op/SBXCrossover.h create mode 100644 branches/contribution/branches/bilevel/src/op/VRP2RBX.h create mode 100644 branches/contribution/branches/bilevel/src/op/VRP2Repair.h create mode 100644 branches/contribution/branches/bilevel/src/op/VRP2SBX.h create mode 100644 branches/contribution/branches/bilevel/src/op/VRPXover.h create mode 100644 branches/contribution/branches/bilevel/src/op/beoBestExchange.h create mode 100644 branches/contribution/branches/bilevel/src/op/beoCoevoLowExchange.h create mode 100644 branches/contribution/branches/bilevel/src/op/beoCoevoUpExchange.h create mode 100644 branches/contribution/branches/bilevel/src/op/beoLeftieExchange.h create mode 100644 branches/contribution/branches/bilevel/src/op/beoRateContainerCoevoOp.h create mode 100644 branches/contribution/branches/bilevel/src/op/beoRightieExchange.h create mode 100644 branches/contribution/branches/bilevel/src/op/biVRPRBX.h create mode 100644 branches/contribution/branches/bilevel/src/op/biVRPSBX.h diff --git a/branches/contribution/branches/bilevel/CMakeLists.txt b/branches/contribution/branches/bilevel/CMakeLists.txt new file mode 100644 index 000000000..26ec44594 --- /dev/null +++ b/branches/contribution/branches/bilevel/CMakeLists.txt @@ -0,0 +1,112 @@ +###################################################################################### +### 0) Set your application properties +###################################################################################### +# check cmake version compatibility +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +# Here define your project name +PROJECT(biMMDVRP) + +# Here define the name and the version of your package +SET(PACKAGE_NAME "mdrvrp" CACHE STRING "Package name" FORCE) +SET(PACKAGE_VERSION "0.1" CACHE STRING "Package version" FORCE) + + +# regular expression checking +INCLUDE_REGULAR_EXPRESSION("^.*$" "^$") + +# set a language for the entire project. +ENABLE_LANGUAGE(CXX) +ENABLE_LANGUAGE(C) + +###################################################################################### + +###################################################################################### +### 1) Include the install configuration file where are defined the main variables +###################################################################################### + +INCLUDE(${CMAKE_SOURCE_DIR}/install.cmake) + +###################################################################################### + +###################################################################################### +### 2) Include the sources +###################################################################################### +###################################### +### Include required modules & utilities +##################################################################################### +INCLUDE(CMakeBackwardCompatibilityCXX) + +INCLUDE(FindDoxygen) + +INCLUDE(CheckLibraryExists) + +INCLUDE(Dart OPTIONAL) + +INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src) # include EO directory +INCLUDE_DIRECTORIES(${PARADISEO_MO_SRC_DIR}/src) # include MO directory +INCLUDE_DIRECTORIES(${PARADISEO_MOEO_SRC_DIR}/src) # include MOEO directory +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src) # include your own source directory (MyContrib/src) + +# Set a special flag if the environment is windows (should do the same in a config.g file) +IF (WIN32) + ADD_DEFINITIONS(-D_WINDOWS=1) +ENDIF (WIN32) + +###################################################################################### + +##################################################################################### +### Manage the build type +##################################################################################### + +# the user should choose the build type on windows environments,excepted under cygwin (default=none) +SET(CMAKE_DEFAULT_BUILD_TYPE "Release" CACHE STRING "Variable that stores the default CMake build type" FORCE) + +FIND_PROGRAM(MEMORYCHECK_COMMAND + NAMES purify valgrind + PATHS + "/usr/local/bin /usr/bin [HKEY_LOCAL_MACHINE\\SOFTWARE\\Rational Software\\Purify\\Setup;InstallFolder]" + DOC "Path to the memory checking command, used for memory error detection.") + +IF(NOT CMAKE_BUILD_TYPE) + SET( CMAKE_BUILD_TYPE + ${CMAKE_DEFAULT_BUILD_TYPE} CACHE STRING + "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." + FORCE) +ENDIF(NOT CMAKE_BUILD_TYPE) + +IF(WIN32 AND NOT CYGWIN) + IF(CMAKE_CXX_COMPILER MATCHES cl) + IF(NOT WITH_SHARED_LIBS) + IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008") + SET(CMAKE_CXX_FLAGS "/nologo /Gy") + SET(CMAKE_CXX_FLAGS_DEBUG "/W3 /MTd /Z7 /Od") + SET(CMAKE_CXX_FLAGS_RELEASE "/w /MT /O3 /wd4530") + SET(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O2") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MTd /Z7 /Od") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") + ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005" OR CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008") + ENDIF(NOT WITH_SHARED_LIBS) + ENDIF(CMAKE_CXX_COMPILER MATCHES cl) +ELSE(WIN32 AND NOT CYGWIN) + IF(CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -fprofile-arcs -ftest-coverage -Wall -Wextra -Wno-unused-parameter") + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") + SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -O6") + ENDIF(CMAKE_COMPILER_IS_GNUCXX) +ENDIF(WIN32 AND NOT CYGWIN) + +IF(CMAKE_BUILD_TYPE MATCHES Debug) + ADD_DEFINITIONS(-DCMAKE_VERBOSE_MAKEFILE=ON) +ENDIF(CMAKE_BUILD_TYPE MATCHES Debug) + +###################################################################################### +### 3) Link the librairies for your executable +###################################################################################### + +ADD_SUBDIRECTORY(doc) +ADD_SUBDIRECTORY(src) +ADD_SUBDIRECTORY(test) +ADD_SUBDIRECTORY(application) +###################################################################################### + diff --git a/branches/contribution/branches/bilevel/CTestConfig.cmake b/branches/contribution/branches/bilevel/CTestConfig.cmake new file mode 100644 index 000000000..465d208d6 --- /dev/null +++ b/branches/contribution/branches/bilevel/CTestConfig.cmake @@ -0,0 +1,7 @@ +set(CTEST_PROJECT_NAME "ParadisEO") +set(CTEST_NIGHTLY_START_TIME "00:00:00 EST") + +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "cdash.inria.fr") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=ParadisEO") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/branches/contribution/branches/bilevel/README.txt b/branches/contribution/branches/bilevel/README.txt new file mode 100644 index 000000000..208c30691 --- /dev/null +++ b/branches/contribution/branches/bilevel/README.txt @@ -0,0 +1,18 @@ +Paradiseo contribution for a bilevel multiple depot vehicule routing problem solver + +Build instructions: +start by setting the path to paradiseo in install.cmake (paradiseo should be built) +then go to the build directory, and do a "cmake ..", then a "make" +after building, in the build directory + +Run instructions: +./application/simpletemp bench seed +where bench is a benchmark file for biMDVRP (bipr*x* in the instances folder) and seed a number to initialize the pseudo random generator +./application/multitemp bench seed +where bench is a benchmark file for mbiMDVRP (mbipr*x* in the instances folder) and seed a number to initialize the pseudo random generator + + + +Additional informations: +*The instances/benchmark are in instances directory +*We use CoBRA to solve the problem diff --git a/branches/contribution/branches/bilevel/application/CMakeLists.txt b/branches/contribution/branches/bilevel/application/CMakeLists.txt new file mode 100644 index 000000000..d7a399355 --- /dev/null +++ b/branches/contribution/branches/bilevel/application/CMakeLists.txt @@ -0,0 +1,81 @@ +###################################################################################### +### 1) Include the sources +###################################################################################### + +INCLUDE_DIRECTORIES(${PARADISEO_EO_SRC_DIR}/src + ${PARADISEO_MOEO_SRC_DIR}/src + ${PARADISEO_MO_SRC_DIR}/src + ${CMAKE_SOURCE_DIR}/tsp/ + ${CMAKE_SOURCE_DIR}/src) + +###################################################################################### + + +###################################################################################### +### 2) Specify where CMake can find the libraries +###################################################################################### + +LINK_DIRECTORIES(${PARADISEO_EO_BIN_DIR}/lib) +LINK_DIRECTORIES(${PARADISEO_MOEO_BIN_DIR}/lib) +LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lib) +###################################################################################### + + +###################################################################################### +### 3) Define your target: just an executable here +###################################################################################### + + + + + +ADD_EXECUTABLE(mbiMDVRP mbiMDVRP.cpp) +ADD_EXECUTABLE(simpletemp simpletemp.cpp) +ADD_EXECUTABLE(simpleRepair simpleRepair.cpp) +ADD_EXECUTABLE(multitemp multitemp.cpp) +ADD_EXECUTABLE(multirepair multirepair.cpp) +ADD_EXECUTABLE(bilevelGen bilevelGen.cpp) +ADD_EXECUTABLE(verifRat verifRat.cpp) +ADD_EXECUTABLE(verifRat2 verifRat2.cpp) +ADD_EXECUTABLE(verifRatmulti verifRatmulti.cpp) +ADD_EXECUTABLE(verifRatmulti2 verifRatmulti2.cpp) +###################################################################################### + + +###################################################################################### +### 4) Link the librairies for your executable +###################################################################################### + +# Only if you need to link libraries +TARGET_LINK_LIBRARIES(mbiMDVRP eo eoutils lvrp lbeo) +TARGET_LINK_LIBRARIES(simpletemp eo eoutils lbeo lvrp ) +TARGET_LINK_LIBRARIES(simpleRepair eo eoutils lbeo lvrp ) +TARGET_LINK_LIBRARIES(multitemp eo eoutils lbeo lvrp ) +TARGET_LINK_LIBRARIES(multirepair eo eoutils lbeo lvrp ) +TARGET_LINK_LIBRARIES(bilevelGen eo eoutils lvrp lbeo) +TARGET_LINK_LIBRARIES(verifRat eo eoutils lvrp lbeo) +TARGET_LINK_LIBRARIES(verifRat2 eo eoutils lvrp lbeo) +TARGET_LINK_LIBRARIES(verifRatmulti eo eoutils lvrp lbeo) +TARGET_LINK_LIBRARIES(verifRatmulti2 eo eoutils lvrp lbeo) + +###################################################################################### + + +###################################################################################### +### 5) Copy the instances and the "param" file in the build path for an easy use. +### +### --> run the "make install" target to copy the parameter file / instances +### in the directory where you build the application +###################################################################################### + +#ADD_CUSTOM_TARGET(install DEPENDS ${CMAKE_SOURCE_DIR}/application/NSGAII.param +# ${CMAKE_SOURCE_DIR}/application) +ADD_CUSTOM_COMMAND( + TARGET install + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + ${CMAKE_SOURCE_DIR}/application/NSGAII.param + ${CMAKE_BINARY_DIR}/application) + +###################################################################################### diff --git a/branches/contribution/branches/bilevel/application/bilevelGen.cpp b/branches/contribution/branches/bilevel/application/bilevelGen.cpp new file mode 100644 index 000000000..93207f737 --- /dev/null +++ b/branches/contribution/branches/bilevel/application/bilevelGen.cpp @@ -0,0 +1,109 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//bilevel mdvrp instance generator with single-objective follower problem +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +int main(int argc, char* argv[]) + +{ + if (argc<4) { + cout<< "donnez un nom d'instance MDVRP, un nombre d'usine et la demande totale des retailers"<>type; + file>>vehiculeNumber; + file>>retailerNumber; + file>>depotNumber; + cout<<8<<" "<>a; + file>>b; + if(i==depotNumber-1) + cout < +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +int main(int argc, char* argv[]) + +{ + if (argc<4) { + cout<< "donnez un nom d'instance MDVRP, un nombre d'usine et la demande totale des retailers"<>type; + file>>vehiculeNumber; + file>>retailerNumber; + file>>depotNumber; + cout<<10<<" "<>a; + file>>b; + cout < +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +int main(int argc, char* argv[]) +{ + if (argc<3) { + cout<< "donnez un nom d'instance et un numerio de seed"< comp; + biVRPUpEval evalU(mat); + mbiVRPLowEval evalL(mat); + beoEval eval(evalL,evalU); + eval.nbEval=0; + moeoDetTournamentSelect selectCoevoL(comp); + moeoDetTournamentSelect selectCoevoU(comp); + + + VRP2 grou; + grou.init(mat); + PLA grou2; + grou2.init(mat); + + /******* + * ALGOL + ******/ + + moeoParetoObjectiveVectorComparator paretocomp; + moeoFitnessComparator fitcomp; + beoLowComparator compL(paretocomp); + moeoDetTournamentSelect oneselectL(fitcomp); + moeoDummyDiversityAssignment divass; + eoSelectNumber selectL(oneselectL,popsize/3); + moeoGenerationalReplacement replaceL; + double sigma=0.5; + double proba=0.1; + eoRealInterval interval; + eoRealVectorBounds bounds(grou2.size(),interval); + PolynomialMutation mmutL(bounds); + SBXCrossover xoverMMM(bounds); + beoLowQuad xoveralgoL(xoverMMM); + beoLowMut mutL(mmutL); + eoMonGenOp genopalgoU1(mutL); + eoRankingSelect selectalgoL; + eoSequentialOp opL; + eoGeneralBreeder breedalgoL(selectalgoL,opL); + opL.add(mutL,0.5); + opL.add(xoveralgoL,1); + moeoSteadyContinue contalgoL(0,0,0.95); + PLARandInit initpla(mat); + + moeoNSGAII algoL(contalgoL,eval, opL); + + + /****** + * ALGOU + ******/ + moeoDetTournamentSelect oneselectU(comp); + eoSelectNumber selectU(oneselectU,popsize/3); + eoSwapMutation mmutU(5); + beoUpMut mutU(mmutU); + + biVRPSBX xover; + biVRPRBX xover2; + eoGenerationalReplacement replaceU; + eoPeriodicContinue contalgoU(10); + eoBinGenOp genop(xover); + eoMonGenOp genop2(mutU); + eoBinGenOp genop3(xover2); + eoDetTournamentSelect selectalgoU; + eoSequentialOp nouvelopU; + eoGeneralBreeder breedalgoU(oneselectU,nouvelopU); + nouvelopU.add(genop2,0.5); + + beoRepairEval repeval(eval,algoL); + eoEasyEA algoU(contalgoU,repeval, breedalgoU, replaceU); + /****** + * MAIN ALGO + *****/ + + biVRPPerf2Worth perf2WorthU; + biVRPPerf2Worth perf2WorthL; + eoDetTournamentWorthSelect ranselectpoperU(perf2WorthU,2); + eoDetTournamentWorthSelect ranselectpoperL(perf2WorthL,2); + + beoLexContinue contU(100,100); + moeoSteadyContinue contL(100,100); + eoInitPermutation initpermut(grou.size()); + biVRPInit init(mat,initpermut); + beoBestExchange coevo3; + beoRateContainerCoevoOp coevo(coevo3,0.5); + beoSelectOneUp su(ranselectpoperU); + beoSelectOneLow sl(ranselectpoperL); + eoSelectNumber selectPoperU(su,10); + eoSelectNumber selectPoperL(sl,10); + beoCoevoLinePop poper(coevo, 80); + eoDeterministicSaDReplacement merge(0.8); + + beoBLAISArchivetemp blais(algoU,algoL,eval,poper,contL,contU,selectCoevoU,selectCoevoL,merge); + eoPop pop(popsize,init); + for (int i=0;i +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +int main(int argc, char* argv[]) +{ + if (argc<3) { + cout<< "donnez un nom d'instance et un numerio de seed"<::nbEval=0; + string filename(argv[1]); + mbiVRPDistMat mat; + mat.load(filename); + int popsize=200; + + moeoFitnessComparator comp; + biVRPUpEval evalU(mat); + mbiVRPLowEval evalL(mat); + beoEval eval(evalL,evalU); + eval.nbEval=0; + moeoDetTournamentSelect selectCoevoL(comp); + moeoDetTournamentSelect selectCoevoU(comp); + + VRP2 grou; + grou.init(mat); + PLA grou2; + grou2.init(mat); + + /****** + * ALGOU + ******/ + moeoDetTournamentSelect oneselectU(comp); + eoSelectNumber selectU(oneselectU,popsize/3); + eoSwapMutation mmutU(5); + beoUpMut mutU(mmutU); + + biVRPSBX xover; + biVRPRBX xover2; + eoGenerationalReplacement replaceU; + eoPeriodicContinue contalgoU(10); + eoBinGenOp genop(xover); + eoMonGenOp genop2(mutU); + eoBinGenOp genop3(xover2); + eoDetTournamentSelect selectalgoU; + eoSequentialOp nouvelopU; + eoGeneralBreeder breedalgoU(oneselectU,nouvelopU); + nouvelopU.add(genop2,0.5); + eoEasyEA algoU(contalgoU,eval, breedalgoU, replaceU); + + /******* + * ALGOL + ******/ + + moeoParetoObjectiveVectorComparator paretocomp; + moeoFitnessComparator fitcomp; + beoLowComparator compL(paretocomp); + moeoDetTournamentSelect oneselectL(fitcomp); + moeoDummyDiversityAssignment divass; + eoSelectNumber selectL(oneselectL,popsize/3); + moeoGenerationalReplacement replaceL; + double sigma=0.5; + double proba=0.1; + eoRealInterval interval; + eoRealVectorBounds bounds(grou2.size(),interval); + PolynomialMutation mmutL(bounds); + SBXCrossover xoverMMM(bounds); + beoLowQuad xoveralgoL(xoverMMM); + beoLowMut mutL(mmutL); + eoMonGenOp genopalgoU1(mutL); + eoRankingSelect selectalgoL; + eoSequentialOp opL; + eoGeneralBreeder breedalgoL(selectalgoL,opL); + opL.add(mutL,0.5); + opL.add(xoveralgoL,1); + moeoSteadyContinue contalgoL(0,0,0.95); + PLARandInit initpla(mat); + + moeoNSGAII algoL(contalgoL,eval, opL); + + /****** + * MAIN ALGO + *****/ + + biVRPPerf2Worth perf2WorthU; + biVRPPerf2Worth perf2WorthL; + eoDetTournamentWorthSelect ranselectpoperU(perf2WorthU,2); + eoDetTournamentWorthSelect ranselectpoperL(perf2WorthL,2); + + beoLexContinue contU(100,100); + moeoSteadyContinue contL(100,100); + eoInitPermutation initpermut(grou.size()); + biVRPInit init(mat,initpermut); + beoBestExchange coevo3; + beoRateContainerCoevoOp coevo(coevo3,0.5); + beoSelectOneUp su(ranselectpoperU); + beoSelectOneLow sl(ranselectpoperL); + eoSelectNumber selectPoperU(su,10); + eoSelectNumber selectPoperL(sl,10); + beoCoevoLinePop poper(coevo, 80); + eoDeterministicSaDReplacement merge(0.8); + + beoBLAISArchivetemp blais(algoU,algoL,eval,poper,contL,contU,selectCoevoU,selectCoevoL,merge); + eoPop pop(popsize,init); + for (int i=0;i +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +int main(int argc, char* argv[]) +{ + if (argc<3) { + cout<< "donnez un nom d'instance et un numerio de seed"< comp; + biVRPUpEval evalU(mat); + biVRPLowEval evalL(mat); + beoEval eval(evalL,evalU); + eval.nbEval=0; + /******* + * ALGOL + ******/ + eoDetTournamentSelect oneselectL; + eoSelectNumber selectL(oneselectL,popsize/3); + eoGenerationalReplacement replaceL; + double sigma=0.5; + double proba=0.1; + eoNormalMutation mmutL(sigma,proba); + eoRealUXover xoverMMM; + beoLowQuad xoveralgoL(xoverMMM); + beoLowMut mutL(mmutL); + eoMonGenOp genopalgoU1(mutL); + eoRankingSelect selectalgoL; + eoSequentialOp opL; + eoGeneralBreeder breedalgoL(selectalgoL,opL); + opL.add(mutL,0.5); + opL.add(xoveralgoL,1); + eoSteadyFitContinue contalgoL(100,100); + eoEasyEA algoL(contalgoL,eval, breedalgoL, replaceL); + + + /****** + * ALGOU + ******/ + beoRepairEval repeval(eval,algoL); + moeoDetTournamentSelect oneselectU(comp); + eoSelectNumber selectU(oneselectU,popsize/3); + eoSwapMutation mmutU(5); + beoUpMut mutU(mmutU); + + biVRPSBX xover; + biVRPRBX xover2; + eoDeterministicSaDReplacement replaceU(0.3); + eoBinGenOp genop(xover); + eoMonGenOp genop2(mutU); + eoBinGenOp genop3(xover2); + eoDetTournamentSelect selectalgoU; + eoSequentialOp nouvelopU; + eoGeneralBreeder breedalgoU(oneselectU,nouvelopU); + nouvelopU.add(genop,1); + nouvelopU.add(genop2,0.3); + nouvelopU.add(genop3,0.5); + beoLexContinue contU(100,100); + eoEasyEA algoU(contU,repeval, breedalgoU, replaceU); + + + /****** + * MAIN ALGO + *****/ + biVRPPerf2Worth perf2WorthU; + biVRPPerf2Worth perf2WorthL; + eoDetTournamentWorthSelect ranselectpoperU(perf2WorthU,2); + eoDetTournamentWorthSelect ranselectpoperL(perf2WorthL,2); + + VRP2 grou; + grou.init(mat); + eoInitPermutation initpermut(grou.size()); + biVRPInit init(mat,initpermut); + eoDeterministicSaDReplacement merge(0.8); + eoPop pop(100,init); + for (int i=0;i<100;i++) repeval(pop[i]); + algoU(pop); + for (int i=0;i +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +int main(int argc, char* argv[]) +{ + if (argc<3) { + cout<< "donnez un nom d'instance et un numerio de seed"< comp; + biVRPUpEval evalU(mat); + biVRPLowEval evalL(mat); + beoEval eval(evalL,evalU); + eval.nbEval=0; + moeoDetTournamentSelect selectCoevoL(comp); + moeoDetTournamentSelect selectCoevoU(comp); + + /****** + * ALGOU + ******/ + moeoDetTournamentSelect oneselectU(comp); + eoSelectNumber selectU(oneselectU,popsize/3); + eoSwapMutation mmutU(5); + beoUpMut mutU(mmutU); + + biVRPSBX xover; + biVRPRBX xover2; + eoGenerationalReplacement replaceU; + eoPeriodicContinue contalgoU(10); + eoBinGenOp genop(xover); + eoMonGenOp genop2(mutU); + eoBinGenOp genop3(xover2); + eoDetTournamentSelect selectalgoU; + eoSequentialOp nouvelopU; + eoGeneralBreeder breedalgoU(oneselectU,nouvelopU); + nouvelopU.add(genop,1); + nouvelopU.add(genop2,0.3); + nouvelopU.add(genop3,0.5); + eoEasyEA algoU(contalgoU,eval, breedalgoU, replaceU); + + /******* + * ALGOL + ******/ + + eoDetTournamentSelect oneselectL; + eoSelectNumber selectL(oneselectL,popsize/3); + eoGenerationalReplacement replaceL; + double sigma=0.5; + double proba=0.1; + eoNormalMutation mmutL(sigma,proba); + eoRealUXover xoverMMM; + beoLowQuad xoveralgoL(xoverMMM); + beoLowMut mutL(mmutL); + eoMonGenOp genopalgoU1(mutL); + eoRankingSelect selectalgoL; + eoSequentialOp opL; + eoGeneralBreeder breedalgoL(selectalgoL,opL); + opL.add(mutL,0.5); + opL.add(xoveralgoL,1); + eoPeriodicContinue contalgoL(10); + PLARandInit initpla(mat); + + eoEasyEA algoL(contalgoL,eval, breedalgoL, replaceL); + + /****** + * MAIN ALGO + *****/ + + biVRPPerf2Worth perf2WorthU; + biVRPPerf2Worth perf2WorthL; + eoDetTournamentWorthSelect ranselectpoperU(perf2WorthU,2); + eoDetTournamentWorthSelect ranselectpoperL(perf2WorthL,2); + + beoLexContinue contU(100,100); + beoLexContinue contL(100,100); + VRP2 grou; + grou.init(mat); + eoInitPermutation initpermut(grou.size()); + biVRPInit init(mat,initpermut); + beoBestExchange coevo3; + beoRateContainerCoevoOp coevo(coevo3,0.5); + beoSelectOneUp su(ranselectpoperU); + beoSelectOneLow sl(ranselectpoperL); + eoSelectNumber selectPoperU(su,10); + eoSelectNumber selectPoperL(sl,10); + beoCoevoLinePop poper(coevo, 80); + eoDeterministicSaDReplacement merge(0.8); + + beoBLAISArchivetemp blais(algoU,algoL,eval,poper,contL,contU,selectCoevoU,selectCoevoL,merge); + eoPop pop(100,init); + for (int i=0;i<100;i++) eval(pop[i]); + blais(pop); + std::cout<<"nbEval"< +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +int main(int argc, char* argv[]) +{ + if (argc<3) { + cout<< "donnez un nom d'instance et un fichier de solution a verifier"< pop; + beoEval eval(evalL,evalU); + VRP2 vrp; + vrp.init(mat); + PLA pla; + pla.init(mat); + for (int x=2;x vrpvector; + std::vector plavector; + for (int i=0;i>top; + plavector.push_back(top); + } + for (int i=0;i>top; + vrpvector.push_back(top); + } + PLA neopla(plavector,mat); + VRP2 neovrp(vrpvector,mat); + biVRP bivrp(neovrp,neopla); + eval(bivrp); + if(first && !file.eof()){ + best=bivrp; + bestscore=bivrp.upper().fitness(); + first=false; + }else if(!file.eof()){ + if(bivrp.upper().fitness()>bestscore){ + bestscore=bivrp.upper().fitness(); + best=bivrp; + } + } + } + pop.push_back(best); + } + + /******* + * ALGOL + ******/ + + eoEliteSequentialSelect oneselectL; + eoSelectNumber selectL(oneselectL,10); + eoDeterministicSaDReplacement replaceL(0.5); + double sigma=0.5; + double proba=0.1; + eoNormalMutation mmutL(sigma,proba); + eoRealUXover xoverMMM; + beoLowQuad xoveralgoL(xoverMMM); + beoLowMut mutL(mmutL); + eoMonGenOp genopalgoU1(mutL); + eoEliteSequentialSelect selectalgoL; + eoSequentialOp opL; + eoGeneralBreeder breedalgoL(selectalgoL,opL); + opL.add(mutL,0.5); + opL.add(xoveralgoL,1); + eoSteadyFitContinue contalgoL(500,500); + PLARandInit initpla(mat); + + eoEasyEA algoL(contalgoL,eval, breedalgoL, replaceL); + + double eps=0.1; + for (unsigned int i=0;i mmm; + pop[i].setMode(false); + bool finish=false; + int res=0; + for (int k=0; k<10000 && !finish; k++){ + mmm.clear(); + mmm.push_back(pop[i]); + mmm.push_back(pop[i]); + mmm.push_back(pop[i]); + mmm.push_back(pop[i]); + algoL(mmm); + for (unsigned int j=0; j score && fabs(score- mmm[j].lower().fitness())>eps){ + res++; + break; + } + } + } + std::cout< +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +int main(int argc, char* argv[]) +{ + if (argc<3) { + cout<< "donnez un nom d'instance et un fichier de solution a verifier"< pop; + beoEval eval(evalL,evalU); + VRP2 vrp; + vrp.init(mat); + PLA pla; + pla.init(mat); + for (int x=2;x vrpvector; + std::vector plavector; + for (int i=0;i>top; + vrpvector.push_back(top); + } + for (int i=0;i>top; + plavector.push_back(top); + } + PLA neopla(plavector,mat); + VRP2 neovrp(vrpvector,mat); + biVRP bivrp(neovrp,neopla); + eval(bivrp); + if(first && !file.eof()){ + best=bivrp; + bestscore=bivrp.upper().fitness(); + first=false; + }else if(!file.eof()){ + if(bivrp.upper().fitness()>bestscore){ + bestscore=bivrp.upper().fitness(); + best=bivrp; + } + } + } + pop.push_back(best); + } + + /******* + * ALGOL + ******/ + + eoEliteSequentialSelect oneselectL; + eoSelectNumber selectL(oneselectL,10); + eoDeterministicSaDReplacement replaceL(0.5); + double sigma=0.5; + double proba=0.1; + eoNormalMutation mmutL(sigma,proba); + eoRealUXover xoverMMM; + beoLowQuad xoveralgoL(xoverMMM); + beoLowMut mutL(mmutL); + eoMonGenOp genopalgoU1(mutL); + eoEliteSequentialSelect selectalgoL; + eoSequentialOp opL; + eoGeneralBreeder breedalgoL(selectalgoL,opL); + opL.add(mutL,0.5); + opL.add(xoveralgoL,1); + eoSteadyFitContinue contalgoL(500,500); + PLARandInit initpla(mat); + + eoEasyEA algoL(contalgoL,eval, breedalgoL, replaceL); + + double eps=0.1; + for (unsigned int i=0;i mmm; + pop[i].setMode(false); + bool finish=false; + int res=0; + for (int k=0; k<10000 && !finish; k++){ + mmm.clear(); + mmm.push_back(pop[i]); + mmm.push_back(pop[i]); + mmm.push_back(pop[i]); + mmm.push_back(pop[i]); + algoL(mmm); + double tmp=0; + for (unsigned int j=0; j score && fabs(score- mmm[j].lower().fitness())>eps){ + if (tmp +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +int main(int argc, char* argv[]) +{ + if (argc<3) { + cout<< "donnez un nom d'instance et un fichier de solution a verifier"< pop; + beoEval eval(evalL,evalU); + VRP2 vrp; + vrp.init(mat); + PLA pla; + pla.init(mat); + moeoParetoObjectiveVectorComparator compL; + beoLowComparator comp(compL); + moeoUnboundedArchive arc(comp); + for (int x=2;x vrpvector; + std::vector plavector; + for (int i=0;i>top; + plavector.push_back(top); + } + for (int i=0;i>top; + vrpvector.push_back(top); + } + PLA neopla(plavector,mat); + VRP2 neovrp(vrpvector,mat); + biVRP bivrp(neovrp,neopla); + eval(bivrp); + arc(bivrp); + } + } + /******* + * ALGOL + ******/ + + eoEliteSequentialSelect oneselectL; + eoSelectNumber selectL(oneselectL,10); + eoDeterministicSaDReplacement replaceL(0.5); + double sigma=0.5; + double proba=0.1; + eoNormalMutation mmutL(sigma,proba); + eoRealUXover xoverMMM; + beoLowQuad xoveralgoL(xoverMMM); + beoLowMut mutL(mmutL); + eoMonGenOp genopalgoU1(mutL); + eoEliteSequentialSelect selectalgoL; + eoSequentialOp opL; + eoGeneralBreeder breedalgoL(selectalgoL,opL); + opL.add(mutL,0.5); + opL.add(xoveralgoL,1); + eoPeriodicContinue contalgoL(500); + PLARandInit initpla(mat); + + moeoNSGAII algoL(contalgoL,eval, opL); + double eps=0.1; + int res=0; + for (int k=0; k<100 ; k++){ + pop=arc; + algoL(pop); + bool stop=false; + for (int j=0;j +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +int main(int argc, char* argv[]) +{ + if (argc<3) { + cout<< "donnez un nom d'instance et un fichier de solution a verifier"< pop; + beoEval eval(evalL,evalU); + VRP2 vrp; + vrp.init(mat); + PLA pla; + pla.init(mat); + moeoParetoObjectiveVectorComparator compL; + beoLowComparator comp(compL); + moeoUnboundedArchive arc(comp); + for (int x=2;x vrpvector; + std::vector plavector; + for (int i=0;i>top; + vrpvector.push_back(top); + } + for (int i=0;i>top; + plavector.push_back(top); + } + PLA neopla(plavector,mat); + VRP2 neovrp(vrpvector,mat); + biVRP bivrp(neovrp,neopla); + eval(bivrp); + arc(bivrp); + } + + } + + /******* + * ALGOL + ******/ + + eoEliteSequentialSelect oneselectL; + eoSelectNumber selectL(oneselectL,10); + eoDeterministicSaDReplacement replaceL(0.5); + double sigma=0.5; + double proba=0.1; + eoNormalMutation mmutL(sigma,proba); + eoRealUXover xoverMMM; + beoLowQuad xoveralgoL(xoverMMM); + beoLowMut mutL(mmutL); + eoMonGenOp genopalgoU1(mutL); + eoEliteSequentialSelect selectalgoL; + eoSequentialOp opL; + eoGeneralBreeder breedalgoL(selectalgoL,opL); + opL.add(mutL,0.5); + opL.add(xoveralgoL,1); + eoPeriodicContinue contalgoL(500); + PLARandInit initpla(mat); + + moeoNSGAII algoL(contalgoL,eval, opL); + double eps=0.1; + int res=0; + algoL(arc); + for (int i=0;i +#include +#include +template < +class BEOU, + class BEOL, + class OBJECTIVE=beoObjectiveVector, + class Fitness=double + > + class BEO: public MOEO{ + public: + typedef BEOU U; + typedef BEOL L; + + BEO(BEOU &_up, BEOL &_low, bool _mode=true):up(_up),low(_low),mode(_mode){} + BEO(bool _mode=true):mode(_mode){} + + + /** + * return the mode flag + */ + bool getMode()const { + return mode; + } + /** + * sets the mode flag and change the general objective vector to the corresponding + * level + */ + void setMode(bool _up){ + mode=_up; + if (!MOEO::invalidObjectiveVector()){ + OBJECTIVE tmp=MOEO::objectiveVector(); + tmp.mode(_up); + objectiveVector(tmp); + } + } + + + /** + * returns the upper part of the solution + */ + U &upper(){ + return up; + } + /** + * returns the upper part of the solution + */ + const U &upper() const{ + return up; + } + /** + * returns the lower part of the solution + */ + L &lower(){ + return low; + } + /** + * returns the lower part of the solution + */ + const L &lower() const{ + return low; + } + /** + * returns true if both level are equal + */ + bool operator==(const BEO& _beo)const{ + return _beo.lower()==lower() && _beo.upper()==upper(); + } + /** + * comparator based on the general fitness + */ + bool operator<(const BEO& _beo)const{ + return MOEO::fitness()<_beo.fitness(); + } + + /** + * comparator based on the general fitness + */ + bool operator>(const BEO& _beo)const{ + return MOEO::fitness()>_beo.fitness(); + } + + void printOn(std::ostream &_os) const{ + _os< +#include +#include +#include +#include +#include +class DistMat { +public: + virtual void load(const std::string)=0; + virtual unsigned int numberOfVehicle()=0; + virtual unsigned int numberOfDepot()=0; + virtual unsigned int numberOfRetailer()=0; + virtual unsigned int numberOfPlant()=0; + virtual bool isConstantDemand()=0; + virtual bool isConstantCapacity()=0; + virtual double demand(unsigned int)=0; + virtual double availability(unsigned int)=0; + + virtual double distance(unsigned int,unsigned int)=0; + virtual double depotDistance(unsigned int,unsigned int)=0; + virtual double plantDepotDistance(unsigned int,unsigned int)=0; + virtual double maxLoad()=0; + virtual double maxDuration()=0; + typedef std::pair ty; + struct compaPair{ + bool operator()( ty a, ty b)const{ + return a.second getOrder(unsigned int)=0; + virtual std::multiset nearDepot(unsigned int)=0; + virtual std::multiset getOrderPlant(unsigned int)=0; + virtual double cbOfPlant(unsigned int)=0; + virtual double ccOfPlant(unsigned int)=0; +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/Makefile b/branches/contribution/branches/bilevel/src/Makefile new file mode 100644 index 000000000..003b8a49f --- /dev/null +++ b/branches/contribution/branches/bilevel/src/Makefile @@ -0,0 +1,152 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +# Default target executed when no arguments are given to make. +default_target: all +.PHONY : default_target + +#============================================================================= +# Special targets provided by cmake. + +# Disable implicit rules so canoncical targets will work. +.SUFFIXES: + +# Remove some rules from gmake that .SUFFIXES does not remove. +SUFFIXES = + +.SUFFIXES: .hpux_make_needs_suffix_list + +# Suppress display of executed commands. +$(VERBOSE).SILENT: + +# A target that is always out of date. +cmake_force: +.PHONY : cmake_force + +#============================================================================= +# Set environment variables for the build. + +# The shell in which to execute make rules. +SHELL = /bin/sh + +# The CMake executable. +CMAKE_COMMAND = /usr/bin/cmake + +# The command to remove a file. +RM = /usr/bin/cmake -E remove -f + +# The top-level source directory on which CMake was run. +CMAKE_SOURCE_DIR = /home/francois/vrp3/vrp/src + +# The top-level build directory on which CMake was run. +CMAKE_BINARY_DIR = /home/francois/vrp3/vrp/src + +#============================================================================= +# Targets provided globally by CMake. + +# Special rule for the target edit_cache +edit_cache: + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running interactive CMake command-line interface..." + /usr/bin/cmake -i . +.PHONY : edit_cache + +# Special rule for the target edit_cache +edit_cache/fast: edit_cache +.PHONY : edit_cache/fast + +# Special rule for the target rebuild_cache +rebuild_cache: + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." + /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) +.PHONY : rebuild_cache + +# Special rule for the target rebuild_cache +rebuild_cache/fast: rebuild_cache +.PHONY : rebuild_cache/fast + +# The main all target +all: cmake_check_build_system + cd /home/francois/vrp3/vrp/src && $(CMAKE_COMMAND) -E cmake_progress_start /home/francois/vrp3/vrp/src/CMakeFiles /home/francois/vrp3/vrp/src/beo/CMakeFiles/progress.marks + cd /home/francois/vrp3/vrp/src && $(MAKE) -f CMakeFiles/Makefile2 beo/all + $(CMAKE_COMMAND) -E cmake_progress_start /home/francois/vrp3/vrp/src/CMakeFiles 0 +.PHONY : all + +# The main clean target +clean: + cd /home/francois/vrp3/vrp/src && $(MAKE) -f CMakeFiles/Makefile2 beo/clean +.PHONY : clean + +# The main clean target +clean/fast: clean +.PHONY : clean/fast + +# Prepare targets for installation. +preinstall: all + cd /home/francois/vrp3/vrp/src && $(MAKE) -f CMakeFiles/Makefile2 beo/preinstall +.PHONY : preinstall + +# Prepare targets for installation. +preinstall/fast: + cd /home/francois/vrp3/vrp/src && $(MAKE) -f CMakeFiles/Makefile2 beo/preinstall +.PHONY : preinstall/fast + +# clear depends +depend: + cd /home/francois/vrp3/vrp/src && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 +.PHONY : depend + +# Convenience name for target. +beo/CMakeFiles/lbeo.dir/rule: + cd /home/francois/vrp3/vrp/src && $(MAKE) -f CMakeFiles/Makefile2 beo/CMakeFiles/lbeo.dir/rule +.PHONY : beo/CMakeFiles/lbeo.dir/rule + +# Convenience name for target. +lbeo: beo/CMakeFiles/lbeo.dir/rule +.PHONY : lbeo + +# fast build rule for target. +lbeo/fast: + cd /home/francois/vrp3/vrp/src && $(MAKE) -f beo/CMakeFiles/lbeo.dir/build.make beo/CMakeFiles/lbeo.dir/build +.PHONY : lbeo/fast + +# target to build an object file +beoBLAISArchivetemp.o: + cd /home/francois/vrp3/vrp/src && $(MAKE) -f beo/CMakeFiles/lbeo.dir/build.make beo/CMakeFiles/lbeo.dir/beoBLAISArchivetemp.o +.PHONY : beoBLAISArchivetemp.o + +# target to preprocess a source file +beoBLAISArchivetemp.i: + cd /home/francois/vrp3/vrp/src && $(MAKE) -f beo/CMakeFiles/lbeo.dir/build.make beo/CMakeFiles/lbeo.dir/beoBLAISArchivetemp.i +.PHONY : beoBLAISArchivetemp.i + +# target to generate assembly for a file +beoBLAISArchivetemp.s: + cd /home/francois/vrp3/vrp/src && $(MAKE) -f beo/CMakeFiles/lbeo.dir/build.make beo/CMakeFiles/lbeo.dir/beoBLAISArchivetemp.s +.PHONY : beoBLAISArchivetemp.s + +# Help Target +help: + @echo "The following are some of the valid targets for this Makefile:" + @echo "... all (the default if no target is provided)" + @echo "... clean" + @echo "... depend" + @echo "... edit_cache" + @echo "... lbeo" + @echo "... rebuild_cache" + @echo "... beoBLAISArchivetemp.o" + @echo "... beoBLAISArchivetemp.i" + @echo "... beoBLAISArchivetemp.s" +.PHONY : help + + + +#============================================================================= +# Special targets to cleanup operation of make. + +# Special rule to run CMake to check the build system integrity. +# No rule that depends on this can have commands that come from listfiles +# because they might be regenerated. +cmake_check_build_system: + cd /home/francois/vrp3/vrp/src && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 +.PHONY : cmake_check_build_system + diff --git a/branches/contribution/branches/bilevel/src/PLA.h b/branches/contribution/branches/bilevel/src/PLA.h new file mode 100644 index 000000000..30370175a --- /dev/null +++ b/branches/contribution/branches/bilevel/src/PLA.h @@ -0,0 +1,107 @@ +#ifndef PLA_H_ +#define PLA_H_ +#include +#include +#include +#include +#include +class PLAObjectiveVectorTraits: public moeoObjectiveVectorTraits{ + public: + static bool minimizing (int _i){ + return true; + } + static bool maximizing (int _i){ + return false; + } + static unsigned int nObjectives (){ + return 2; + } + +}; + +typedef moeoRealObjectiveVector PLAObjectiveVector; +class PLA: + public moeoVector +{ + public: + PLA():plantNumber(0),depotNumber(0) + {} + PLA(std::vector &_bui, DistMat &_mat):plantNumber(0),depotNumber(0) + { + init(_mat); + for (int i=0;i=size()) std::cout<<"set Taux"<=size()) std::cout<<"get Taux"<1){ + double rap=1/sum; + for (unsigned int j=0;j-eps )) + return false; + } + return true; + } + + + + + private: + unsigned int plantNumber; + unsigned int depotNumber; + +}; + +#endif diff --git a/branches/contribution/branches/bilevel/src/PLAInitResp.h b/branches/contribution/branches/bilevel/src/PLAInitResp.h new file mode 100644 index 000000000..f09211838 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/PLAInitResp.h @@ -0,0 +1,50 @@ +#ifndef PLAINIRESP_H_ +#define PLAINIRESP_H_ +#include +#include +#include + +class PLAInitResp: public eoInit{ + public: + PLAInitResp(DistMat &_mat, eoRng& _rng=eo::rng):rng(_rng),mat(_mat){} + void operator()(biVRP &_vrp){ + PLA &_pla=_vrp.lower(); + VRP2 &vrp=_vrp.upper(); + _pla.init(mat); + std::vector usines; + usines.resize(mat.numberOfPlant(),0); + for (unsigned int dep=0;depsent;usi++){ + if (usines[usi]<1){ + double eps=0.000001; + double resttaux=1-usines[usi]; + double tosend=demand-sent; + if (tosend +#include +#include + +class PLARandInit: public eoInit{ + public: + PLARandInit(DistMat &_mat, eoRng& _rng=eo::rng):rng(_rng),mat(_mat){} + void operator()(PLA &_pla){ + _pla.init(mat); + for (unsigned int i=0;i<_pla.size();i++){ + _pla[i]=rng.uniform(); + } + _pla.repairPlants(); + } + + private: + eoRng &rng; + DistMat &mat; +}; diff --git a/branches/contribution/branches/bilevel/src/VRP2.h b/branches/contribution/branches/bilevel/src/VRP2.h new file mode 100644 index 000000000..3cb86aedd --- /dev/null +++ b/branches/contribution/branches/bilevel/src/VRP2.h @@ -0,0 +1,148 @@ +#ifndef VRP_H_ +#define VRP_H_ +#include +#include +#include +#include +#include +#include +#include +#include +class VRP2ObjectiveVectorTraits: public moeoObjectiveVectorTraits{ + public: + static bool minimizing (int _i){ + return false; + } + static bool maximizing (int _i){ + return true; + } + static unsigned int nObjectives (){ + return 1; + } + +}; + +typedef moeoRealObjectiveVector VRP2ObjectiveVector; +class VRP2: + public moeoVector +{ + + + public: + VRP2():retailerNumber(0),vehicleNumber(0),depotNumber(0),inited(false){} + VRP2(std::vector &_bui, DistMat& _mat){ + init(_mat); + for (int i=0;i=retailerNumber &&i=size()) return false; + + return i==-1 || isVehicle(operator[](i)); + } + int depotOfVehicle(int i) const { + return (i+1)/(vehicleNumber/depotNumber); + } + int depotOfVehicleAt(int i) const{ + return depotOfVehicle(operator[](i)-retailerNumber); + } + + double depotDemand(DistMat &_mat , const unsigned int i) { + int firstvoiture=i*vehicleNumber/depotNumber-1; + double res=0; + for (unsigned int j=0;j voituresIdx; + + bool checkIdx(){ + for (unsigned int i=0;i +#include + +class VRP2Eval: public eoEvalFunc { + public: + VRP2Eval (DistMat &_mat): mat(_mat){} + + void operator()(VRP2 &_vrp){ + VRP2Repair repair(mat); + repair(_vrp); + double neo_fit=0; + double vehicle=0; + bool lastWasVehicle=true; + int lastvehicle=0; + bool firstVehicle=true; + if (!_vrp.isVehicleAt(0)){ + neo_fit=mat.depotDistance(0,_vrp[0]); + } + + for (unsigned int i=0;i<_vrp.size();i++){ + if(_vrp.isVehicleAt(i)){ + if(!lastWasVehicle){ + if (i==0) std::cout<<"tinn"< +#include +#include + +class VRP2InitNN: public eoInit{ + public: + typedef std::multiset setclas; + VRP2InitNN( DistMat& _mat, eoRng& _rng, float _proba=1 ): mat(_mat), rng(_rng), proba(_proba) {} + VRP2InitNN( DistMat& _mat, float _proba=1 ): mat(_mat),rng(eo::rng), proba(_proba) {} + + + void operator()(VRP2 & _vrp){ + std::set voituresPlacees; + std::set villesPlacees; + std::vector villesToAdd; + bool dontstop; + bool voiturePleine=true; + + int voituresParDepot=mat.numberOfVehicle()/mat.numberOfDepot(); + int voiture=-1; + int ville=0; + int lastPosWritten=_vrp.size(); + int depot=-1; + int nextVille=-1; + double charge=0; + while (ville!=-1){ + if (voiturePleine){ + charge=0; + villesToAdd.clear(); + villesToAdd.push_back(ville); + villesPlacees.insert(ville); + depot=-1; + setclas depotclas=mat.nearDepot(ville); + for (setclas::iterator it=depotclas.begin();it!=depotclas.end()&& depot==-1;it++){ + for (int i=0;i &villesPlacees){ + int res=-1; + bool dontstop=false; + do{ + for (unsigned int i=0;i +#include + +template +beoBLAISArchivetemp::beoBLAISArchivetemp( + eoAlgo& _au, + eoAlgo& _al, + eoEvalFunc< BEOT>&_eval, + beoCoevoPop< BEOT> &_coevo, + eoContinue< BEOT> &_contL, + eoContinue< BEOT> &_contU, + eoSelectOne& _selectU, + eoSelectOne& _selectL, + eoReplacement &_merge, + unsigned int _nbFromArc=20, + eoRng &_rng=eo::rng + ): + algoU(_au), + algoL(_al), + eval(_eval), + coevo(_coevo), + contL(_contL), + contU(_contU), + selectU(_selectU), + selectL(_selectL), + merge(_merge), + nbFromArc(_nbFromArc), + rng(_rng) +{} + + + +template +void beoBLAISArchivetemp::operator()(eoPop &_pop){ + unsigned taille=_pop.size(); + for (unsigned int i=0;i<_pop.size();i++){ + eval(_pop[i]); + } + moeoUnboundedArchive archiveLow; + moeoUnboundedArchive archiveUp; + eoPop neopopl; + eoPop neopopu; + eoPop popu=_pop; + eoPop popl=_pop; + + setPopMode(popl,false); + setPopMode(popu,true); + algoU(popu); + setPopMode(popu,true); + algoL(popl); + bool continu=contU(popu); + bool continl=contL(popl); + + while(continu && continl){ + //on eval les pop, on copie + setPopMode(popl,false); + setPopMode(popu,true); + neopopu=popu; + neopopl=popl; + + //on pompe l'archive + setPopMode(archiveLow,false); + setPopMode(archiveUp,true); + setPopMode(popu,true); + if (archiveUp.size()>1) + selectU.setup(archiveUp); + if (archiveLow.size()>1) + selectL.setup(archiveLow); + unsigned int boucle=nbFromArc; + if (boucle> archiveUp.size()) boucle=archiveUp.size(); + if (boucle> archiveLow.size()) boucle=archiveLow.size(); + for (unsigned int i=0;i _pop.size()){ + std::sort(archiveUp.begin(),archiveUp.end(),fitcomp); + archiveUp.resize(_pop.size()); + } + if(archiveLow.size()> _pop.size()){ + std::sort(archiveLow.begin(),archiveLow.end(),fitcomp); + archiveLow.resize(_pop.size()); + } + + neopopu.sort(); + std::unique(neopopu.begin(),neopopu.end()); + eoPoppopuclean; + for (unsigned int i=0;ipoplclean; + for (unsigned int i=0;i +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +template +class beoBLAISArchivetemp: public eoAlgo { + public: + typedef typename BEOT::U U; + typedef typename BEOT::L L; + typedef typename BEOT::Fitness Fitness; + typedef typename U::Fitness FitnessU; + typedef typename L::Fitness FitnessL; + + beoBLAISArchivetemp( + eoAlgo&, + eoAlgo&, + eoEvalFunc&, + beoCoevoPop&, + eoContinue&, + eoContinue&, + eoSelectOne&, + eoSelectOne&, + eoReplacement&, + unsigned int, + eoRng &_rng + ); + + void operator()(eoPop &_pop); + private: + struct s_fitcomp{ + bool operator()(const BEOT& b1, const BEOT& b2){ + return b1.upper().fitness()>b2.upper().fitness(); + } + }fitcomp; + eoAlgo& algoU; + eoAlgo& algoL; + eoEvalFunc& eval; + beoCoevoPop& coevo; + eoContinue& contL; + eoContinue& contU; + eoSelectOne& selectU; + eoSelectOne& selectL; + eoReplacement &merge; + unsigned int nbFromArc; + eoRng &rng; + + void setPopMode(eoPop &_pop, bool mode){ + for (unsigned int i=0;i< _pop.size(); i++){ + _pop[i].setMode(mode); + _pop[i].invalidate(); + eval(_pop[i]); + } + } + + void archiveBest(eoPop &_pop,eoPop &_archive, bool level){ + _archive.sort(); + bool empty=_archive.empty(); + for (unsigned int i=0;i<_pop.size();i++){ + typename BEOT::U up=_pop[i].upper(); + typename BEOT::L low=_pop[i].lower(); + if(empty) { + _archive.push_back(_pop[i]); + empty=false; + } + else{ + bool ok=true; + for (unsigned int j=0;j<_archive.size();j++){ + if ((level && _archive[j].lower()==low)||(!level && _archive[j].upper()==up)){ + ok=false; + break; + } + } + if(ok) + _archive.push_back(_pop[i]); + } + + } + } + +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/beoBLAISArchivetemp.cpp b/branches/contribution/branches/bilevel/src/beoBLAISArchivetemp.cpp new file mode 100644 index 000000000..3c76c02a8 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoBLAISArchivetemp.cpp @@ -0,0 +1,199 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +// +//Coevolutionary bilevel method using repeated algorithms (CoBRA) +//algorithm to solve bilevel problems +#include +#include + +template +beoBLAISArchivetemp::beoBLAISArchivetemp( + eoAlgo& _au, + eoAlgo& _al, + eoEvalFunc< BEOT>&_eval, + beoCoevoPop< BEOT> &_coevo, + eoContinue< BEOT> &_contL, + eoContinue< BEOT> &_contU, + eoSelectOne& _selectU, + eoSelectOne& _selectL, + eoReplacement &_merge, + unsigned int _nbFromArc=20, + eoRng &_rng=eo::rng + ): + algoU(_au), + algoL(_al), + eval(_eval), + coevo(_coevo), + contL(_contL), + contU(_contU), + selectU(_selectU), + selectL(_selectL), + merge(_merge), + nbFromArc(_nbFromArc), + rng(_rng) +{} + + + +template +void beoBLAISArchivetemp::operator()(eoPop &_pop){ + unsigned taille=_pop.size(); + for (unsigned int i=0;i<_pop.size();i++){ + eval(_pop[i]); + } + + eoPop archiveUp; + moeoUnboundedArchive archiveLow; + eoPop neopopl; + eoPop neopopu; + eoPop popu=_pop; + eoPop popl=_pop; + + setPopMode(popl,false); + setPopMode(popu,true); + algoU(popu); + setPopMode(popu,true); + algoL(popl); + bool continu=contU(popu); + bool continl=contL(popl); + + while(continu && continl){ + //on eval les pop, on copie + setPopMode(popl,false); + setPopMode(popu,true); + neopopu=popu; + neopopl=popl; + + //on pompe l'archive + setPopMode(archiveLow,false); + setPopMode(archiveUp,true); + setPopMode(popu,true); + if (archiveUp.size()>1) + selectU.setup(archiveUp); + if (archiveLow.size()>1) + selectL.setup(archiveLow); + unsigned int boucle=nbFromArc; + if (boucle> archiveUp.size()) boucle=archiveUp.size(); + if (boucle> archiveLow.size()) boucle=archiveLow.size(); + for (unsigned int i=0;i _pop.size()){ + archiveUp.sort(); + archiveUp.resize(_pop.size()); + } + if(archiveLow.size()> _pop.size()){ + std::sort(archiveLow.begin(),archiveLow.end(),fitcomp); + archiveLow.resize(_pop.size()); + } + + neopopu.sort(); + std::unique(neopopu.begin(),neopopu.end()); + eoPoppopuclean; + for (unsigned int i=0;ipoplclean; + for (unsigned int i=0;i +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +template +class beoBLAISArchivetemp: public eoAlgo { + public: + typedef typename BEOT::U U; + typedef typename BEOT::L L; + typedef typename BEOT::Fitness Fitness; + typedef typename U::Fitness FitnessU; + typedef typename L::Fitness FitnessL; + + beoBLAISArchivetemp( + eoAlgo&, + eoAlgo&, + eoEvalFunc&, + beoCoevoPop&, + eoContinue&, + eoContinue&, + eoSelectOne&, + eoSelectOne&, + eoReplacement&, + unsigned int, + eoRng &_rng + ); + + void operator()(eoPop &_pop); + private: + struct s_fitcomp{ + bool operator()(const BEOT& b1, const BEOT& b2){ + return b1.upper().fitness()>b2.upper().fitness(); + } + }fitcomp; + eoAlgo& algoU; + eoAlgo& algoL; + eoEvalFunc& eval; + beoCoevoPop& coevo; + eoContinue& contL; + eoContinue& contU; + eoSelectOne& selectU; + eoSelectOne& selectL; + eoReplacement &merge; + unsigned int nbFromArc; + eoRng &rng; + + void setPopMode(eoPop &_pop, bool mode){ + for (unsigned int i=0;i< _pop.size(); i++){ + _pop[i].setMode(mode); + _pop[i].invalidate(); + eval(_pop[i]); + } + } + + void archiveBest(eoPop &_pop,eoPop &_archive, bool level){ + _archive.sort(); + bool empty=_archive.empty(); + for (unsigned int i=0;i<_pop.size();i++){ + typename BEOT::U up=_pop[i].upper(); + typename BEOT::L low=_pop[i].lower(); + if(empty) { + _archive.push_back(_pop[i]); + empty=false; + } + else{ + bool ok=true; + for (unsigned int j=0;j<_archive.size();j++){ + if ((level && _archive[j].lower()==low)||(!level && _archive[j].upper()==up)){ + ok=false; + break; + } + } + if(ok) + _archive.push_back(_pop[i]); + } + + } + } + +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/beoCoevoAllPop.h b/branches/contribution/branches/bilevel/src/beoCoevoAllPop.h new file mode 100644 index 000000000..0701d463b --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoCoevoAllPop.h @@ -0,0 +1,61 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//beoCoevoAllPop applies a coevolution operator to all couples of individuals of pop1xpop2 +//then copy the results in both population +template class beoCoevoAllPop: public beoCoevoPop{ + public: + beoCoevoAllPop(beoCoevoOp &_op):op(_op){} + + void operator()(eoPop &_pop1, eoPop &_pop2){ + unsigned int size1=_pop1.size(); + unsigned int size2=_pop2.size(); + + for (unsigned int i=0;i &op; +}; diff --git a/branches/contribution/branches/bilevel/src/beoCoevoLinePop.h b/branches/contribution/branches/bilevel/src/beoCoevoLinePop.h new file mode 100644 index 000000000..1a79abb1b --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoCoevoLinePop.h @@ -0,0 +1,57 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//---------------------------------------------------------------------------- +//random coevolution operator +//acts on all individuals in the population +template class beoCoevoLinePop: public beoCoevoPop{ + public: + beoCoevoLinePop(beoCoevoOp &_op, unsigned int _number=0):op(_op), number(_number){} + + void operator()(eoPop &_pop1, eoPop &_pop2){ + _pop1.shuffle(); + _pop2.shuffle(); + unsigned int minsize=_pop1.size(); + if (minsize>_pop2.size()) minsize=_pop2.size(); + if ((number> 0) && (minsize>number)) minsize=number; + _pop2.resize(minsize); + _pop1.resize(minsize); + for (unsigned int i=0;i &op; + unsigned int number; +}; diff --git a/branches/contribution/branches/bilevel/src/beoCoevoOp.h b/branches/contribution/branches/bilevel/src/beoCoevoOp.h new file mode 100644 index 000000000..06dd350fd --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoCoevoOp.h @@ -0,0 +1,43 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//coevolution operator to use in BLAIS +#ifndef BEOCOEVOOP_H_ +#define BEOCOEVOOP_H_ +#include + +template class beoCoevoOp +: public eoBF< BEOT &, BEOT &, bool > +{}; +#endif diff --git a/branches/contribution/branches/bilevel/src/beoCoevoPop.h b/branches/contribution/branches/bilevel/src/beoCoevoPop.h new file mode 100644 index 000000000..f1fc78ec8 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoCoevoPop.h @@ -0,0 +1,42 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//coevolutionary operator to use on populations +#ifndef BEOCOEVOPOP_H_ +#define BEOCOEVOPOP_H_ +template class beoCoevoPop{ + public: + virtual void operator()(eoPop&, eoPop&)=0; +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/beoDummyCoevoPop.h b/branches/contribution/branches/bilevel/src/beoDummyCoevoPop.h new file mode 100644 index 000000000..2d9292e49 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoDummyCoevoPop.h @@ -0,0 +1,43 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//dummy coevolutionary operator +#include +template +class beoDummyCoevoPop: public beoCoevoPop{ + public: + void operator()(eoPop &a, eoPop&b){ + std::cout<<" "; + } +}; diff --git a/branches/contribution/branches/bilevel/src/beoEval.h b/branches/contribution/branches/bilevel/src/beoEval.h new file mode 100644 index 000000000..4bfc748f0 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoEval.h @@ -0,0 +1,71 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//evaluator for bilevel problems using a differente operator for each level +#include +#include +template class beoEval: public eoEvalFunc{ + + public: + + beoEval(eoEvalFunc &_evalL,eoEvalFunc &_evalU): evalL(_evalL),evalU(_evalU){} + + + void operator()(BEOT &_beot){ + bool mode=_beot.getMode(); + if (_beot.invalid()){ + nbEval++; + _beot.setMode(false); + evalL(_beot); + _beot.setMode(true); + evalU(_beot); + } + if(mode){ + _beot.fitness(_beot.upper().fitness()); + } + else{ + if (!_beot.lower().invalidFitness()) + _beot.fitness(_beot.lower().fitness()); + } + _beot.setMode(mode); + } + + int nbEval; + + + private: + eoEvalFunc &evalL; + eoEvalFunc &evalU; + +}; diff --git a/branches/contribution/branches/bilevel/src/beoInit.h b/branches/contribution/branches/bilevel/src/beoInit.h new file mode 100644 index 000000000..0e87f4700 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoInit.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//initializer for bilevel solutions using a different initializers for each level +#ifndef BEOINIT_H_ +#define BEOINIT_H_ +#include +template class beoInit: public eoInit{ + public: + beoInit(eoInit & _initu, eoInit& _initl): + initu(_initu),initl(_initl) + {} + + void operator()(BEOT &_b){ + initu(_b.upper()); + initl(_b); + } + + private: + eoInit &initu; + eoInit &initl; +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/beoLexContinue.h b/branches/contribution/branches/bilevel/src/beoLexContinue.h new file mode 100644 index 000000000..c174d22b0 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoLexContinue.h @@ -0,0 +1,96 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//continuator stopping when no improvment was made during a parametrized number of generation +#include +template +class beoLexContinue: public eoSteadyFitContinue{ + public: + typedef typename BEOT::Fitness Fitness; + using eoSteadyFitContinue::steadyState; + using eoSteadyFitContinue::thisGeneration; + using eoSteadyFitContinue::lastImprovement; + using eoSteadyFitContinue::repSteadyGenerations; + using eoSteadyFitContinue::repMinGenerations; + + beoLexContinue( unsigned long _minGens, unsigned long _steadyGens,bool _onlyup=true):eoSteadyFitContinue(_minGens,_steadyGens),onlyup(_onlyup){} + + beoLexContinue( unsigned long _minGens, unsigned long _steadyGen,unsigned long& _currentGen,bool _onlyup=true): + eoSteadyFitContinue(_minGens,_steadyGen,_currentGen),onlyup(_onlyup) + {} + virtual bool operator()(const eoPop &pop){ + thisGeneration++; + + Fitness bestCurrentUpFitness = pop[0].upper().fitness(); + Fitness bestCurrentLowFitness = onlyup?0:pop[0].lower().fitness(); + for (unsigned int i=1;ibestCurrentUpFitness + || + (pop[i].upper().fitness()==bestCurrentUpFitness + &&(onlyup|| pop[i].lower().fitness()>bestCurrentLowFitness))){ + bestCurrentUpFitness=pop[i].upper().fitness(); + bestCurrentLowFitness=onlyup?0:pop[i].lower().fitness(); + } + } + + + if (steadyState){ + if (bestCurrentUpFitness > bestUpSoFar || (bestCurrentUpFitness==bestUpSoFar && bestCurrentLowFitness>bestLowSoFar)){ + bestUpSoFar = bestCurrentUpFitness; + bestLowSoFar = bestCurrentLowFitness; + lastImprovement = thisGeneration; + }else{ + if(thisGeneration-lastImprovement>repSteadyGenerations){ + return false; + } + } + } else { + if (thisGeneration > repMinGenerations) { + steadyState = true; + bestUpSoFar = bestCurrentUpFitness; + bestLowSoFar = bestCurrentLowFitness; + lastImprovement = thisGeneration; + } + } + return true; + } + + Fitness bestUpSoFar; + Fitness bestLowSoFar; + bool onlyup; + + + +}; + diff --git a/branches/contribution/branches/bilevel/src/beoLowComparator.h b/branches/contribution/branches/bilevel/src/beoLowComparator.h new file mode 100644 index 000000000..62a314588 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoLowComparator.h @@ -0,0 +1,47 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//Comparator adaptator, to compare 2 bilevel soltuion along their lower level +#ifndef BEO_BEOLOWCOMPARATOR_H_ +#define BEO_BEOLOWCOMPARATOR_H_ +template class beoLowComparator:public moeoObjectiveVectorComparator{ + public: + beoLowComparator(moeoObjectiveVectorComparator &_comp):comp(_comp){} + const bool operator()(const OBJ& a, const OBJ& b){ + return comp(a.low(),b.low()); + } + private: + moeoObjectiveVectorComparator ∁ +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/beoLowMut.h b/branches/contribution/branches/bilevel/src/beoLowMut.h new file mode 100644 index 000000000..b706c0029 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoLowMut.h @@ -0,0 +1,58 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//Mutation adaptator, to mutate a bilevel solution along its lower level +#include +#include + +template +class beoLowMut : public eoMonOp{ + public: + typedef typename BEOT::L L; + beoLowMut(eoMonOp &_monl):monl(_monl){} + bool operator()(BEOT &l1){ + + if (monl(l1.lower())){ + l1.invalidate(); + l1.upper().invalidate(); + l1.lower().invalidate(); + return true; + } + return false; + } + private: + eoMonOp &monl; + + +}; diff --git a/branches/contribution/branches/bilevel/src/beoLowQuad.h b/branches/contribution/branches/bilevel/src/beoLowQuad.h new file mode 100644 index 000000000..cc4e57539 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoLowQuad.h @@ -0,0 +1,60 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//Quadratic operator adaptator, to cross 2 bilevel solutions along their lower level +#include +#include + +template +class beoLowQuad : public eoQuadOp{ + public: + typedef typename BEOT::L L; + beoLowQuad(eoQuadOp &_quadl):quadl(_quadl){} + bool operator()(BEOT &l1, BEOT &l2){ + if(quadl(l1.lower(),l2.lower())){ + l1.invalidate(); + l1.upper().invalidate(); + l1.lower().invalidate(); + l2.invalidate(); + l2.upper().invalidate(); + l2.lower().invalidate(); + return true; + } + return false; + } + private: + eoQuadOp &quadl; + + +}; diff --git a/branches/contribution/branches/bilevel/src/beoObjectiveVector.h b/branches/contribution/branches/bilevel/src/beoObjectiveVector.h new file mode 100644 index 000000000..0a13e2000 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoObjectiveVector.h @@ -0,0 +1,181 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//Objective Vector for bilevel problems +#ifndef BEO_OBJECTIVEVECTOR_H_ +#define BEO_OBJECTIVEVECTOR_H_ +#include +#include +template class beoObjectiveVector{ + + public: + typedef ObjectUp ObjUp; + typedef ObjectLow ObjLow; + typedef moeoObjectiveVectorTraits Traits; + beoObjectiveVector():regle(false){} + + + + /** + * doesnt do a thing + */ + static void setup(unsigned int nobj,std::vector &_bobjectives){ + } + + /** + * return the size of the mode flag level objective + */ + unsigned int size()const { + if(mode()) + return up().size(); + else + return low().size(); + } + /** + * return the [] result of the mode flag level variable + **/ + double & operator[](unsigned int i){ + if (mode()) + return up()[i]; + else{ + return low()[i]; + } + } + /** + * return the [] result of the mode flag level variable + **/ + const double & operator[](unsigned int i)const { + if (mode()) + return up()[i]; + else{ + return low()[i]; + } + } + + /** + * return the number of objective of the lower level + */ + static unsigned int nObjectives(){ + return ObjLow::nObjectives(); + } + /** + * return true if the lower level is to be minimized + */ + static bool minimizing(unsigned int i){ + return ObjLow::minimizing(i); + } + /** + * return true if the lower level is to be maximized + */ + static bool maximizing(unsigned int i){ + return ObjLow::maximizing(i); + } + + /** + * return the upper part of the objective + **/ + ObjectUp &up(){ + return mup; + } + /** + * return the lower part of the objective + **/ + ObjectLow &low(){ + return mlow; + } + /** + * return the upper part of the objective + **/ + const ObjectUp &up()const{ + return mup; + } + /** + * return the lower part of the objective + **/ + const ObjectLow &low()const{ + return mlow; + } + /** + * return the upper part of the objective + **/ + void upset(const ObjectUp &_up){ + mup=_up; + } + /** + * sets the lower part of the objective + **/ + void lowset(const ObjectLow &_low){ + regle=true; + mlow=_low; + } + /** + * returns the mode flag + */ + bool mode() const{ + return false; + } + /** + * sets the mode flag + */ + void mode(bool _mode){ + flag=_mode; + } + /** + * return true if different + */ + bool operator!=(const beoObjectiveVector &_vec)const{ + return !operator==(_vec); + } + /** + * return true if both of the level are equal + */ + bool operator==(const beoObjectiveVector &_vec)const{ + return _vec.up()==up() && _vec.low()==low(); + } + + + + private: + ObjectUp mup; + ObjectLow mlow; + bool flag; + bool regle; +}; +template std::istream & operator>>(std::istream & _is,beoObjectiveVector &_be){ + return _is; +} +template std::ostream & operator<<(std::ostream & _os,const beoObjectiveVector &_be){ + return _os; +} +#endif diff --git a/branches/contribution/branches/bilevel/src/beoObjectiveVectorTraits.h b/branches/contribution/branches/bilevel/src/beoObjectiveVectorTraits.h new file mode 100644 index 000000000..fd9eec2f0 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoObjectiveVectorTraits.h @@ -0,0 +1,64 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//traits for bilevel problem objective vector +#ifndef BEO_OBJECTIVEVECTORTRAITS_H_ +#define BEO_OBJECTIVEVECTORTRAITS_H_ +#include +#include +#include +#include +template class beoObjectiveVectorTraits: public moeoObjectiveVectorTraits{ + public: + static bool minimizing (int _i){ + if(mode()) + return UpTrait::minimizing(_i); + else + return LowTrait::minimizing(_i); + } + static bool maximizing (int _i){ + if(mode()) + return UpTrait::maximizing(_i); + else + return LowTrait::maximizing(_i); + } + static unsigned int nObjectives (){ + return mode()?UpTrait::nObjectives():LowTrait::nObjectives(); + } + virtual static void mode(bool _mode)=0; + virtual static bool mode()=0; +}; + + +#endif diff --git a/branches/contribution/branches/bilevel/src/beoRepairEval.h b/branches/contribution/branches/bilevel/src/beoRepairEval.h new file mode 100644 index 000000000..772da1a41 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoRepairEval.h @@ -0,0 +1,64 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//evaluator which apply an algorithme before the evaluation +//to use to follow the hierarchical scheme +#include +#include +template class beoRepairEval: public eoEvalFunc{ + public: + beoRepairEval(eoEvalFunc &_eval,eoAlgo &_repair): eval(_eval),repair(_repair){} + void operator()(BEOT &_beot){ + eoPop pop; + for (int i=0;i<100;i++) + pop.push_back(_beot); + repair(pop); + eval(pop[0]); + double best=pop[0].lower().fitness(); + _beot.lower()=pop[0].lower(); + for (int i=0;i &eval; + eoAlgo &repair; + + +}; diff --git a/branches/contribution/branches/bilevel/src/beoSelectCoevoPop.h b/branches/contribution/branches/bilevel/src/beoSelectCoevoPop.h new file mode 100644 index 000000000..2339a5da3 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoSelectCoevoPop.h @@ -0,0 +1,71 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//beoSelectCoevoPop selects a part of two population and then co-evolute them together +template +class beoSelectCoevoPop: public beoCoevoPop{ + public: + beoSelectCoevoPop( + eoSelect &_select1, + eoSelect &_select2, + beoCoevoOp &_op): + select1(_select1), + select2(_select2), + op(_op), + poper(op) + {} + + beoSelectCoevoPop( + eoSelect &_select1, + beoCoevoOp &_op): + select1(_select1), + select2(_select1), + op(_op), + poper(op) + {} + void operator()(eoPop &_pop1,eoPop &_pop2){ + eoPop res1,res2; + select1(_pop1,res1); + select2(_pop2,res2); + poper(res1,res2); + _pop1=res1; + _pop2=res2; + } + private: + eoSelect &select1; + eoSelect &select2; + beoCoevoOp &op; + beoCoevoAllPop poper; + +}; diff --git a/branches/contribution/branches/bilevel/src/beoSelectLow.h b/branches/contribution/branches/bilevel/src/beoSelectLow.h new file mode 100644 index 000000000..3aba87ce2 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoSelectLow.h @@ -0,0 +1,56 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//selector adaptator to select along the lower level +#ifndef BEOSELECTLOW_H_ +#define BEOSELECTLOW_H_ +#include + +template +class beoSelectLow{ + + public: + beoSelectLow(eoSelect &_select):select(_select){} + + void operator()(eoPop & _pop, eoPop & _dest){ + for (unsigned int i=0;i<_pop.size();i++){ + _pop[i].fitness(_pop[i].lower().fitness()); + } + return select(_pop,_dest); + } + + private: + eoSelect &select; +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/beoSelectOneLow.h b/branches/contribution/branches/bilevel/src/beoSelectOneLow.h new file mode 100644 index 000000000..696d2c90e --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoSelectOneLow.h @@ -0,0 +1,56 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//Individual selector adaptator to select along the lower level +#ifndef BEOSELECTONELOW_H_ +#define BEOSELECTONELOW_H_ +#include + +template +class beoSelectOneLow: public eoSelectOne{ + + public: + beoSelectOneLow(eoSelectOne &_select):select(_select){} + virtual void setup (const eoPop< BEOT > &_pop){ + select.setup(_pop); + } + + const BEOT& operator()(const eoPop & _pop){ + return select(_pop); + } + + private: + eoSelectOne &select; +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/beoSelectOneUp.h b/branches/contribution/branches/bilevel/src/beoSelectOneUp.h new file mode 100644 index 000000000..2f6d7a740 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoSelectOneUp.h @@ -0,0 +1,56 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//Individual selector adaptator to select along the upper level +#ifndef BEOSELECTONEUP_H_ +#define BEOSELECTONEUP_H_ +#include + +template +class beoSelectOneUp: public eoSelectOne{ + + public: + beoSelectOneUp(eoSelectOne &_select):select(_select){} + + virtual void setup (const eoPop< BEOT > &_pop){ + select.setup(_pop); + } + const BEOT& operator()(const eoPop & _pop){ + return select(_pop); + } + + private: + eoSelectOne &select; +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/beoSelectUp.h b/branches/contribution/branches/bilevel/src/beoSelectUp.h new file mode 100644 index 000000000..bcdff8cd0 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoSelectUp.h @@ -0,0 +1,56 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//sectector adaptator to select along the upper level +#ifndef BEOSELECTUP_H_ +#define BEOSELECTUP_H_ +#include + +template +class beoSelectUp{ + + public: + beoSelectUp(eoSelect &_select):select(_select){} + + void operator()(eoPop & _pop, eoPop & _dest){ + for (unsigned int i=0;i<_pop.size();i++){ + _pop[i].fitness(_pop[i].upper().fitness()); + } + return select(_pop,_dest); + } + + private: + eoSelect &select; +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/beoUpComparator.h b/branches/contribution/branches/bilevel/src/beoUpComparator.h new file mode 100644 index 000000000..f3bc36e36 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoUpComparator.h @@ -0,0 +1,47 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//Comparator adaptator to compare along the upper level +#ifndef BEO_BEOUPCOMPARATOR_H_ +#define BEO_BEOUPCOMPARATOR_H_ +template class beoUpComparator:public moeoComparator{ + public: + beoUpComparator(moeoComparator &_comp):comp(_comp){} + bool operator()(const BEOT& a, const BEOT& b){ + return comp(a.upper(),b.upper()); + } + private: + moeoComparator ∁ +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/beoUpMut.h b/branches/contribution/branches/bilevel/src/beoUpMut.h new file mode 100644 index 000000000..b28723eb0 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoUpMut.h @@ -0,0 +1,56 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//Mutation operatorr adaptator to mutate along the upper level +#include +#include + +template +class beoUpMut : public eoMonOp{ + public: + typedef typename BEOT::U U; + beoUpMut(eoMonOp &_monu):monu(_monu){} + bool operator()(BEOT &u1){ + + if (monu(u1.upper())){ + u1.invalidate(); + return true; + } + return false; + } + private: + eoMonOp &monu; + + +}; diff --git a/branches/contribution/branches/bilevel/src/beoUpQuad.h b/branches/contribution/branches/bilevel/src/beoUpQuad.h new file mode 100644 index 000000000..2c73fcd55 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/beoUpQuad.h @@ -0,0 +1,60 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//Quadratic operator adaptator to cross along the upper level +#include +#include + +template +class beoUpQuad : public eoQuadOp{ + public: + typedef typename BEOT::U U; + beoUpQuad(eoQuadOp &_quadu):quadu(_quadu){} + bool operator()(BEOT &u1, BEOT &u2){ + if(quadu(u1.upper(),u2.upper())){ + u1.invalidate(); + u1.upper().invalidate(); + u1.lower().invalidate(); + u2.invalidate(); + u2.upper().invalidate(); + u2.lower().invalidate(); + return true; + } + return false; + } + private: + eoQuadOp &quadu; + + +}; diff --git a/branches/contribution/branches/bilevel/src/biVRP.h b/branches/contribution/branches/bilevel/src/biVRP.h new file mode 100644 index 000000000..30044bfae --- /dev/null +++ b/branches/contribution/branches/bilevel/src/biVRP.h @@ -0,0 +1,14 @@ +#ifndef BIVRP_H_ +#define BIVRP_H_ +#include +#include +#include + +class biVRP:public BEO { + public: + biVRP():BEO(){} + biVRP(VRP2 & vrp, PLA &pla):BEO(vrp,pla){} + + +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/biVRPDistMat.cpp b/branches/contribution/branches/bilevel/src/biVRPDistMat.cpp new file mode 100644 index 000000000..9e270adfb --- /dev/null +++ b/branches/contribution/branches/bilevel/src/biVRPDistMat.cpp @@ -0,0 +1,201 @@ +#include +#include +#include +#include +#include +#include +#include + +void biVRPDistMat::load(const std::string _fname){ + std::string buf; + std::ifstream file(_fname.data()); + if (file.is_open()){ + int type; + file >> type; + if (type!=8){ + std::cout<<"pas un bimdvrp"<>vehicleNumber; + file>>retailerNumber; + file>>depotNumber; + file>>plantNumber; + file>>durationMax; + file>>loadMax; + vehicleNumber*=depotNumber; + retailerDistance.resize(retailerNumber*(retailerNumber+1)/2); + depotRetailDistance.resize(retailerNumber*depotNumber); + depotPlantDistance.resize(plantNumber*depotNumber); + nearestDepot.resize(retailerNumber); + plantNearestDepot.resize(plantNumber); + classement.resize(retailerNumber); + + for(unsigned int i=1;i>dur; + file>>load; + if (dur!=durationMax || load!=loadMax) + std::cout<<"ne gere pas les durées max ou les charge max multiples("< > coords; + for (unsigned int i=0;icoord; + double x,y,dump,demand; + double n; + double neocb; + file>>dump; + file>>x; + file>>y; + coord.push_back(x); + coord.push_back(y); + coords.push_back(coord); + file>>dump; + file>>demand; + file>>neocb; + file>>n; + if (i=retailerNumber+depotNumber && i>dump; + + + + } + for (unsigned int i=0;i biVRPDistMat::getOrder(unsigned int retail){ + return classement[retail]; +} +std::multiset biVRPDistMat::getOrderPlant(unsigned int plant){ + return plantNearestDepot[plant]; +} +std::multiset biVRPDistMat::nearDepot(unsigned int i){ + return nearestDepot[i]; +} +unsigned int biVRPDistMat::indexret(unsigned int _a,unsigned int _b){ + int a,b; + if (_b<_a){ + a=_a; + b=_b; + }else{ + a=_b; + b=_a; + } + return b*numberOfRetailer()+a - (b*(b+1)/2); +} + + +double biVRPDistMat::computeDist(double xa,double ya,double xb,double yb){ + double dist; + dist=sqrt(pow(xa-xb,2)+pow(ya-yb,2)); + return dist; +} + diff --git a/branches/contribution/branches/bilevel/src/biVRPDistMat.h b/branches/contribution/branches/bilevel/src/biVRPDistMat.h new file mode 100644 index 000000000..5cc7e39b3 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/biVRPDistMat.h @@ -0,0 +1,68 @@ +#ifndef BIVRPDISTMAT_H +#define BIVRPDISTMAT_H +#include +#include +#include +#include +#include +#include +#include +class biVRPDistMat :public DistMat{ +public: + void load(const std::string); + unsigned int numberOfVehicle(); + unsigned int numberOfDepot(); + unsigned int numberOfRetailer(); + unsigned int numberOfPlant(); + bool isConstantDemand(); + bool isConstantCapacity(); + double demand(unsigned int); + double availability(unsigned int); + + double distance(unsigned int,unsigned int); + double depotDistance(unsigned int,unsigned int); + double plantDepotDistance(unsigned int,unsigned int); + double maxLoad(); + double maxDuration(); + + double charge(unsigned int); + + typedef std::pair ty; + virtual std::multiset getOrder(unsigned int); + std::multiset nearDepot(unsigned int); + std::multiset getOrderPlant(unsigned int); + double cbOfPlant(unsigned int); + double ccOfPlant(unsigned int); +private: + unsigned int vehicleNumber; + unsigned int depotNumber; + unsigned int plantNumber; + unsigned int retailerNumber; + bool constantDemand; + double loadMax; + double durationMax; + std::vector retailerDemand; + bool constantCapacity; + std::vector vehicleCapacity; + std::vector plantAvailability; + unsigned int indexret(unsigned int _a,unsigned int _b); + double computeDist(double,double,double,double); + std::vector cb; + std::vector cc; + + //vecteurs de distance + std::vector retailerDistance; + std::vector depotRetailDistance ; + std::vector depotPlantDistance ; + + + //classement des distances + std::vector > classement; + std::vector > plantNearestDepot; + std::vector > nearestDepot; + +}; + + +#endif + diff --git a/branches/contribution/branches/bilevel/src/biVRPInit.h b/branches/contribution/branches/bilevel/src/biVRPInit.h new file mode 100644 index 000000000..994c39946 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/biVRPInit.h @@ -0,0 +1,19 @@ +#include +#include +#include +class biVRPInit : public eoInit{ + public: + biVRPInit(DistMat& _mat):mat(_mat), initpla(mat), initNN(mat),initVRP(initNN),initbeo(initVRP,initpla) {} + biVRPInit(DistMat& _mat,eoInit &_initVRP):mat(_mat), initpla(mat), initNN(mat), initVRP(_initVRP),initbeo(initVRP,initpla) {} + void operator()(biVRP &_vrp){ + _vrp.upper().init(mat); + _vrp.lower().init(mat); + initbeo(_vrp); + } + private: + DistMat &mat; + PLAInitResp initpla; + VRP2InitNN initNN; + eoInit &initVRP; + beoInit initbeo; +}; diff --git a/branches/contribution/branches/bilevel/src/biVRPLowEval.h b/branches/contribution/branches/bilevel/src/biVRPLowEval.h new file mode 100644 index 000000000..014d74f93 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/biVRPLowEval.h @@ -0,0 +1,34 @@ +#include +#include +#include +#include + +class biVRPLowEval: public eoEvalFunc{ + public: + biVRPLowEval(DistMat & _mat,double _lambda=1000.):mat(_mat),lambda(_lambda){} + + + void operator()(biVRP &_vrp){ + double res=0; + _vrp.lower().repairPlants(); + for (unsigned int i=0;i +class biVRPPerf2Worth: public eoPerf2WorthCached{ + using eoPerf2WorthCached::value; + virtual void calculate_worths(const eoPop &_pop){ + value().resize(_pop.size()); + for (unsigned int i=0;i<_pop.size();i++){ + value()[i]=1/(-_pop[i].fitness()); + } + } +}; diff --git a/branches/contribution/branches/bilevel/src/biVRPUpEval.h b/branches/contribution/branches/bilevel/src/biVRPUpEval.h new file mode 100644 index 000000000..784b5d258 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/biVRPUpEval.h @@ -0,0 +1,29 @@ +#include +#include +#include + +class biVRPUpEval: public eoEvalFunc{ + public: + biVRPUpEval(DistMat & _mat):mat(_mat){} + + + void operator()(biVRP &_vrp){ + VRP2Eval evalup(mat); + evalup(_vrp.upper()); + double neofit=-_vrp.upper().fitness(); + for (unsigned int i=0;i +#include +#include +#include +#include +#include +#include + +void mbiVRPDistMat::load(const std::string _fname){ + std::string buf; + std::ifstream file(_fname.data()); + if (file.is_open()){ + int type; + file >> type; + if (type!=10){ + std::cout<<"pas un mbimdvrp"<>vehicleNumber; + file>>retailerNumber; + file>>depotNumber; + file>>plantNumber; + file>>durationMax; + file>>loadMax; + vehicleNumber*=depotNumber; + retailerDistance.resize(retailerNumber*(retailerNumber+1)/2); + depotRetailDistance.resize(retailerNumber*depotNumber); + depotPlantDistance.resize(plantNumber*depotNumber); + nearestDepot.resize(retailerNumber); + plantNearestDepot.resize(plantNumber); + classement.resize(retailerNumber); + + + for(unsigned int i=1;i>dur; + file>>load; + if (dur!=durationMax || load!=loadMax) + std::cout<<"ne gere pas les durées max ou les charge max multiples("< > coords; + for (unsigned int i=0;icoord; + double x,y,dump,demand; + double n; + double neocb; + file>>dump; + file>>x; + file>>y; + coord.push_back(x); + coord.push_back(y); + coords.push_back(coord); + file>>dump; + file>>demand; + file>>neocb; + file>>n; + if (i=retailerNumber+depotNumber && i>neocd; + cb.push_back(neocb); + cc.push_back(neocc); + cd.push_back(neocd); + } + else for (unsigned int j=0;j>dump; + + + + } + for (unsigned int i=0;i mbiVRPDistMat::getOrder(unsigned int retail){ + return classement[retail]; +} +std::multiset mbiVRPDistMat::getOrderPlant(unsigned int plant){ + return plantNearestDepot[plant]; +} +std::multiset mbiVRPDistMat::nearDepot(unsigned int i){ + return nearestDepot[i]; +} +unsigned int mbiVRPDistMat::indexret(unsigned int _a,unsigned int _b){ + int a,b; + if (_b<_a){ + a=_a; + b=_b; + }else{ + a=_b; + b=_a; + } + return b*numberOfRetailer()+a - (b*(b+1)/2); +} + + +double mbiVRPDistMat::computeDist(double xa,double ya,double xb,double yb){ + double dist; + dist=sqrt(pow(xa-xb,2)+pow(ya-yb,2)); + return dist; +} + diff --git a/branches/contribution/branches/bilevel/src/mbiVRPDistMat.h b/branches/contribution/branches/bilevel/src/mbiVRPDistMat.h new file mode 100644 index 000000000..bbc57dafe --- /dev/null +++ b/branches/contribution/branches/bilevel/src/mbiVRPDistMat.h @@ -0,0 +1,69 @@ +#ifndef MBIVRPDISTMAT_H +#define MBIVRPDISTMAT_H +#include +#include +#include +#include +#include +#include +#include +class mbiVRPDistMat :public DistMat{ +public: + void load(const std::string); + unsigned int numberOfVehicle(); + unsigned int numberOfDepot(); + unsigned int numberOfRetailer(); + unsigned int numberOfPlant(); + bool isConstantDemand(); + bool isConstantCapacity(); + double demand(unsigned int); + double availability(unsigned int); + + double distance(unsigned int,unsigned int); + double depotDistance(unsigned int,unsigned int); + double plantDepotDistance(unsigned int,unsigned int); + double maxLoad(); + double maxDuration(); + + + + std::multiset getOrder(unsigned int); + std::multiset nearDepot(unsigned int); + std::multiset getOrderPlant(unsigned int); + double cbOfPlant(unsigned int); + double ccOfPlant(unsigned int); + double cdOfPlant(unsigned int); +private: + unsigned int vehicleNumber; + unsigned int depotNumber; + unsigned int plantNumber; + unsigned int retailerNumber; + bool constantDemand; + double loadMax; + double durationMax; + std::vector retailerDemand; + bool constantCapacity; + std::vector vehicleCapacity; + std::vector plantAvailability; + unsigned int indexret(unsigned int _a,unsigned int _b); + double computeDist(double,double,double,double); + std::vector cb; + std::vector cc; + std::vector cd; + + //vecteurs de distance + std::vector retailerDistance; + std::vector depotRetailDistance ; + std::vector depotPlantDistance ; + + + //classement des distances + std::vector > classement; + std::vector > plantNearestDepot; + std::vector > nearestDepot; + +}; + + +#endif + diff --git a/branches/contribution/branches/bilevel/src/mbiVRPLowEval.h b/branches/contribution/branches/bilevel/src/mbiVRPLowEval.h new file mode 100644 index 000000000..381b25ad7 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/mbiVRPLowEval.h @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include +class mbiVRPLowEval: public eoEvalFunc{ + public: + mbiVRPLowEval(mbiVRPDistMat& _mat,double _lambda=1000.):mat(_mat),lambda(_lambda){} + + + void operator()(biVRP &_vrp){ + biVRP::ObjectiveVector vecres; + if (_vrp.invalidObjectiveVector()){ + _vrp.objectiveVector(vecres); + } + PLAObjectiveVector res; + res[0]=0; + res[1]=0; + _vrp.lower().repairPlants(); + for (unsigned int i=0;i +template class moeoSteadyContinue: public eoContinue{ + + + public: + moeoSteadyContinue(int _nbmin,int _nbmax,double _proportion=0.7):first(true),proportion(_proportion),nbmin(_nbmin),nbmax(_nbmax){} + bool operator()(const eoPop &_pop){ + static int count=0; + if(first){ + current=0; + steadystate=false; + for (int x=0;x<_pop.size();x++){ + ol.insert(_pop[x].objectiveVector()); + } + first=false; + lastimpr=0; + return true; + } + double countin=0; + double countall=0; + current++; + + for (int i=0;i<_pop.size();i++){ + if (ol.count(_pop[i].objectiveVector())!=0){ + countin++; + } + countall++; + } + ol.clear(); + for (int x=0;x<_pop.size();x++){ + ol.insert(_pop[x].objectiveVector()); + } + if((countin/countall)>proportion){ + first=true; + ol.clear(); + lastimpr=current; + } + return (current ol; + double proportion; + int current; + bool steadystate; + int lastimpr; + int nbmin; + int nbmax; + +}; + +#endif diff --git a/branches/contribution/branches/bilevel/src/op/PolynomialMutation.h b/branches/contribution/branches/bilevel/src/op/PolynomialMutation.h new file mode 100644 index 000000000..871ed0b0f --- /dev/null +++ b/branches/contribution/branches/bilevel/src/op/PolynomialMutation.h @@ -0,0 +1,123 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* 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 use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#ifndef POLYNOMIALMUTATION_H_ +#define POLYNOMIALMUTATION_H_ + +#include + +template class PolynomialMutation: public eoMonOp +{ +public: + + PolynomialMutation(eoRealVectorBounds & _bounds, const double& _p_mut = 0.5, const double& _eta = 1.0): + p_mut(_p_mut), eta(_eta), bounds(_bounds) {} + + /// The class name. + virtual std::string className() const { + return "PolynomialMutation"; + } + + /** + * Do it! + * @param _eo The indi undergoing the mutation + */ + bool operator()(EOT& _eo) + { + bool hasChanged=false; + double rnd, delta1, delta2, mut_pow, deltaq, delta_max; + double y, yl, yu, val, xy; + + for (unsigned j=0; j<_eo.size(); j++) + { + if (rng.flip(p_mut)) + { + y = _eo[j]; + + yl = bounds.minimum(j); + yu = bounds.maximum(j); + delta1 = (y-yl)/(yu-yl); + delta2 = (yu-y)/(yu-yl); + + + //Ajout + if ( (y-yl) > (yu-y)) + delta_max = delta2; + else + delta_max= delta1; + //fin ajout + + rnd = rng.uniform(); + mut_pow = 1.0/(eta+1.0); + if (rnd <= 0.5) + { + xy = 1.0-delta_max;//delta_max au lieu de delta1 + val = 2.0*rnd+(1.0-2.0*rnd)*(pow(xy,(eta+1.0))); + deltaq = pow(val,mut_pow) - 1.0; + } + else + { + xy = 1.0-delta_max;//delta_max au lieu de delta2 + val = 2.0*(1.0-rnd)+2.0*(rnd-0.5)*(pow(xy,(eta+1.0))); + deltaq = 1.0 - (pow(val,mut_pow)); + } + //ajout + if (deltaq > delta_max) + deltaq = delta_max; + else if (deltaq < -delta_max) + deltaq= -delta_max; + //fin ajout + y = y + deltaq*(yu-yl); + + bounds.truncate(j, y); + _eo[j] = y; + + hasChanged = true; + } + } + + return hasChanged; + } + +private: + double p_mut; + double eta; + eoRealVectorBounds & bounds; +}; + +#endif /*POLYNOMIALMUTATION_H_*/ diff --git a/branches/contribution/branches/bilevel/src/op/SBXCrossover.h b/branches/contribution/branches/bilevel/src/op/SBXCrossover.h new file mode 100644 index 000000000..0001818ed --- /dev/null +++ b/branches/contribution/branches/bilevel/src/op/SBXCrossover.h @@ -0,0 +1,194 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* 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 use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- + +#ifndef SBXCROSSOVER_H_ +#define SBXCROSSOVER_H_ + +#include // swap_ranges +#include +#include +#include +#include +#include + +template class SBXCrossover: public eoQuadOp +{ +public: + /**** + * (Default) Constructor. + * The bounds are initialized with the global object that says: no bounds. + * + * + */ + SBXCrossover(const double& _eta = 1.0) : + bounds(eoDummyVectorNoBounds), eta(_eta), range(1) {} + + + ////////////////////////////////////////////// + + /** + * Constructor with bounds + * @param _bounds an eoRealVectorBounds that contains the bounds + * @param _alphaMin the amount of exploration OUTSIDE the parents + * as in BLX-alpha notation (Eshelman and Schaffer) + * 0 == contractive application + * Must be positive + */ + + + + SBXCrossover(eoRealVectorBounds & _bounds, + const double& _eta = 1.0) : + bounds(_bounds), eta(_eta), range(1) {} + + /////////////////////////////////////////////// + + ////////////////////////////////////////////// + + /** + * Constructor from a parser. Will read from the argument parser + * eoRealVectorBounds that contains the bounds + * eta, the SBX parameter + */ + + SBXCrossover(eoParser & _parser) : + // First, decide whether the objective variables are bounded + // Warning, must be the same keywords than other possible objectBounds elsewhere + bounds (_parser.getORcreateParam(eoDummyVectorNoBounds, "objectBounds", "Bounds for variables", 'B', "Variation Operators").value()) , + // then get eta value + eta (_parser.getORcreateParam(1.0, "eta", "SBX eta parameter", '\0', "Variation Operators").value()) , + range(1) {} + +# define EPS 1.0e-14 + + /// The class name. + virtual std::string className() const { + return "SBXCrossover"; + } + + /***************************************** + * SBX crossover - modifies both parents * + * @param _eo1 The first parent * + * @param _eo2 The first parent * + *****************************************/ + bool operator()(EOT& _eo1, EOT& _eo2) + { + unsigned i; + double rand; + double y1, y2, yl, yu; + double c1, c2; + double alpha, beta, betaq; + bool changed = false; + + for (i=0; i<_eo1.size(); i++) + { + if (true) + { + if (fabs(_eo1[i] - _eo2[i]) > EPS) // pour éviter la division par 0 + { + // y2 doit être > à y1 + if (_eo1[i] < _eo2[i]) + { + y1 = _eo1[i]; + y2 = _eo2[i]; + } + else + { + y1 = _eo2[i]; + y2 = _eo1[i]; + } + yl = bounds.minimum(i); + yu = bounds.maximum(i); + + rand = rng.uniform(); + + beta = 1.0 + (2.0 * (y1 - yl) / (y2 - y1)); + alpha = 2.0 - pow( beta, -(eta + 1.0)); + if (rand <= (1.0/alpha)) + { + betaq = pow ( (rand * alpha), (1.0 / (eta + 1.0))); + } + else + { + betaq = pow ( (1.0 / (2.0 - rand * alpha)), (1.0 / (eta+1.0))); + } + c1 = 0.5 * ((y1 + y2) - betaq * (y2 - y1)); + + beta = 1.0 + (2.0 * (yu - y2) / (y2 - y1)); + alpha = 2.0 - pow( beta, -(eta + 1.0)); + if (rand <= (1.0/alpha)) + { + betaq = pow ( (rand * alpha), (1.0 / (eta + 1.0))); + } + else + { + betaq = pow ( (1.0 / (2.0 - rand * alpha)), (1.0 / (eta + 1.0))); + } + c2 = 0.5 * ((y1 + y2) + betaq * (y2 - y1)); + + bounds.truncate(i, c1); + bounds.truncate(i, c2); + + if (rng.flip()) + { + _eo1[i] = c2; + _eo2[i] = c1; + } + else + { + _eo1[i] = c1; + _eo2[i] = c2; + } + + changed = true; + } + } + } + + return changed; + } + + + +protected: + eoRealVectorBounds & bounds; + double eta; + double range; // == 1 +}; + +#endif /*SBXCROSSOVER_H_*/ diff --git a/branches/contribution/branches/bilevel/src/op/VRP2RBX.h b/branches/contribution/branches/bilevel/src/op/VRP2RBX.h new file mode 100644 index 000000000..c40461f48 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/op/VRP2RBX.h @@ -0,0 +1,65 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +#include +#include +class VRP2RBX: public eoBinOp{ + public: + VRP2RBX(float _proba=0.5, eoRng &_rnd=eo::rng):proba(_proba),rnd(_rnd){} + bool operator()(VRP2 & vrp1, const VRP2 &vrp2){ + unsigned int cur=0; + std::set alreadyIn; + for (unsigned int i=0;i +#include +#include +class VRP2Repair : public eoMonOp { + + public: + VRP2Repair(DistMat &_mat, eoRng& _rng, float _bias = 0.5 ):rng(_rng),gen(_bias,_rng),mat(_mat){} + VRP2Repair(DistMat &_mat, float _bias = 0.5):rng(eo::rng),gen(_bias,rng),mat(_mat){} + + bool operator()(VRP2 &_vrp){ + VRP2 res(_vrp); + double chargeMax=mat.maxLoad(); + std::list listRes; + std::list::iterator, double > > itesLibres; + bool first=true; + unsigned int currentVehicle=0; + unsigned int i; + std::vector malplaces; + + while(first ||currentVehicle<_vrp.size()){ + double charge; + if(first)charge=_vrp.chargeOfVehicleAt(mat,-1); + else charge=_vrp.chargeOfVehicleAt(mat,currentVehicle); + bool OK=charge<=chargeMax; + if (OK) { + for(i=(first?0:currentVehicle+1);i<_vrp.size() && !_vrp.isVehicleAt(i);i++){ + listRes.push_back(_vrp[i]); + } + if (i<_vrp.size()){ + std::list::iterator it=listRes.insert(listRes.end(),_vrp[i]); + if (_vrp.isVehicleAt(i)){ + std::make_pair(it,charge); + itesLibres.push_back(std::make_pair(it,charge)); + } + } + } + else{ + charge=0; + for (i=(first?0:currentVehicle+1); i<_vrp.size() && !_vrp.isVehicleAt(i); i++){ + if (charge+mat.demand(_vrp[i])<=chargeMax ){ + charge+=mat.demand(_vrp[i]); + listRes.push_back(_vrp[i]); + }else{ + malplaces.push_back(i); + } + } + listRes.push_back(_vrp[i]); + } + currentVehicle=i; + first=false; + } + for (unsigned int j=0;j::iterator, double> >::iterator it; + i=malplaces[j]; + for(it=itesLibres.begin();it!=itesLibres.end()&&!done;it++){ + if((*it).second+mat.demand(_vrp[i])<=chargeMax){ + done=true; + listRes.insert((*it).first,_vrp[i]); + (*it).second+=mat.demand(_vrp[i]); + } + } + if(!done) { + listRes.push_back(_vrp[i]); + } + } + int cur=0; + for (std::list::iterator it=listRes.begin();it!=listRes.end();it++){ + _vrp[cur++]=*it; + } + _vrp.invalidate(); + return true; + } + + + private: + eoRng &rng; + eoBooleanGenerator gen; + DistMat &mat; + + +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/op/VRP2SBX.h b/branches/contribution/branches/bilevel/src/op/VRP2SBX.h new file mode 100644 index 000000000..82b6b07b3 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/op/VRP2SBX.h @@ -0,0 +1,82 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +#include +#include +class VRP2SBX: public eoBinOp{ + + public: + VRP2SBX(float _proba=0.5, eoRng &_rnd=eo::rng):proba(_proba),rnd(_rnd){} + bool operator()(VRP2 & vrp1, const VRP2 &vrp2){ + VRP2 res(vrp1); + int link1=-1,link2=-1; + int vehicle1; + while (link1==-1 || vrp1.isVehicleAt(link1)){ + link1=rnd.random(vrp1.size()); + } + while (link2==-1 || vrp2.isVehicleAt(link2)){ + link2=rnd.random(vrp2.size()); + } + for (vehicle1=link1;vehicle1>=0;vehicle1--) + if (vrp1.isVehicleAt(vehicle1)) + break; + std::set retailAfterLink2; + for (unsigned int i =link2;i + +class VRPXover: public eoQuadOp{ + +}; diff --git a/branches/contribution/branches/bilevel/src/op/beoBestExchange.h b/branches/contribution/branches/bilevel/src/op/beoBestExchange.h new file mode 100644 index 000000000..c2248e29a --- /dev/null +++ b/branches/contribution/branches/bilevel/src/op/beoBestExchange.h @@ -0,0 +1,50 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//Coevolutionary operator making the "best" coevolution +//takes the lower level from the second element and the higher from the first +#ifndef BEOBESTEXCHANGE_H_ +#define BEOBESTEXCHANGE_H_ +#include +#include +template class beoBestExchange: public beoCoevoOp{ + bool operator()(BEOT &a, BEOT &b){ + a.lower()=b.lower(); + b.upper()=a.upper(); + a.invalidate(); + b.invalidate(); + return true; + } +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/op/beoCoevoLowExchange.h b/branches/contribution/branches/bilevel/src/op/beoCoevoLowExchange.h new file mode 100644 index 000000000..25df0542c --- /dev/null +++ b/branches/contribution/branches/bilevel/src/op/beoCoevoLowExchange.h @@ -0,0 +1,50 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//Coevolutionary operator that swap the lower level variable +#ifndef BEOCOEVOLOWEXCHANGE_H_ +#define BEOCOEVOLOWEXCHANGE_H_ +#include +#include +template class beoCoevoLowExchange: public beoCoevoOp{ + bool operator()(BEOT &a, BEOT &b){ + typename BEOT::L tmp(a.lower()); + a.lower()=b.lower(); + b.lower()=tmp; + a.invalidate(); + b.invalidate(); + return true; + } +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/op/beoCoevoUpExchange.h b/branches/contribution/branches/bilevel/src/op/beoCoevoUpExchange.h new file mode 100644 index 000000000..632274dd0 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/op/beoCoevoUpExchange.h @@ -0,0 +1,50 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//Coevolutionary operator that swap the higher level variable +#ifndef BEOCOEVOUPEXCHANGE_H_ +#define BEOCOEVOUPEXCHANGE_H_ +#include +#include +template class beoCoevoUpExchange: public beoCoevoOp{ + bool operator()(BEOT &a, BEOT &b){ + typename BEOT::U tmp(a.upper()); + a.upper()=b.upper(); + b.upper()=tmp; + a.invalidate(); + b.invalidate(); + return true; + } +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/op/beoLeftieExchange.h b/branches/contribution/branches/bilevel/src/op/beoLeftieExchange.h new file mode 100644 index 000000000..d0f782176 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/op/beoLeftieExchange.h @@ -0,0 +1,47 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//Coevolutionary operator that copy the second element into the first +#ifndef BEOLEFTIEEXCHANGE_H_ +#define BEOLEFTIEEXCHANGE_H_ +#include +#include +template class beoLeftieExchange: public beoCoevoOp{ + bool operator()(BEOT &a, BEOT &b){ + a=b; + a.invalidate(); + return true; + } +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/op/beoRateContainerCoevoOp.h b/branches/contribution/branches/bilevel/src/op/beoRateContainerCoevoOp.h new file mode 100644 index 000000000..5462a5115 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/op/beoRateContainerCoevoOp.h @@ -0,0 +1,62 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//coevolutionary operator container +#include +#include +template class beoRateContainerCoevoOp: public beoCoevoOp{ + public: + beoRateContainerCoevoOp(beoCoevoOp &_op, double _rate, eoRng &_rng= eo::rng):rng(_rng){ + add (_op,_rate); + } + + void add(beoCoevoOp &_op, double _rate){ + ops.push_back(&_op); + rates.push_back(_rate); + } + + bool operator()(BEOT &_b1, BEOT &_b2){ + int i=rng.roulette_wheel(rates); + return (*ops[i])(_b1,_b2); + } + + + + + private: + std::vector* > ops; + std::vector rates; + eoRng &rng; + +}; diff --git a/branches/contribution/branches/bilevel/src/op/beoRightieExchange.h b/branches/contribution/branches/bilevel/src/op/beoRightieExchange.h new file mode 100644 index 000000000..108a92b6a --- /dev/null +++ b/branches/contribution/branches/bilevel/src/op/beoRightieExchange.h @@ -0,0 +1,47 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +//Coevolutionary operator that copy the first element into the second one +#ifndef BEORIGHTIEEXCHANGE_H_ +#define BEORIGHTIEEXCHANGE_H_ +#include +#include +template class beoRightieExchange: public beoCoevoOp{ + bool operator()(BEOT &a, BEOT &b){ + b=a; + b.invalidate(); + return true; + } +}; +#endif diff --git a/branches/contribution/branches/bilevel/src/op/biVRPRBX.h b/branches/contribution/branches/bilevel/src/op/biVRPRBX.h new file mode 100644 index 000000000..a5af89ac4 --- /dev/null +++ b/branches/contribution/branches/bilevel/src/op/biVRPRBX.h @@ -0,0 +1,72 @@ +/* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2010 +* +* Legillon Francois +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* 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". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* 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 +* +*/ +//----------------------------------------------------------------------------- +#include +#include +class biVRPRBX: public eoBinOp{ + + public: + biVRPRBX(float _proba=0.5, eoRng &_rnd=eo::rng):proba(_proba),rnd(_rnd){} + bool operator()(biVRP & vrp1, const biVRP &vrp2){ + unsigned int cur=0; + std::set alreadyIn; + biVRP res(vrp1); + for (unsigned int i=0;i +#include +class biVRPSBX: public eoBinOp{ + + public: + biVRPSBX(float _proba=0.5, eoRng &_rnd=eo::rng):proba(_proba),rnd(_rnd){} + bool operator()(biVRP & vrp1, const biVRP &vrp2){ + biVRP::U res(vrp1.upper()); + int link1=-1,link2=-1; + while (link1==-1 || vrp1.upper().isVehicleAt(link1)){ + link1=rnd.random(vrp1.upper().size()); + } + while (link2==-1 || vrp2.upper().isVehicleAt(link2)){ + link2=rnd.random(vrp2.upper().size()); + } + std::set retailAfterLink2; + for (unsigned int i =link2;i