diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/src/CMakeLists.txt b/trunk/paradiseo-peo/tutorial/Walkthrough/src/CMakeLists.txt index d69162fb0..3b5bf9052 100644 --- a/trunk/paradiseo-peo/tutorial/Walkthrough/src/CMakeLists.txt +++ b/trunk/paradiseo-peo/tutorial/Walkthrough/src/CMakeLists.txt @@ -41,21 +41,25 @@ 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) ###################################################################################### @@ -70,6 +74,7 @@ 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}") ###################################################################################### @@ -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(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) ###################################################################################### diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleA.cpp b/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleA.cpp index 4f9577320..fa86c5ae6 100644 --- a/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleA.cpp +++ b/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleA.cpp @@ -32,7 +32,7 @@ int main (int __argc, char * * __argv) { loadParameters (__argc, __argv); /* Processing some parameters relative to the tackled problem (TSP) */ - RouteInit route_init; /* Its builds random routes */ + RouteInit route_init; /* It builds random routes */ 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 */ - peo :: run (); peo :: finalize (); /* Termination */ diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleB.cpp b/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleB.cpp index a1066a2b8..0de63ab2f 100644 --- a/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleB.cpp +++ b/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleB.cpp @@ -70,15 +70,9 @@ int main (int __argc, char * * __argv) { peo :: finalize (); /* Termination */ + std :: cout << ox_pop[ 0 ].fitness(); 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; - } + std :: cout << " -> " << ox_pop[ 0 ].fitness() << std :: endl; return 0; diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleC.cpp b/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleC.cpp index 0e6834746..4944fcaa9 100644 --- a/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleC.cpp +++ b/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleC.cpp @@ -23,7 +23,7 @@ #define CROSS_RATE 1.0 #define MUT_RATE 0.01 -#define MIG_FREQ 3 +#define MIG_FREQ 1 #define MIG_SIZE 5 @@ -62,7 +62,7 @@ int main (int __argc, char * * __argv) { /* The migration policy */ eoPeriodicContinue ox_mig_cont (MIG_FREQ); /* Migration occurs periodically */ - eoRandomSelect ox_mig_select_one; /* Emigrants are randomly selected */ + eoStochTournamentSelect ox_mig_select_one; /* Emigrants are randomly selected */ eoSelectNumber ox_mig_select (ox_mig_select_one, MIG_SIZE); eoPlusReplacement 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 */ // -------------------------------------------------------------------------------------------------- - - + // The Second EA ------------------------------------------------------------------------------------ @@ -99,10 +98,9 @@ int main (int __argc, char * * __argv) { peoSeqTransform ox_seq_transform2 (ox_transform2); eoEPReplacement ox_replace2 (2); - /* The migration policy */ eoPeriodicContinue ox_mig_cont2 (MIG_FREQ); /* Migration occurs periodically */ - eoRandomSelect ox_mig_select_one2; /* Emigrants are randomly selected */ + eoStochTournamentSelect ox_mig_select_one2; /* Emigrants are randomly selected */ eoSelectNumber ox_mig_select2 (ox_mig_select_one2, MIG_SIZE); eoPlusReplacement ox_mig_replace2; /* Immigrants replace the worse individuals */ @@ -119,7 +117,8 @@ int main (int __argc, char * * __argv) { peo :: run (); peo :: finalize (); /* Termination */ - + + // rank 0 is assigned to the scheduler in the XML mapping file if ( getNodeRank() == 1 ) { @@ -127,5 +126,6 @@ int main (int __argc, char * * __argv) { std::cout << "EA[ 1 ] -----> " << ox_pop2.best_element().fitness() << std::endl; } + return 0; } diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleD.cpp b/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleD.cpp index d4b55a3ab..16d05cb27 100644 --- a/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleD.cpp +++ b/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleD.cpp @@ -46,7 +46,7 @@ int main (int __argc, char * * __argv) { eoGenContinue ox_cont (NUM_GEN); /* A fixed number of iterations */ eoCheckPoint ox_checkpoint (ox_cont); /* Checkpoint */ - peoParaPopEval ox_pop_eval (full_eval); + peoSeqPopEval ox_pop_eval (full_eval); eoStochTournamentSelect ox_select_one; eoSelectNumber ox_select (ox_select_one, POP_SIZE); eoSGATransform ox_transform (order_cross, CROSS_RATE, city_swap_mut, MUT_RATE); diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleE.cpp b/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleE.cpp new file mode 100644 index 000000000..a5ecc3335 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/Walkthrough/src/exampleE.cpp @@ -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 + +#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 *> 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 ox_pop (POP_SIZE, route_init); /* Population */ + + eoGenContinue ox_cont (NUM_GEN); /* A fixed number of iterations */ + eoCheckPoint ox_checkpoint (ox_cont); /* Checkpoint */ + peoParaPopEval ox_pop_eval (full_eval); + eoStochTournamentSelect ox_select_one; + eoSelectNumber ox_select (ox_select_one, POP_SIZE); + eoSGATransform ox_transform (order_cross, CROSS_RATE, city_swap_mut, MUT_RATE); + peoSeqTransform ox_para_transform (ox_transform); + eoEPReplacement ox_replace (2); + + + peoEA 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; +} diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonA.param b/trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonA.param similarity index 81% rename from trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonA.param rename to trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonA.param index 7834acc95..ab6d3b3cb 100644 --- a/trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonA.param +++ b/trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonA.param @@ -4,7 +4,7 @@ ## deployment schema ---schema=schemaA.xml +--schema=../src/schemaA.xml ## parameters diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonB.param b/trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonB.param similarity index 81% rename from trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonB.param rename to trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonB.param index 7f3afded5..8b9394f01 100644 --- a/trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonB.param +++ b/trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonB.param @@ -4,7 +4,7 @@ ## deployment schema ---schema=schemaB.xml +--schema=../src/schemaB.xml ## parameters diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonC.param b/trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonC.param similarity index 81% rename from trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonC.param rename to trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonC.param index 164d3d82b..0683ddd9c 100644 --- a/trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonC.param +++ b/trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonC.param @@ -4,7 +4,7 @@ ## deployment schema ---schema=schemaC.xml +--schema=../src/schemaC.xml ## parameters diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonD.param b/trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonD.param similarity index 81% rename from trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonD.param rename to trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonD.param index 834fbe9e9..f01278be3 100644 --- a/trunk/paradiseo-peo/tutorial/Walkthrough/build/lessonD.param +++ b/trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonD.param @@ -4,7 +4,7 @@ ## deployment schema ---schema=schemaD.xml +--schema=../src/schemaD.xml ## parameters diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonE.param b/trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonE.param new file mode 100644 index 000000000..b21c786ba --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/Walkthrough/src/lessonE.param @@ -0,0 +1,11 @@ +## miscallenous parameters + +--debug=false + +## deployment schema + +--schema=../src/schemaE.xml + +## parameters + +--inst=../../examples/tsp/benchs/eil101.tsp diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaA.xml b/trunk/paradiseo-peo/tutorial/Walkthrough/src/schemaA.xml similarity index 100% rename from trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaA.xml rename to trunk/paradiseo-peo/tutorial/Walkthrough/src/schemaA.xml diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaB.xml b/trunk/paradiseo-peo/tutorial/Walkthrough/src/schemaB.xml similarity index 100% rename from trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaB.xml rename to trunk/paradiseo-peo/tutorial/Walkthrough/src/schemaB.xml diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaC.xml b/trunk/paradiseo-peo/tutorial/Walkthrough/src/schemaC.xml similarity index 100% rename from trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaC.xml rename to trunk/paradiseo-peo/tutorial/Walkthrough/src/schemaC.xml diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaD.xml b/trunk/paradiseo-peo/tutorial/Walkthrough/src/schemaD.xml similarity index 100% rename from trunk/paradiseo-peo/tutorial/Walkthrough/build/schemaD.xml rename to trunk/paradiseo-peo/tutorial/Walkthrough/src/schemaD.xml diff --git a/trunk/paradiseo-peo/tutorial/Walkthrough/src/schemaE.xml b/trunk/paradiseo-peo/tutorial/Walkthrough/src/schemaE.xml new file mode 100644 index 000000000..b352f8b19 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/Walkthrough/src/schemaE.xml @@ -0,0 +1,16 @@ + + + + + + + + 1 + + + + + + + +