git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@535 331e1502-861f-0410-8da2-ba01fb791d7f

This commit is contained in:
legrand 2007-07-05 08:53:52 +00:00
commit 8eec676a69
2 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,121 @@
######################################################################################
### 0) Set the compiler
######################################################################################
SET (CMAKE_CXX_COMPILER mpicxx)
######################################################################################
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${EO_SRC_DIR})
INCLUDE_DIRECTORIES(${MO_SRC_DIR})
INCLUDE_DIRECTORIES(${PEO_SRC_DIR})
INCLUDE_DIRECTORIES(${TSP_EXAMPLE_DIR}/src)
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries (mandatory: before 3) )
######################################################################################
LINK_DIRECTORIES( ${EO_SRC_DIR}
${EO_SRC_DIR}/utils
${PEO_DIR}/build
${TSP_EXAMPLE_DIR}/build)
######################################################################################
######################################################################################
### 3) Define your target(s): just an executable here
######################################################################################
# no matter what is the OS, hopefully
ADD_EXECUTABLE(exampleA exampleA.cpp)
ADD_EXECUTABLE(exampleB exampleB.cpp)
ADD_EXECUTABLE(exampleC exampleC.cpp)
ADD_EXECUTABLE(exampleD exampleD.cpp)
ADD_EXECUTABLE(exampleE exampleE.cpp)
ADD_DEPENDENCIES(exampleA tsp)
ADD_DEPENDENCIES(exampleB tsp)
ADD_DEPENDENCIES(exampleC tsp)
ADD_DEPENDENCIES(exampleD tsp)
ADD_DEPENDENCIES(exampleE tsp)
ADD_DEPENDENCIES(exampleA peo)
ADD_DEPENDENCIES(exampleB peo)
ADD_DEPENDENCIES(exampleC peo)
ADD_DEPENDENCIES(exampleD peo)
ADD_DEPENDENCIES(exampleE peo)
ADD_DEPENDENCIES(exampleA rmc_mpi)
ADD_DEPENDENCIES(exampleB rmc_mpi)
ADD_DEPENDENCIES(exampleC rmc_mpi)
ADD_DEPENDENCIES(exampleD rmc_mpi)
ADD_DEPENDENCIES(exampleE rmc_mpi)
SET(EXECUTABLE_OUTPUT_PATH ${TUTORIAL_WALKTHROUGH_DIR}/build)
######################################################################################
######################################################################################
### 4) Optionnal: define your target(s)'s version: no effect for windows
######################################################################################
SET(WALKTHROUGH_VERSION "1.0.beta")
SET_TARGET_PROPERTIES(exampleA PROPERTIES VERSION "${WALKTHROUGH_VERSION}")
SET_TARGET_PROPERTIES(exampleB PROPERTIES VERSION "${WALKTHROUGH_VERSION}")
SET_TARGET_PROPERTIES(exampleC PROPERTIES VERSION "${WALKTHROUGH_VERSION}")
SET_TARGET_PROPERTIES(exampleD PROPERTIES VERSION "${WALKTHROUGH_VERSION}")
SET_TARGET_PROPERTIES(exampleE PROPERTIES VERSION "${WALKTHROUGH_VERSION}")
######################################################################################
######################################################################################
### 5) Link the librairies
######################################################################################
TARGET_LINK_LIBRARIES(exampleA ${XML2_LIBS}) # define in CMakeLists.txt at PEO root dir
TARGET_LINK_LIBRARIES(exampleB ${XML2_LIBS}) # define in CMakeLists.txt at PEO root dir
TARGET_LINK_LIBRARIES(exampleC ${XML2_LIBS}) # define in CMakeLists.txt at PEO root dir
TARGET_LINK_LIBRARIES(exampleD ${XML2_LIBS}) # define in CMakeLists.txt at PEO root dir
TARGET_LINK_LIBRARIES(exampleE ${XML2_LIBS}) # define in CMakeLists.txt at PEO root dir
TARGET_LINK_LIBRARIES(exampleA tsp)
TARGET_LINK_LIBRARIES(exampleB tsp)
TARGET_LINK_LIBRARIES(exampleC tsp)
TARGET_LINK_LIBRARIES(exampleD tsp)
TARGET_LINK_LIBRARIES(exampleE tsp)
TARGET_LINK_LIBRARIES(exampleA peo)
TARGET_LINK_LIBRARIES(exampleB peo)
TARGET_LINK_LIBRARIES(exampleC peo)
TARGET_LINK_LIBRARIES(exampleD peo)
TARGET_LINK_LIBRARIES(exampleE peo)
TARGET_LINK_LIBRARIES(exampleA rmc_mpi)
TARGET_LINK_LIBRARIES(exampleB rmc_mpi)
TARGET_LINK_LIBRARIES(exampleC rmc_mpi)
TARGET_LINK_LIBRARIES(exampleD rmc_mpi)
TARGET_LINK_LIBRARIES(exampleE rmc_mpi)
TARGET_LINK_LIBRARIES(exampleA eo)
TARGET_LINK_LIBRARIES(exampleB eo)
TARGET_LINK_LIBRARIES(exampleC eo)
TARGET_LINK_LIBRARIES(exampleD eo)
TARGET_LINK_LIBRARIES(exampleE eo)
TARGET_LINK_LIBRARIES(exampleA eoutils)
TARGET_LINK_LIBRARIES(exampleB eoutils)
TARGET_LINK_LIBRARIES(exampleC eoutils)
TARGET_LINK_LIBRARIES(exampleD eoutils)
TARGET_LINK_LIBRARIES(exampleE eoutils)
######################################################################################

