git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@503 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
b2c054b34a
commit
68177c4b57
16 changed files with 136 additions and 22 deletions
|
|
@ -41,21 +41,25 @@ ADD_EXECUTABLE(exampleA exampleA.cpp)
|
||||||
ADD_EXECUTABLE(exampleB exampleB.cpp)
|
ADD_EXECUTABLE(exampleB exampleB.cpp)
|
||||||
ADD_EXECUTABLE(exampleC exampleC.cpp)
|
ADD_EXECUTABLE(exampleC exampleC.cpp)
|
||||||
ADD_EXECUTABLE(exampleD exampleD.cpp)
|
ADD_EXECUTABLE(exampleD exampleD.cpp)
|
||||||
|
ADD_EXECUTABLE(exampleE exampleE.cpp)
|
||||||
|
|
||||||
ADD_DEPENDENCIES(exampleA tsp)
|
ADD_DEPENDENCIES(exampleA tsp)
|
||||||
ADD_DEPENDENCIES(exampleB tsp)
|
ADD_DEPENDENCIES(exampleB tsp)
|
||||||
ADD_DEPENDENCIES(exampleC tsp)
|
ADD_DEPENDENCIES(exampleC tsp)
|
||||||
ADD_DEPENDENCIES(exampleD tsp)
|
ADD_DEPENDENCIES(exampleD tsp)
|
||||||
|
ADD_DEPENDENCIES(exampleE tsp)
|
||||||
|
|
||||||
ADD_DEPENDENCIES(exampleA peo)
|
ADD_DEPENDENCIES(exampleA peo)
|
||||||
ADD_DEPENDENCIES(exampleB peo)
|
ADD_DEPENDENCIES(exampleB peo)
|
||||||
ADD_DEPENDENCIES(exampleC peo)
|
ADD_DEPENDENCIES(exampleC peo)
|
||||||
ADD_DEPENDENCIES(exampleD peo)
|
ADD_DEPENDENCIES(exampleD peo)
|
||||||
|
ADD_DEPENDENCIES(exampleE peo)
|
||||||
|
|
||||||
ADD_DEPENDENCIES(exampleA rmc_mpi)
|
ADD_DEPENDENCIES(exampleA rmc_mpi)
|
||||||
ADD_DEPENDENCIES(exampleB rmc_mpi)
|
ADD_DEPENDENCIES(exampleB rmc_mpi)
|
||||||
ADD_DEPENDENCIES(exampleC rmc_mpi)
|
ADD_DEPENDENCIES(exampleC rmc_mpi)
|
||||||
ADD_DEPENDENCIES(exampleD rmc_mpi)
|
ADD_DEPENDENCIES(exampleD rmc_mpi)
|
||||||
|
ADD_DEPENDENCIES(exampleE rmc_mpi)
|
||||||
|
|
||||||
SET(EXECUTABLE_OUTPUT_PATH ${TUTORIAL_WALKTHROUGH_DIR}/build)
|
SET(EXECUTABLE_OUTPUT_PATH ${TUTORIAL_WALKTHROUGH_DIR}/build)
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
@ -70,6 +74,7 @@ SET_TARGET_PROPERTIES(exampleA PROPERTIES VERSION "${WALKTHROUGH_VERSION}")
|
||||||
SET_TARGET_PROPERTIES(exampleB PROPERTIES VERSION "${WALKTHROUGH_VERSION}")
|
SET_TARGET_PROPERTIES(exampleB PROPERTIES VERSION "${WALKTHROUGH_VERSION}")
|
||||||
SET_TARGET_PROPERTIES(exampleC PROPERTIES VERSION "${WALKTHROUGH_VERSION}")
|
SET_TARGET_PROPERTIES(exampleC PROPERTIES VERSION "${WALKTHROUGH_VERSION}")
|
||||||
SET_TARGET_PROPERTIES(exampleD PROPERTIES VERSION "${WALKTHROUGH_VERSION}")
|
SET_TARGET_PROPERTIES(exampleD PROPERTIES VERSION "${WALKTHROUGH_VERSION}")
|
||||||
|
SET_TARGET_PROPERTIES(exampleE PROPERTIES VERSION "${WALKTHROUGH_VERSION}")
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -81,30 +86,36 @@ TARGET_LINK_LIBRARIES(exampleA ${XML2_LIBS}) # define in CMakeLists.txt at PEO r
|
||||||
TARGET_LINK_LIBRARIES(exampleB ${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(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(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(exampleA tsp)
|
||||||
TARGET_LINK_LIBRARIES(exampleB tsp)
|
TARGET_LINK_LIBRARIES(exampleB tsp)
|
||||||
TARGET_LINK_LIBRARIES(exampleC tsp)
|
TARGET_LINK_LIBRARIES(exampleC tsp)
|
||||||
TARGET_LINK_LIBRARIES(exampleD tsp)
|
TARGET_LINK_LIBRARIES(exampleD tsp)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleE tsp)
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(exampleA peo)
|
TARGET_LINK_LIBRARIES(exampleA peo)
|
||||||
TARGET_LINK_LIBRARIES(exampleB peo)
|
TARGET_LINK_LIBRARIES(exampleB peo)
|
||||||
TARGET_LINK_LIBRARIES(exampleC peo)
|
TARGET_LINK_LIBRARIES(exampleC peo)
|
||||||
TARGET_LINK_LIBRARIES(exampleD peo)
|
TARGET_LINK_LIBRARIES(exampleD peo)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleE peo)
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(exampleA rmc_mpi)
|
TARGET_LINK_LIBRARIES(exampleA rmc_mpi)
|
||||||
TARGET_LINK_LIBRARIES(exampleB rmc_mpi)
|
TARGET_LINK_LIBRARIES(exampleB rmc_mpi)
|
||||||
TARGET_LINK_LIBRARIES(exampleC rmc_mpi)
|
TARGET_LINK_LIBRARIES(exampleC rmc_mpi)
|
||||||
TARGET_LINK_LIBRARIES(exampleD rmc_mpi)
|
TARGET_LINK_LIBRARIES(exampleD rmc_mpi)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleE rmc_mpi)
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(exampleA eo)
|
TARGET_LINK_LIBRARIES(exampleA eo)
|
||||||
TARGET_LINK_LIBRARIES(exampleB eo)
|
TARGET_LINK_LIBRARIES(exampleB eo)
|
||||||
TARGET_LINK_LIBRARIES(exampleC eo)
|
TARGET_LINK_LIBRARIES(exampleC eo)
|
||||||
TARGET_LINK_LIBRARIES(exampleD eo)
|
TARGET_LINK_LIBRARIES(exampleD eo)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleE eo)
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(exampleA eoutils)
|
TARGET_LINK_LIBRARIES(exampleA eoutils)
|
||||||
TARGET_LINK_LIBRARIES(exampleB eoutils)
|
TARGET_LINK_LIBRARIES(exampleB eoutils)
|
||||||
TARGET_LINK_LIBRARIES(exampleC eoutils)
|
TARGET_LINK_LIBRARIES(exampleC eoutils)
|
||||||
TARGET_LINK_LIBRARIES(exampleD eoutils)
|
TARGET_LINK_LIBRARIES(exampleD eoutils)
|
||||||
|
TARGET_LINK_LIBRARIES(exampleE eoutils)
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ int main (int __argc, char * * __argv) {
|
||||||
loadParameters (__argc, __argv); /* Processing some parameters relative to the tackled
|
loadParameters (__argc, __argv); /* Processing some parameters relative to the tackled
|
||||||
problem (TSP) */
|
problem (TSP) */
|
||||||
|
|
||||||
RouteInit route_init; /* Its builds random routes */
|
RouteInit route_init; /* It builds random routes */
|
||||||
RouteEval full_eval; /* Full route evaluator */
|
RouteEval full_eval; /* Full route evaluator */
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -65,7 +65,6 @@ int main (int __argc, char * * __argv) {
|
||||||
|
|
||||||
ox_ea (ox_pop); /* Application to the given population */
|
ox_ea (ox_pop); /* Application to the given population */
|
||||||
|
|
||||||
|
|
||||||
peo :: run ();
|
peo :: run ();
|
||||||
peo :: finalize (); /* Termination */
|
peo :: finalize (); /* Termination */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,15 +70,9 @@ int main (int __argc, char * * __argv) {
|
||||||
peo :: finalize (); /* Termination */
|
peo :: finalize (); /* Termination */
|
||||||
|
|
||||||
|
|
||||||
|
std :: cout << ox_pop[ 0 ].fitness();
|
||||||
hc( ox_pop[ 0 ] );
|
hc( ox_pop[ 0 ] );
|
||||||
|
std :: cout << " -> " << ox_pop[ 0 ].fitness() << std :: endl;
|
||||||
|
|
||||||
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;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
#define CROSS_RATE 1.0
|
#define CROSS_RATE 1.0
|
||||||
#define MUT_RATE 0.01
|
#define MUT_RATE 0.01
|
||||||
|
|
||||||
#define MIG_FREQ 3
|
#define MIG_FREQ 1
|
||||||
#define MIG_SIZE 5
|
#define MIG_SIZE 5
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ int main (int __argc, char * * __argv) {
|
||||||
|
|
||||||
/* The migration policy */
|
/* The migration policy */
|
||||||
eoPeriodicContinue <Route> ox_mig_cont (MIG_FREQ); /* Migration occurs periodically */
|
eoPeriodicContinue <Route> ox_mig_cont (MIG_FREQ); /* Migration occurs periodically */
|
||||||
eoRandomSelect <Route> ox_mig_select_one; /* Emigrants are randomly selected */
|
eoStochTournamentSelect <Route> ox_mig_select_one; /* Emigrants are randomly selected */
|
||||||
eoSelectNumber <Route> ox_mig_select (ox_mig_select_one, MIG_SIZE);
|
eoSelectNumber <Route> ox_mig_select (ox_mig_select_one, MIG_SIZE);
|
||||||
eoPlusReplacement <Route> ox_mig_replace; /* Immigrants replace the worse individuals */
|
eoPlusReplacement <Route> ox_mig_replace; /* Immigrants replace the worse individuals */
|
||||||
|
|
||||||
|
|
@ -74,8 +74,7 @@ int main (int __argc, char * * __argv) {
|
||||||
|
|
||||||
ox_ea (ox_pop); /* Application to the given population */
|
ox_ea (ox_pop); /* Application to the given population */
|
||||||
// --------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// The Second EA ------------------------------------------------------------------------------------
|
// The Second EA ------------------------------------------------------------------------------------
|
||||||
|
|
@ -99,10 +98,9 @@ int main (int __argc, char * * __argv) {
|
||||||
peoSeqTransform <Route> ox_seq_transform2 (ox_transform2);
|
peoSeqTransform <Route> ox_seq_transform2 (ox_transform2);
|
||||||
eoEPReplacement <Route> ox_replace2 (2);
|
eoEPReplacement <Route> ox_replace2 (2);
|
||||||
|
|
||||||
|
|
||||||
/* The migration policy */
|
/* The migration policy */
|
||||||
eoPeriodicContinue <Route> ox_mig_cont2 (MIG_FREQ); /* Migration occurs periodically */
|
eoPeriodicContinue <Route> ox_mig_cont2 (MIG_FREQ); /* Migration occurs periodically */
|
||||||
eoRandomSelect <Route> ox_mig_select_one2; /* Emigrants are randomly selected */
|
eoStochTournamentSelect <Route> ox_mig_select_one2; /* Emigrants are randomly selected */
|
||||||
eoSelectNumber <Route> ox_mig_select2 (ox_mig_select_one2, MIG_SIZE);
|
eoSelectNumber <Route> ox_mig_select2 (ox_mig_select_one2, MIG_SIZE);
|
||||||
eoPlusReplacement <Route> ox_mig_replace2; /* Immigrants replace the worse individuals */
|
eoPlusReplacement <Route> ox_mig_replace2; /* Immigrants replace the worse individuals */
|
||||||
|
|
||||||
|
|
@ -119,7 +117,8 @@ int main (int __argc, char * * __argv) {
|
||||||
|
|
||||||
peo :: run ();
|
peo :: run ();
|
||||||
peo :: finalize (); /* Termination */
|
peo :: finalize (); /* Termination */
|
||||||
|
|
||||||
|
|
||||||
// rank 0 is assigned to the scheduler in the XML mapping file
|
// rank 0 is assigned to the scheduler in the XML mapping file
|
||||||
if ( getNodeRank() == 1 ) {
|
if ( getNodeRank() == 1 ) {
|
||||||
|
|
||||||
|
|
@ -127,5 +126,6 @@ int main (int __argc, char * * __argv) {
|
||||||
std::cout << "EA[ 1 ] -----> " << ox_pop2.best_element().fitness() << std::endl;
|
std::cout << "EA[ 1 ] -----> " << ox_pop2.best_element().fitness() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ int main (int __argc, char * * __argv) {
|
||||||
|
|
||||||
eoGenContinue <Route> ox_cont (NUM_GEN); /* A fixed number of iterations */
|
eoGenContinue <Route> ox_cont (NUM_GEN); /* A fixed number of iterations */
|
||||||
eoCheckPoint <Route> ox_checkpoint (ox_cont); /* Checkpoint */
|
eoCheckPoint <Route> ox_checkpoint (ox_cont); /* Checkpoint */
|
||||||
peoParaPopEval <Route> ox_pop_eval (full_eval);
|
peoSeqPopEval <Route> ox_pop_eval (full_eval);
|
||||||
eoStochTournamentSelect <Route> ox_select_one;
|
eoStochTournamentSelect <Route> ox_select_one;
|
||||||
eoSelectNumber <Route> ox_select (ox_select_one, POP_SIZE);
|
eoSelectNumber <Route> ox_select (ox_select_one, POP_SIZE);
|
||||||
eoSGATransform <Route> ox_transform (order_cross, CROSS_RATE, city_swap_mut, MUT_RATE);
|
eoSGATransform <Route> ox_transform (order_cross, CROSS_RATE, city_swap_mut, MUT_RATE);
|
||||||
|
|
|
||||||
83
trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleE.cpp
Normal file
83
trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleE.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
## deployment schema
|
## deployment schema
|
||||||
|
|
||||||
--schema=schemaA.xml
|
--schema=../src/schemaA.xml
|
||||||
|
|
||||||
## parameters
|
## parameters
|
||||||
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
## deployment schema
|
## deployment schema
|
||||||
|
|
||||||
--schema=schemaB.xml
|
--schema=../src/schemaB.xml
|
||||||
|
|
||||||
## parameters
|
## parameters
|
||||||
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
## deployment schema
|
## deployment schema
|
||||||
|
|
||||||
--schema=schemaC.xml
|
--schema=../src/schemaC.xml
|
||||||
|
|
||||||
## parameters
|
## parameters
|
||||||
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
## deployment schema
|
## deployment schema
|
||||||
|
|
||||||
--schema=schemaD.xml
|
--schema=../src/schemaD.xml
|
||||||
|
|
||||||
## parameters
|
## parameters
|
||||||
|
|
||||||
11
trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonE.param
Normal file
11
trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonE.param
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
## miscallenous parameters
|
||||||
|
|
||||||
|
--debug=false
|
||||||
|
|
||||||
|
## deployment schema
|
||||||
|
|
||||||
|
--schema=../src/schemaE.xml
|
||||||
|
|
||||||
|
## parameters
|
||||||
|
|
||||||
|
--inst=../../examples/tsp/benchs/eil101.tsp
|
||||||
16
trunk/paradiseo-peo/tutorial/Walkthrough/src/schemaE.xml
Normal file
16
trunk/paradiseo-peo/tutorial/Walkthrough/src/schemaE.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>
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue