git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@485 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
6afece10a5
commit
ec22cf9d34
16 changed files with 814 additions and 1 deletions
|
|
@ -11,6 +11,6 @@ SET(TSP_EXAMPLE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/examples/tsp CACHE PATH "TSP exa
|
||||||
### 2) Where must cmake go now ?
|
### 2) Where must cmake go now ?
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
SUBDIRS(examples Lesson1 Lesson2 Lesson3)
|
SUBDIRS(examples Lesson1 Lesson2 Lesson3 Walkthrough)
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
|
||||||
16
trunk/paradiseo-peo/tutorial/Walkthrough/CMakeLists.txt
Normal file
16
trunk/paradiseo-peo/tutorial/Walkthrough/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
### 0) Need walkthrough directory
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
SET(TUTORIAL_WALKTHROUGH_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
### 1) Where must cmake go now ?
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
SUBDIRS(src)
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
11
trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonA.param
Normal file
11
trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonA.param
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
## miscallenous parameters
|
||||||
|
|
||||||
|
--debug=false
|
||||||
|
|
||||||
|
## deployment schema
|
||||||
|
|
||||||
|
--schema=schemaA.xml
|
||||||
|
|
||||||
|
## parameters
|
||||||
|
|
||||||
|
--inst=../../examples/tsp/benchs/eil101.tsp
|
||||||
11
trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonB.param
Normal file
11
trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonB.param
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
## miscallenous parameters
|
||||||
|
|
||||||
|
--debug=false
|
||||||
|
|
||||||
|
## deployment schema
|
||||||
|
|
||||||
|
--schema=schemaB.xml
|
||||||
|
|
||||||
|
## parameters
|
||||||
|
|
||||||
|
--inst=../../examples/tsp/benchs/eil101.tsp
|
||||||
11
trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonC.param
Normal file
11
trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonC.param
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
## miscallenous parameters
|
||||||
|
|
||||||
|
--debug=false
|
||||||
|
|
||||||
|
## deployment schema
|
||||||
|
|
||||||
|
--schema=schemaC.xml
|
||||||
|
|
||||||
|
## parameters
|
||||||
|
|
||||||
|
--inst=../../examples/tsp/benchs/eil101.tsp
|
||||||
11
trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonD.param
Normal file
11
trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonD.param
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
## miscallenous parameters
|
||||||
|
|
||||||
|
--debug=false
|
||||||
|
|
||||||
|
## deployment schema
|
||||||
|
|
||||||
|
--schema=schemaD.xml
|
||||||
|
|
||||||
|
## parameters
|
||||||
|
|
||||||
|
--inst=../../examples/tsp/benchs/eil101.tsp
|
||||||
10
trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaA.xml
Normal file
10
trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaA.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<schema>
|
||||||
|
<group scheduler="0">
|
||||||
|
<node name="0" num_workers="0">
|
||||||
|
<runner>1</runner>
|
||||||
|
</node>
|
||||||
|
</group>
|
||||||
|
</schema>
|
||||||
|
|
||||||
10
trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaB.xml
Normal file
10
trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaB.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<schema>
|
||||||
|
<group scheduler="0">
|
||||||
|
<node name="0" num_workers="0">
|
||||||
|
<runner>1</runner>
|
||||||
|
</node>
|
||||||
|
</group>
|
||||||
|
</schema>
|
||||||
|
|
||||||
17
trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaC.xml
Normal file
17
trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaC.xml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<schema>
|
||||||
|
<group scheduler="0">
|
||||||
|
<node name="0" num_workers="0">
|
||||||
|
</node>
|
||||||
|
<node name="1" num_workers="0">
|
||||||
|
<runner>1</runner>
|
||||||
|
<runner>2</runner>
|
||||||
|
</node>
|
||||||
|
<node name="2" num_workers="1">
|
||||||
|
</node>
|
||||||
|
<node name="3" num_workers="1">
|
||||||
|
</node>
|
||||||
|
</group>
|
||||||
|
</schema>
|
||||||
|
|
||||||
16
trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaD.xml
Normal file
16
trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaD.xml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<schema>
|
||||||
|
<group scheduler="0">
|
||||||
|
<node name="0" num_workers="0">
|
||||||
|
</node>
|
||||||
|
<node name="1" num_workers="0">
|
||||||
|
<runner>1</runner>
|
||||||
|
</node>
|
||||||
|
<node name="2" num_workers="1">
|
||||||
|
</node>
|
||||||
|
<node name="3" num_workers="1">
|
||||||
|
</node>
|
||||||
|
</group>
|
||||||
|
</schema>
|
||||||
|
|
||||||
110
trunk/paradiseo-peo/tutorial/Walkthrough/src/CMakeLists.txt
Normal file
110
trunk/paradiseo-peo/tutorial/Walkthrough/src/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,110 @@
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
### 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_DEPENDENCIES(exampleA tsp)
|
||||||
|
ADD_DEPENDENCIES(exampleB tsp)
|
||||||
|
ADD_DEPENDENCIES(exampleC tsp)
|
||||||
|
ADD_DEPENDENCIES(exampleD tsp)
|
||||||
|
|
||||||
|
ADD_DEPENDENCIES(exampleA peo)
|
||||||
|
ADD_DEPENDENCIES(exampleB peo)
|
||||||
|
ADD_DEPENDENCIES(exampleC peo)
|
||||||
|
ADD_DEPENDENCIES(exampleD peo)
|
||||||
|
|
||||||
|
ADD_DEPENDENCIES(exampleA rmc_mpi)
|
||||||
|
ADD_DEPENDENCIES(exampleB rmc_mpi)
|
||||||
|
ADD_DEPENDENCIES(exampleC rmc_mpi)
|
||||||
|
ADD_DEPENDENCIES(exampleD 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}")
|
||||||
|
######################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
|
### 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(exampleA tsp)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleB tsp)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleC tsp)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleD tsp)
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(exampleA peo)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleB peo)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleC peo)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleD 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(exampleA eo)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleB eo)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleC eo)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleD eo)
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(exampleA eoutils)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleB eoutils)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleC eoutils)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleD eoutils)
|
||||||
|
|
||||||
|
######################################################################################
|
||||||
74
trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleA.cpp
Normal file
74
trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleA.cpp
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
// (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
|
||||||
|
|
||||||
|
|
||||||
|
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 */
|
||||||
|
|
||||||
|
|
||||||
|
OrderXover order_cross; /* Recombination */
|
||||||
|
PartialMappedXover pm_cross;
|
||||||
|
EdgeXover edge_cross;
|
||||||
|
CitySwap city_swap_mut; /* Mutation */
|
||||||
|
|
||||||
|
|
||||||
|
/** Local Search */
|
||||||
|
TwoOptInit pmx_two_opt_init;
|
||||||
|
TwoOptNext pmx_two_opt_next;
|
||||||
|
TwoOptIncrEval pmx_two_opt_incr_eval;
|
||||||
|
moBestImprSelect <TwoOpt> pmx_two_opt_move_select;
|
||||||
|
moHC <TwoOpt> hc (pmx_two_opt_init, pmx_two_opt_next, pmx_two_opt_incr_eval, pmx_two_opt_move_select, full_eval);
|
||||||
|
|
||||||
|
/** 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 */
|
||||||
|
peoSeqPopEval <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 */
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
85
trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleB.cpp
Normal file
85
trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleB.cpp
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
// (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
|
||||||
|
|
||||||
|
|
||||||
|
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 */
|
||||||
|
|
||||||
|
|
||||||
|
OrderXover order_cross; /* Recombination */
|
||||||
|
PartialMappedXover pm_cross;
|
||||||
|
EdgeXover edge_cross;
|
||||||
|
CitySwap city_swap_mut; /* Mutation */
|
||||||
|
|
||||||
|
|
||||||
|
/** Local Search */
|
||||||
|
TwoOptInit pmx_two_opt_init;
|
||||||
|
TwoOptNext pmx_two_opt_next;
|
||||||
|
TwoOptIncrEval pmx_two_opt_incr_eval;
|
||||||
|
moBestImprSelect <TwoOpt> pmx_two_opt_move_select;
|
||||||
|
moHC <TwoOpt> hc (pmx_two_opt_init, pmx_two_opt_next, pmx_two_opt_incr_eval, pmx_two_opt_move_select, full_eval);
|
||||||
|
|
||||||
|
/** 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 */
|
||||||
|
peoSeqPopEval <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 */
|
||||||
|
|
||||||
|
|
||||||
|
hc( ox_pop[ 0 ] );
|
||||||
|
|
||||||
|
|
||||||
|
for ( unsigned long index = 1; index < ox_pop.size(); index++ ) {
|
||||||
|
|
||||||
|
std :: cout << ox_pop[ index ].fitness();
|
||||||
|
hc( ox_pop[ index ] );
|
||||||
|
std :: cout << " -> " << ox_pop[ index ].fitness() << std :: endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
120
trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleC.cpp
Normal file
120
trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleC.cpp
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
// (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 MIG_FREQ 2
|
||||||
|
#define MIG_SIZE 5
|
||||||
|
|
||||||
|
|
||||||
|
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 */
|
||||||
|
|
||||||
|
|
||||||
|
OrderXover order_cross; /* Recombination */
|
||||||
|
CitySwap city_swap_mut; /* Mutation */
|
||||||
|
|
||||||
|
|
||||||
|
/* Migration topology */
|
||||||
|
RingTopology topo;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// The First 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 */
|
||||||
|
peoSeqPopEval <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);
|
||||||
|
|
||||||
|
|
||||||
|
/* The migration policy */
|
||||||
|
eoPeriodicContinue <Route> ox_mig_cont (MIG_FREQ); /* Migration occurs periodically */
|
||||||
|
eoRandomSelect <Route> ox_mig_select_one; /* Emigrants are randomly selected */
|
||||||
|
eoSelectNumber <Route> ox_mig_select (ox_mig_select_one, MIG_SIZE);
|
||||||
|
eoPlusReplacement <Route> ox_mig_replace; /* Immigrants replace the worse individuals */
|
||||||
|
|
||||||
|
peoAsyncIslandMig <Route> ox_mig (ox_mig_cont, ox_mig_select, ox_mig_replace, topo, ox_pop, ox_pop);
|
||||||
|
ox_checkpoint.add (ox_mig);
|
||||||
|
|
||||||
|
peoEA <Route> ox_ea (ox_checkpoint, ox_pop_eval, ox_select, ox_para_transform, ox_replace);
|
||||||
|
ox_mig.setOwner (ox_ea);
|
||||||
|
|
||||||
|
ox_ea (ox_pop); /* Application to the given population */
|
||||||
|
// --------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// The Second EA ------------------------------------------------------------------------------------
|
||||||
|
eoPop <Route> ox_pop2 (POP_SIZE, route_init); /* Population */
|
||||||
|
|
||||||
|
eoGenContinue <Route> ox_cont2 (NUM_GEN); /* A fixed number of iterations */
|
||||||
|
eoCheckPoint <Route> ox_checkpoint2 (ox_cont2); /* Checkpoint */
|
||||||
|
peoSeqPopEval <Route> ox_pop_eval2 (full_eval);
|
||||||
|
eoStochTournamentSelect <Route> ox_select_one2;
|
||||||
|
eoSelectNumber <Route> ox_select2 (ox_select_one2, POP_SIZE);
|
||||||
|
eoSGATransform <Route> ox_transform2 (order_cross, CROSS_RATE, city_swap_mut, MUT_RATE);
|
||||||
|
peoSeqTransform <Route> ox_para_transform2 (ox_transform2);
|
||||||
|
eoEPReplacement <Route> ox_replace2 (2);
|
||||||
|
|
||||||
|
|
||||||
|
/* The migration policy */
|
||||||
|
eoPeriodicContinue <Route> ox_mig_cont2 (MIG_FREQ); /* Migration occurs periodically */
|
||||||
|
eoRandomSelect <Route> ox_mig_select_one2; /* Emigrants are randomly selected */
|
||||||
|
eoSelectNumber <Route> ox_mig_select2 (ox_mig_select_one2, MIG_SIZE);
|
||||||
|
eoPlusReplacement <Route> ox_mig_replace2; /* Immigrants replace the worse individuals */
|
||||||
|
|
||||||
|
peoAsyncIslandMig <Route> ox_mig2 (ox_mig_cont2, ox_mig_select2, ox_mig_replace2, topo, ox_pop2, ox_pop2);
|
||||||
|
ox_checkpoint2.add (ox_mig2);
|
||||||
|
|
||||||
|
peoEA <Route> ox_ea2 (ox_checkpoint2, ox_pop_eval2, ox_select2, ox_para_transform2, ox_replace2);
|
||||||
|
ox_mig2.setOwner (ox_ea2);
|
||||||
|
|
||||||
|
ox_ea2 (ox_pop2); /* Application to the given population */
|
||||||
|
// --------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
peo :: run ();
|
||||||
|
peo :: finalize (); /* Termination */
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << ox_pop[ 0 ].fitness() << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
70
trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleD.cpp
Normal file
70
trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleD.cpp
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
// (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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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 */
|
||||||
|
|
||||||
|
|
||||||
|
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 */
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << ox_pop[ 0 ].fitness() << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,241 @@
|
||||||
|
# Doxyfile 1.4.7
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Project related configuration options
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
PROJECT_NAME = "ParadisEO-PEO Lesson1"
|
||||||
|
PROJECT_NUMBER = 0.1
|
||||||
|
OUTPUT_DIRECTORY = ../../docs/html/lesson1
|
||||||
|
CREATE_SUBDIRS = NO
|
||||||
|
OUTPUT_LANGUAGE = English
|
||||||
|
USE_WINDOWS_ENCODING = NO
|
||||||
|
BRIEF_MEMBER_DESC = YES
|
||||||
|
REPEAT_BRIEF = YES
|
||||||
|
ABBREVIATE_BRIEF = "The $name class" \
|
||||||
|
"The $name widget" \
|
||||||
|
"The $name file" \
|
||||||
|
is \
|
||||||
|
provides \
|
||||||
|
specifies \
|
||||||
|
contains \
|
||||||
|
represents \
|
||||||
|
a \
|
||||||
|
an \
|
||||||
|
the
|
||||||
|
ALWAYS_DETAILED_SEC = NO
|
||||||
|
INLINE_INHERITED_MEMB = NO
|
||||||
|
FULL_PATH_NAMES = NO
|
||||||
|
STRIP_FROM_PATH =
|
||||||
|
STRIP_FROM_INC_PATH =
|
||||||
|
SHORT_NAMES = NO
|
||||||
|
JAVADOC_AUTOBRIEF = YES
|
||||||
|
MULTILINE_CPP_IS_BRIEF = NO
|
||||||
|
DETAILS_AT_TOP = NO
|
||||||
|
INHERIT_DOCS = YES
|
||||||
|
SEPARATE_MEMBER_PAGES = NO
|
||||||
|
TAB_SIZE = 8
|
||||||
|
ALIASES =
|
||||||
|
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||||
|
OPTIMIZE_OUTPUT_JAVA = NO
|
||||||
|
BUILTIN_STL_SUPPORT = NO
|
||||||
|
DISTRIBUTE_GROUP_DOC = NO
|
||||||
|
SUBGROUPING = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Build related configuration options
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
EXTRACT_ALL = NO
|
||||||
|
EXTRACT_PRIVATE = YES
|
||||||
|
EXTRACT_STATIC = YES
|
||||||
|
EXTRACT_LOCAL_CLASSES = YES
|
||||||
|
EXTRACT_LOCAL_METHODS = NO
|
||||||
|
HIDE_UNDOC_MEMBERS = YES
|
||||||
|
HIDE_UNDOC_CLASSES = YES
|
||||||
|
HIDE_FRIEND_COMPOUNDS = NO
|
||||||
|
HIDE_IN_BODY_DOCS = NO
|
||||||
|
INTERNAL_DOCS = NO
|
||||||
|
CASE_SENSE_NAMES = YES
|
||||||
|
HIDE_SCOPE_NAMES = NO
|
||||||
|
SHOW_INCLUDE_FILES = YES
|
||||||
|
INLINE_INFO = YES
|
||||||
|
SORT_MEMBER_DOCS = NO
|
||||||
|
SORT_BRIEF_DOCS = NO
|
||||||
|
SORT_BY_SCOPE_NAME = NO
|
||||||
|
GENERATE_TODOLIST = YES
|
||||||
|
GENERATE_TESTLIST = YES
|
||||||
|
GENERATE_BUGLIST = YES
|
||||||
|
GENERATE_DEPRECATEDLIST= YES
|
||||||
|
ENABLED_SECTIONS =
|
||||||
|
MAX_INITIALIZER_LINES = 30
|
||||||
|
SHOW_USED_FILES = YES
|
||||||
|
SHOW_DIRECTORIES = NO
|
||||||
|
FILE_VERSION_FILTER =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to warning and progress messages
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
QUIET = YES
|
||||||
|
WARNINGS = YES
|
||||||
|
WARN_IF_UNDOCUMENTED = YES
|
||||||
|
WARN_IF_DOC_ERROR = YES
|
||||||
|
WARN_NO_PARAMDOC = NO
|
||||||
|
WARN_FORMAT = "$file:$line: $text"
|
||||||
|
WARN_LOGFILE =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the input files
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
INPUT = .
|
||||||
|
FILE_PATTERNS = *.cpp \
|
||||||
|
*.h \
|
||||||
|
NEWS \
|
||||||
|
README
|
||||||
|
RECURSIVE = YES
|
||||||
|
EXCLUDE =
|
||||||
|
EXCLUDE_SYMLINKS = NO
|
||||||
|
EXCLUDE_PATTERNS =
|
||||||
|
EXAMPLE_PATH =
|
||||||
|
EXAMPLE_PATTERNS = *
|
||||||
|
EXAMPLE_RECURSIVE = NO
|
||||||
|
IMAGE_PATH = ../../docs/images
|
||||||
|
INPUT_FILTER =
|
||||||
|
FILTER_PATTERNS =
|
||||||
|
FILTER_SOURCE_FILES = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to source browsing
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
SOURCE_BROWSER = YES
|
||||||
|
INLINE_SOURCES = NO
|
||||||
|
STRIP_CODE_COMMENTS = YES
|
||||||
|
REFERENCED_BY_RELATION = YES
|
||||||
|
REFERENCES_RELATION = YES
|
||||||
|
REFERENCES_LINK_SOURCE = YES
|
||||||
|
USE_HTAGS = NO
|
||||||
|
VERBATIM_HEADERS = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the alphabetical class index
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
ALPHABETICAL_INDEX = YES
|
||||||
|
COLS_IN_ALPHA_INDEX = 3
|
||||||
|
IGNORE_PREFIX = peo
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the HTML output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_HTML = YES
|
||||||
|
HTML_OUTPUT = html
|
||||||
|
HTML_FILE_EXTENSION = .html
|
||||||
|
HTML_HEADER =
|
||||||
|
HTML_FOOTER =
|
||||||
|
HTML_STYLESHEET =
|
||||||
|
HTML_ALIGN_MEMBERS = YES
|
||||||
|
GENERATE_HTMLHELP = NO
|
||||||
|
CHM_FILE =
|
||||||
|
HHC_LOCATION =
|
||||||
|
GENERATE_CHI = NO
|
||||||
|
BINARY_TOC = NO
|
||||||
|
TOC_EXPAND = NO
|
||||||
|
DISABLE_INDEX = NO
|
||||||
|
ENUM_VALUES_PER_LINE = 4
|
||||||
|
GENERATE_TREEVIEW = YES
|
||||||
|
TREEVIEW_WIDTH = 250
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the LaTeX output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_LATEX = YES
|
||||||
|
LATEX_OUTPUT = latex
|
||||||
|
LATEX_CMD_NAME = latex
|
||||||
|
MAKEINDEX_CMD_NAME = makeindex
|
||||||
|
COMPACT_LATEX = NO
|
||||||
|
PAPER_TYPE = a4wide
|
||||||
|
EXTRA_PACKAGES =
|
||||||
|
LATEX_HEADER =
|
||||||
|
PDF_HYPERLINKS = YES
|
||||||
|
USE_PDFLATEX = YES
|
||||||
|
LATEX_BATCHMODE = NO
|
||||||
|
LATEX_HIDE_INDICES = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the RTF output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_RTF = NO
|
||||||
|
RTF_OUTPUT = rtf
|
||||||
|
COMPACT_RTF = NO
|
||||||
|
RTF_HYPERLINKS = NO
|
||||||
|
RTF_STYLESHEET_FILE =
|
||||||
|
RTF_EXTENSIONS_FILE =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the man page output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_MAN = YES
|
||||||
|
MAN_OUTPUT = man
|
||||||
|
MAN_EXTENSION = .3
|
||||||
|
MAN_LINKS = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the XML output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_XML = NO
|
||||||
|
XML_OUTPUT = xml
|
||||||
|
XML_SCHEMA =
|
||||||
|
XML_DTD =
|
||||||
|
XML_PROGRAMLISTING = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options for the AutoGen Definitions output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_AUTOGEN_DEF = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the Perl module output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_PERLMOD = NO
|
||||||
|
PERLMOD_LATEX = NO
|
||||||
|
PERLMOD_PRETTY = YES
|
||||||
|
PERLMOD_MAKEVAR_PREFIX =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration options related to the preprocessor
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
ENABLE_PREPROCESSING = YES
|
||||||
|
MACRO_EXPANSION = NO
|
||||||
|
EXPAND_ONLY_PREDEF = NO
|
||||||
|
SEARCH_INCLUDES = YES
|
||||||
|
INCLUDE_PATH =
|
||||||
|
INCLUDE_FILE_PATTERNS =
|
||||||
|
PREDEFINED =
|
||||||
|
EXPAND_AS_DEFINED =
|
||||||
|
SKIP_FUNCTION_MACROS = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration::additions related to external references
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
TAGFILES = ../../../paradiseo-mo/docs/eo.doxytag=../../../../../paradiseo-mo/docs/html \
|
||||||
|
../../../paradiseo-mo/docs/mo.doxytag=../../../../../paradiseo-mo/docs/html \
|
||||||
|
../../docs/paradiseo-peo.doxytag=../../ \
|
||||||
|
../shared/paradiseo-peo-lsn-shared.doxytag=../../lsnshared/html
|
||||||
|
GENERATE_TAGFILE = ../../docs/paradiseo-peo-lsn.doxytag
|
||||||
|
ALLEXTERNALS = NO
|
||||||
|
EXTERNAL_GROUPS = YES
|
||||||
|
PERL_PATH = /usr/bin/perl
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration options related to the dot tool
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
CLASS_DIAGRAMS = YES
|
||||||
|
HIDE_UNDOC_RELATIONS = YES
|
||||||
|
HAVE_DOT = NO
|
||||||
|
CLASS_GRAPH = YES
|
||||||
|
COLLABORATION_GRAPH = YES
|
||||||
|
GROUP_GRAPHS = YES
|
||||||
|
UML_LOOK = NO
|
||||||
|
TEMPLATE_RELATIONS = NO
|
||||||
|
INCLUDE_GRAPH = YES
|
||||||
|
INCLUDED_BY_GRAPH = YES
|
||||||
|
CALL_GRAPH = NO
|
||||||
|
CALLER_GRAPH = NO
|
||||||
|
GRAPHICAL_HIERARCHY = YES
|
||||||
|
DIRECTORY_GRAPH = YES
|
||||||
|
DOT_IMAGE_FORMAT = png
|
||||||
|
DOT_PATH =
|
||||||
|
DOTFILE_DIRS =
|
||||||
|
MAX_DOT_GRAPH_WIDTH = 1024
|
||||||
|
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||||
|
MAX_DOT_GRAPH_DEPTH = 0
|
||||||
|
DOT_TRANSPARENT = NO
|
||||||
|
DOT_MULTI_TARGETS = NO
|
||||||
|
GENERATE_LEGEND = YES
|
||||||
|
DOT_CLEANUP = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration::additions related to the search engine
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
SEARCHENGINE = YES
|
||||||
Loading…
Add table
Add a link
Reference in a new issue