View file

@ -0,0 +1,83 @@
// (c) OPAC Team, LIFL, July 2007
//
// Contact: paradiseo-help@lists.gforge.inria.fr
#include "param.h"
#include "route_init.h"
#include "route_eval.h"
#include "order_xover.h"
#include "edge_xover.h"
#include "partial_mapped_xover.h"
#include "city_swap.h"
#include "part_route_eval.h"
#include "merge_route_eval.h"
#include "two_opt_init.h"
#include "two_opt_next.h"
#include "two_opt_incr_eval.h"
#include <paradiseo>
#define POP_SIZE 10
#define NUM_GEN 10
#define CROSS_RATE 1.0
#define MUT_RATE 0.01
#define NUM_PART_EVALS 2
int main (int __argc, char * * __argv) {
peo :: init (__argc, __argv);
loadParameters (__argc, __argv); /* Processing some parameters relative to the tackled
problem (TSP) */
RouteInit route_init; /* Its builds random routes */
RouteEval full_eval; /* Full route evaluator */
MergeRouteEval merge_eval;
std :: vector <eoEvalFunc <Route> *> part_eval;
for (unsigned i = 1 ; i <= NUM_PART_EVALS ; i ++)
part_eval.push_back (new PartRouteEval ((float) (i - 1) / NUM_PART_EVALS, (float) i / NUM_PART_EVALS));
OrderXover order_cross; /* Recombination */
CitySwap city_swap_mut; /* Mutation */
/** The EA */
eoPop <Route> ox_pop (POP_SIZE, route_init); /* Population */
eoGenContinue <Route> ox_cont (NUM_GEN); /* A fixed number of iterations */
eoCheckPoint <Route> ox_checkpoint (ox_cont); /* Checkpoint */
peoParaPopEval <Route> ox_pop_eval (full_eval);
eoStochTournamentSelect <Route> ox_select_one;
eoSelectNumber <Route> ox_select (ox_select_one, POP_SIZE);
eoSGATransform <Route> ox_transform (order_cross, CROSS_RATE, city_swap_mut, MUT_RATE);
peoSeqTransform <Route> ox_para_transform (ox_transform);
eoEPReplacement <Route> ox_replace (2);
peoEA <Route> ox_ea (ox_checkpoint, ox_pop_eval, ox_select, ox_para_transform, ox_replace);
ox_ea (ox_pop); /* Application to the given population */
peo :: run ();
peo :: finalize (); /* Termination */
// rank 0 is assigned to the scheduler in the XML mapping file
if ( getNodeRank() == 1 ) {
std::cout << "EA[ 0 ] -----> " << ox_pop.best_element().fitness() << std::endl;
}
return 0;
}