From f4740e571c11325df407548aad4fa0cc75d9f21b Mon Sep 17 00:00:00 2001 From: canape Date: Thu, 24 Jan 2008 14:57:07 +0000 Subject: [PATCH] tutorial PEO modified git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@905 331e1502-861f-0410-8da2-ba01fb791d7f --- .../tutorial/Wrapper/CMakeLists.txt | 95 ------------- .../paradiseo-peo/tutorial/Wrapper/main1.cpp | 63 --------- .../paradiseo-peo/tutorial/Wrapper/main2.cpp | 99 ------------- .../paradiseo-peo/tutorial/Wrapper/main3.cpp | 64 --------- .../paradiseo-peo/tutorial/Wrapper/main4.cpp | 133 ------------------ .../paradiseo-peo/tutorial/Wrapper/main5.cpp | 78 ---------- .../paradiseo-peo/tutorial/Wrapper/main6.cpp | 78 ---------- .../paradiseo-peo/tutorial/Wrapper/main7.cpp | 90 ------------ trunk/paradiseo-peo/tutorial/Wrapper/param | 12 -- .../paradiseo-peo/tutorial/Wrapper/schema.xml | 16 --- 10 files changed, 728 deletions(-) delete mode 100644 trunk/paradiseo-peo/tutorial/Wrapper/CMakeLists.txt delete mode 100644 trunk/paradiseo-peo/tutorial/Wrapper/main1.cpp delete mode 100644 trunk/paradiseo-peo/tutorial/Wrapper/main2.cpp delete mode 100644 trunk/paradiseo-peo/tutorial/Wrapper/main3.cpp delete mode 100644 trunk/paradiseo-peo/tutorial/Wrapper/main4.cpp delete mode 100644 trunk/paradiseo-peo/tutorial/Wrapper/main5.cpp delete mode 100644 trunk/paradiseo-peo/tutorial/Wrapper/main6.cpp delete mode 100644 trunk/paradiseo-peo/tutorial/Wrapper/main7.cpp delete mode 100644 trunk/paradiseo-peo/tutorial/Wrapper/param delete mode 100644 trunk/paradiseo-peo/tutorial/Wrapper/schema.xml diff --git a/trunk/paradiseo-peo/tutorial/Wrapper/CMakeLists.txt b/trunk/paradiseo-peo/tutorial/Wrapper/CMakeLists.txt deleted file mode 100644 index f34c8fcbc..000000000 --- a/trunk/paradiseo-peo/tutorial/Wrapper/CMakeLists.txt +++ /dev/null @@ -1,95 +0,0 @@ - -###################################################################################### -### 0) Set the compiler and define targets to easily run the lessons -###################################################################################### - -SET (CMAKE_CXX_COMPILER mpicxx) - -ADD_CUSTOM_TARGET(install DEPENDS ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Wrapper/param ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Wrapper/schema.xml) - -ADD_CUSTOM_COMMAND( - TARGET install - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Wrapper/param - ${ParadisEO-PEO_BINARY_DIR}/tutorial/Wrapper) -ADD_CUSTOM_COMMAND( - TARGET install - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Wrapper/schema.xml - ${ParadisEO-PEO_BINARY_DIR}/tutorial/Wrapper) - -###################################################################################### - - -###################################################################################### -### 1) Include the sources -###################################################################################### - -INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src ${MOEO_SRC_DIR}/src ${MO_SRC_DIR}/src ${ParadisEO-PEO_SOURCE_DIR}/src ${TSP_SRC_DIR}) - -###################################################################################### - - -###################################################################################### -### 2) Specify where CMake can find the libraries (mandatory: before 3) ) -###################################################################################### - -IF(NOT WIN32 OR CYGWIN) - LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${MOEO_BIN_DIR}/lib ${ParadisEO-PEO_BINARY_DIR}/lib ${TSP_BINARY_DIR}/lib) -ENDIF(NOT WIN32 OR CYGWIN) - -# especially for Visual Studio -IF(WIN32 AND NOT CYGWIN) - LINK_DIRECTORIES(${EO_BIN_DIR}\\lib\\${CMAKE_BUILD_TYPE} ${ParadisEO-PEO_BINARY_DIR}\\lib\\${CMAKE_BUILD_TYPE} ${TSP_BINARY_DIR}\\lib\\${CMAKE_BUILD_TYPE}) -ENDIF(WIN32 AND NOT CYGWIN) - -###################################################################################### - - -###################################################################################### -### 3) Define your target(s): just an executable here -###################################################################################### - -ADD_EXECUTABLE(example1 main1.cpp) -ADD_DEPENDENCIES(example1 peo rmc_mpi) -ADD_EXECUTABLE(example2 main2.cpp) -ADD_DEPENDENCIES(example2 peo rmc_mpi) -ADD_EXECUTABLE(example3 main3.cpp) -ADD_DEPENDENCIES(example3 peo rmc_mpi) -ADD_EXECUTABLE(example4 main4.cpp) -ADD_DEPENDENCIES(example4 peo rmc_mpi) -ADD_EXECUTABLE(example5 main5.cpp) -ADD_DEPENDENCIES(example5 tsp peo rmc_mpi) -ADD_EXECUTABLE(example6 main6.cpp) -ADD_DEPENDENCIES(example6 tsp peo rmc_mpi) -ADD_EXECUTABLE(example7 main7.cpp) -ADD_DEPENDENCIES(example7 peo rmc_mpi) - -###################################################################################### - - -###################################################################################### -### 4) Optionnal: define your target(s)'s version: no effect for windows -###################################################################################### - - -###################################################################################### - - -###################################################################################### -### 5) Link the librairies -###################################################################################### - -TARGET_LINK_LIBRARIES(example1 ${XML2_LIBS} peo rmc_mpi eo eoutils) -TARGET_LINK_LIBRARIES(example2 ${XML2_LIBS} peo rmc_mpi eo eoutils) -TARGET_LINK_LIBRARIES(example3 ${XML2_LIBS} peo rmc_mpi eo eoutils) -TARGET_LINK_LIBRARIES(example4 ${XML2_LIBS} peo rmc_mpi eo eoutils) -TARGET_LINK_LIBRARIES(example5 ${XML2_LIBS} tsp peo rmc_mpi eo eoutils) -TARGET_LINK_LIBRARIES(example6 ${XML2_LIBS} tsp peo rmc_mpi eo eoutils) -TARGET_LINK_LIBRARIES(example7 ${XML2_LIBS} tsp peo rmc_mpi eo eoutils) - -###################################################################################### diff --git a/trunk/paradiseo-peo/tutorial/Wrapper/main1.cpp b/trunk/paradiseo-peo/tutorial/Wrapper/main1.cpp deleted file mode 100644 index e19e45a39..000000000 --- a/trunk/paradiseo-peo/tutorial/Wrapper/main1.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include -#include -typedef eoReal Indi; - -double f (const Indi & _indi) -{ - double sum; - sum=_indi[1]-pow(_indi[0],2); - sum=100*pow(sum,2); - sum+=pow((1-_indi[0]),2); - return (-sum); -} - -int main( int __argc, char** __argv ) -{ - - - - peo :: init( __argc, __argv ); - -// Parameters - const unsigned int VEC_SIZE = 2; - const unsigned int POP_SIZE = 20; - const unsigned int MAX_GEN = 300; - const double INIT_POSITION_MIN = -2.0; - const double INIT_POSITION_MAX = 2.0; - const float CROSS_RATE = 0.8; - const double EPSILON = 0.01; - const float MUT_RATE = 0.3; - rng.reseed (time(0)); - - -// Algorithm - eoGenContinue < Indi > genContPara (MAX_GEN); - eoCombinedContinue continuatorPara (genContPara); - eoCheckPoint checkpoint(continuatorPara); - peoEvalFunc mainEval( f ); - peoPopEval eval(mainEval); - eoUniformGenerator < double >uGen (INIT_POSITION_MIN, INIT_POSITION_MAX); - eoInitFixedLength < Indi > random (VEC_SIZE, uGen); - eoRankingSelect selectionStrategy; - eoSelectNumber select(selectionStrategy,POP_SIZE); - eoSegmentCrossover crossover; - eoUniformMutation mutation(EPSILON); - eoSGATransform transform(crossover,CROSS_RATE,mutation,MUT_RATE); - eoPlusReplacement replace; - eoEasyEA< Indi > eaAlg( checkpoint, eval, select, transform, replace ); - -// Population - eoPop < Indi > pop; - pop.append (POP_SIZE, random); - -// Wrapper - peoWrapper parallelEA( eaAlg, pop); - eval.setOwner(parallelEA); - peo :: run(); - peo :: finalize(); - if (getNodeRank()==1) - { - pop.sort(); - std::cout << "Final population :\n" << pop << std::endl; - } -} diff --git a/trunk/paradiseo-peo/tutorial/Wrapper/main2.cpp b/trunk/paradiseo-peo/tutorial/Wrapper/main2.cpp deleted file mode 100644 index a61318b44..000000000 --- a/trunk/paradiseo-peo/tutorial/Wrapper/main2.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include -#include -typedef eoReal Indi; - -double f (const Indi & _indi) -{ - double sum; - sum=_indi[1]-pow(_indi[0],2); - sum=100*pow(sum,2); - sum+=pow((1-_indi[0]),2); - return (-sum); -} - -int main( int __argc, char** __argv ) -{ - peo :: init( __argc, __argv ); - -// Parameters - const unsigned int VEC_SIZE = 2; - const unsigned int POP_SIZE = 20; - const unsigned int MAX_GEN = 300; - const double INIT_POSITION_MIN = -2.0; - const double INIT_POSITION_MAX = 2.0; - const float CROSS_RATE = 0.8; - const double EPSILON = 0.01; - const float MUT_RATE = 0.5; - const unsigned MIG_FREQ = 10; - const unsigned int MIG_SIZE = 5; - rng.reseed (time(0)); - RingTopology topology; - -// Algorithm - eoGenContinue < Indi > genContPara (MAX_GEN); - eoCombinedContinue continuatorPara (genContPara); - eoCheckPoint checkpoint(continuatorPara); - peoEvalFunc mainEval( f ); - peoPopEval eval(mainEval); - eoUniformGenerator < double >uGen (INIT_POSITION_MIN, INIT_POSITION_MAX); - eoInitFixedLength < Indi > random (VEC_SIZE, uGen); - eoRankingSelect selectionStrategy; - eoSelectNumber select(selectionStrategy,POP_SIZE); - eoSegmentCrossover crossover; - eoUniformMutation mutation(EPSILON); - peoTransform transform(crossover,CROSS_RATE,mutation,MUT_RATE); - peoPop < Indi > pop; - pop.append (POP_SIZE, random); - eoPlusReplacement replace; - eoRandomSelect mig_select_one; - eoSelector > mig_select (mig_select_one,MIG_SIZE,pop); - eoReplace > mig_replace (replace,pop); - peoSyncIslandMig > mig(MIG_FREQ,mig_select,mig_replace,topology,pop,pop); - checkpoint.add(mig); - eoEasyEA< Indi > eaAlg( checkpoint, eval, select, transform, replace ); - -// Algorithm - eoGenContinue < Indi > genContPara2 (MAX_GEN); - eoCombinedContinue continuatorPara2 (genContPara2); - eoCheckPoint checkpoint2(continuatorPara2); - peoEvalFunc mainEval2( f ); - peoPopEval eval2(mainEval2); - eoUniformGenerator < double >uGen2 (INIT_POSITION_MIN, INIT_POSITION_MAX); - eoInitFixedLength < Indi > random2 (VEC_SIZE, uGen2); - eoRankingSelect selectionStrategy2; - eoSelectNumber select2(selectionStrategy2,POP_SIZE); - eoSegmentCrossover crossover2; - eoUniformMutation mutation2(EPSILON); - peoTransform transform2(crossover2,CROSS_RATE,mutation2,MUT_RATE); - peoPop < Indi > pop2; - pop2.append (POP_SIZE, random2); - eoPlusReplacement replace2; - eoRandomSelect mig_select_one2; - eoSelector > mig_select2 (mig_select_one2,MIG_SIZE,pop2); - eoReplace > mig_replace2 (replace2,pop2); - peoSyncIslandMig > mig2(MIG_FREQ,mig_select2,mig_replace2,topology,pop2,pop2); - checkpoint2.add(mig2); - eoEasyEA< Indi > eaAlg2( checkpoint2, eval2, select2, transform2, replace2 ); - - - peoWrapper parallelEA( eaAlg, pop); - eval.setOwner(parallelEA); - transform.setOwner(parallelEA); - mig.setOwner(parallelEA); - - peoWrapper parallelEA2( eaAlg2, pop2); - eval2.setOwner(parallelEA2); - transform2.setOwner(parallelEA2); - mig2.setOwner(parallelEA2); - - peo :: run(); - peo :: finalize(); - - - - if (getNodeRank()==1) - { - pop.sort(); - std::cout << "Final population :\n" << pop << std::endl; - } -} diff --git a/trunk/paradiseo-peo/tutorial/Wrapper/main3.cpp b/trunk/paradiseo-peo/tutorial/Wrapper/main3.cpp deleted file mode 100644 index b9d1b512b..000000000 --- a/trunk/paradiseo-peo/tutorial/Wrapper/main3.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include -#include - -typedef eoRealParticle < double >Indi; - -double f (const Indi & _indi) -{ - double sum; - sum=_indi[1]-pow(_indi[0],2); - sum=100*pow(sum,2); - sum+=pow((1-_indi[0]),2); - return (-sum); -} - -int main( int __argc, char** __argv ) -{ - - peo :: init( __argc, __argv ); - const unsigned int VEC_SIZE = 2; - const unsigned int POP_SIZE = 20; - const unsigned int NEIGHBORHOOD_SIZE= 6; - const unsigned int MAX_GEN = 300; - const double INIT_POSITION_MIN = -2.0; - const double INIT_POSITION_MAX = 2.0; - const double INIT_VELOCITY_MIN = -1.; - const double INIT_VELOCITY_MAX = 1.; - const double weight = 1; - const double C1 = 0.5; - const double C2 = 2.; - rng.reseed (time(0)); - eoGenContinue < Indi > genContPara (MAX_GEN); - eoCombinedContinue continuatorPara (genContPara); - eoCheckPoint checkpoint(continuatorPara); - - peoEvalFunc plainEval(f); - peoPopEval< Indi > eval(plainEval); - - eoUniformGenerator < double >uGen (INIT_POSITION_MIN, INIT_POSITION_MAX); - eoInitFixedLength < Indi > random (VEC_SIZE, uGen); - eoUniformGenerator < double >sGen (INIT_VELOCITY_MIN, INIT_VELOCITY_MAX); - eoVelocityInitFixedLength < Indi > veloRandom (VEC_SIZE, sGen); - eoFirstIsBestInit < Indi > localInit; - eoRealVectorBounds bndsFlight(VEC_SIZE,INIT_POSITION_MIN,INIT_POSITION_MAX); - eoStandardFlight < Indi > flight(bndsFlight); - eoPop < Indi > pop; - pop.append (POP_SIZE, random); - eoLinearTopology topology(NEIGHBORHOOD_SIZE); - eoRealVectorBounds bnds(VEC_SIZE,INIT_VELOCITY_MIN,INIT_VELOCITY_MAX); - eoStandardVelocity < Indi > velocity (topology,weight,C1,C2,bnds); - eoInitializer init(eval,veloRandom,localInit,topology,pop); - -// Parallel algorithm - - eoSyncEasyPSO psa(init,checkpoint,eval, velocity, flight); - peoWrapper parallelPSO( psa, pop); - eval.setOwner(parallelPSO); - peo :: run(); - peo :: finalize(); - if (getNodeRank()==1) - { - pop.sort(); - std::cout << "Final population :\n" << pop << std::endl; - } -} diff --git a/trunk/paradiseo-peo/tutorial/Wrapper/main4.cpp b/trunk/paradiseo-peo/tutorial/Wrapper/main4.cpp deleted file mode 100644 index e69aac663..000000000 --- a/trunk/paradiseo-peo/tutorial/Wrapper/main4.cpp +++ /dev/null @@ -1,133 +0,0 @@ -#include -#include - - -typedef eoRealParticle < double >Indi; - -double f (const Indi & _indi) -{ - double sum; - sum=_indi[1]-pow(_indi[0],2); - sum=100*pow(sum,2); - sum+=pow((1-_indi[0]),2); - return (-sum); -} - -int main( int __argc, char** __argv ) -{ - - peo :: init( __argc, __argv ); - const unsigned int VEC_SIZE = 2; - const unsigned int POP_SIZE = 20; - const unsigned int NEIGHBORHOOD_SIZE= 6; - const unsigned int MAX_GEN = 100; - const double INIT_POSITION_MIN = -2.0; - const double INIT_POSITION_MAX = 2.0; - const double INIT_VELOCITY_MIN = -1.; - const double INIT_VELOCITY_MAX = 1.; - const unsigned int MIG_FREQ = 10; - const double omega = 1; - const double C1 = 0.5; - const double C2 = 2.; - rng.reseed (time(0)); - -// Island model - - RingTopology topologyMig; - -// First - eoGenContinue < Indi > genContPara (MAX_GEN); - eoCombinedContinue continuatorPara (genContPara); - eoCheckPoint checkpoint(continuatorPara); - peoEvalFunc plainEval(f); - peoPopEval< Indi > eval(plainEval); - eoUniformGenerator < double >uGen (INIT_POSITION_MIN, INIT_POSITION_MAX); - eoInitFixedLength < Indi > random (VEC_SIZE, uGen); - eoUniformGenerator < double >sGen (INIT_VELOCITY_MIN, INIT_VELOCITY_MAX); - eoVelocityInitFixedLength < Indi > veloRandom (VEC_SIZE, sGen); - eoFirstIsBestInit < Indi > localInit; - eoRealVectorBounds bndsFlight(VEC_SIZE,INIT_POSITION_MIN,INIT_POSITION_MAX); - eoStandardFlight < Indi > flight(bndsFlight); - peoPop < Indi > pop; - pop.append (POP_SIZE, random); - eoLinearTopology topology(NEIGHBORHOOD_SIZE); - eoRealVectorBounds bnds(VEC_SIZE,INIT_VELOCITY_MIN,INIT_VELOCITY_MAX); - eoStandardVelocity < Indi > velocity (topology,omega,C1,C2,bnds); - eoInitializer init(eval,veloRandom,localInit,topology,pop); - -// Island model - - eoPeriodicContinue< Indi > mig_cont( MIG_FREQ ); - peoPSOSelect mig_selec(topology); - peoWorstPositionReplacement mig_replac; - - // Specific implementation (peoData.h) - - eoContinuator cont(mig_cont, pop); - eoSelector > mig_select (mig_selec,1,pop); - eoReplace > mig_replace (mig_replac,pop); - - -// Second - - eoGenContinue < Indi > genContPara2 (MAX_GEN); - eoCombinedContinue continuatorPara2 (genContPara2); - eoCheckPoint checkpoint2(continuatorPara2); - peoEvalFunc plainEval2(f); - peoPopEval< Indi > eval2(plainEval2); - eoUniformGenerator < double >uGen2 (INIT_POSITION_MIN, INIT_POSITION_MAX); - eoInitFixedLength < Indi > random2 (VEC_SIZE, uGen2); - eoUniformGenerator < double >sGen2 (INIT_VELOCITY_MIN, INIT_VELOCITY_MAX); - eoVelocityInitFixedLength < Indi > veloRandom2 (VEC_SIZE, sGen2); - eoFirstIsBestInit < Indi > localInit2; - eoRealVectorBounds bndsFlight2(VEC_SIZE,INIT_POSITION_MIN,INIT_POSITION_MAX); - eoStandardFlight < Indi > flight2(bndsFlight2); - peoPop < Indi > pop2; - pop2.append (POP_SIZE, random2); - eoLinearTopology topology2(NEIGHBORHOOD_SIZE); - eoRealVectorBounds bnds2(VEC_SIZE,INIT_VELOCITY_MIN,INIT_VELOCITY_MAX); - eoStandardVelocity < Indi > velocity2 (topology2,omega,C1,C2,bnds2); - eoInitializer init2(eval2,veloRandom2,localInit2,topology2,pop2); - -// Island model - - eoPeriodicContinue< Indi > mig_cont2( MIG_FREQ ); - peoPSOSelect mig_selec2(topology2); - peoWorstPositionReplacement mig_replac2; - -// Specific implementation (peoData.h) - - eoContinuator cont2(mig_cont2,pop2); - eoSelector > mig_select2 (mig_selec2,1,pop2); - eoReplace > mig_replace2 (mig_replac2,pop2); - - -// Island model - - peoAsyncIslandMig< Indi, peoPop > mig(cont,mig_select, mig_replace, topologyMig, pop, pop); - checkpoint.add( mig ); - peoAsyncIslandMig< Indi, peoPop > mig2(cont2,mig_select2, mig_replace2, topologyMig, pop2, pop2); - checkpoint2.add( mig2 ); - - -// Parallel algorithm - - eoSyncEasyPSO psa(init,checkpoint,eval, velocity, flight); - peoWrapper parallelPSO( psa, pop); - eval.setOwner(parallelPSO); - mig.setOwner(parallelPSO); - eoSyncEasyPSO psa2(init2,checkpoint2,eval2, velocity2, flight2); - peoWrapper parallelPSO2( psa2, pop2); - eval2.setOwner(parallelPSO2); - mig2.setOwner(parallelPSO2); - peo :: run(); - peo :: finalize(); - if (getNodeRank()==1) - { - pop.sort(); - pop2.sort(); - std::cout << "Final population :\n" << pop << std::endl; - std::cout << "Final population :\n" << pop2 << std::endl; - } - -} diff --git a/trunk/paradiseo-peo/tutorial/Wrapper/main5.cpp b/trunk/paradiseo-peo/tutorial/Wrapper/main5.cpp deleted file mode 100644 index 8ea4264d0..000000000 --- a/trunk/paradiseo-peo/tutorial/Wrapper/main5.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#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 100 -#define CROSS_RATE 1.0 -#define MUT_RATE 0.01 - - -int main (int __argc, char * * __argv) -{ - - peo :: init (__argc, __argv); - loadParameters (__argc, __argv); - RouteInit route_init; - RouteEval full_eval; - OrderXover order_cross; - PartialMappedXover pm_cross; - EdgeXover edge_cross; - CitySwap city_swap_mut; - -// Initialization of the local search - TwoOptInit pmx_two_opt_init; - TwoOptNext pmx_two_opt_next; - TwoOptIncrEval pmx_two_opt_incr_eval; - moBestImprSelect pmx_two_opt_move_select; - moHC hc (pmx_two_opt_init, pmx_two_opt_next, pmx_two_opt_incr_eval, pmx_two_opt_move_select, full_eval); - -// EA - eoPop pop (POP_SIZE, route_init); - eoGenContinue cont (NUM_GEN); - eoCheckPoint checkpoint (cont); - eoEvalFuncCounter< Route > eval(full_eval); - eoStochTournamentSelect select_one; - eoSelectNumber select (select_one, POP_SIZE); - eoSGATransform transform (order_cross, CROSS_RATE, city_swap_mut, MUT_RATE); - eoEPReplacement replace (2); - eoEasyEA< Route > eaAlg( checkpoint, eval, select, transform, replace ); - peoWrapper parallelEA( eaAlg, pop); - peo :: run (); - peo :: finalize (); - - if (getNodeRank()==1) - { - pop.sort(); - std :: cout << "\nResult before the local search\n"; - for(unsigned i=0;i initParallelHC (hc); - peoWrapper parallelHC (initParallelHC, pop); - initParallelHC.setOwner(parallelHC); - peo :: run( ); - peo :: finalize( ); - - if (getNodeRank()==1) - { - std :: cout << "\nResult after the local search\n"; - pop.sort(); - for(unsigned i=0;i - -#define POP_SIZE 10 -#define NUM_GEN 200 -#define CROSS_RATE 1.0 -#define MUT_RATE 0.1 - - -int main (int __argc, char * * __argv) -{ - - peo :: init (__argc, __argv); - loadParameters (__argc, __argv); - RouteInit route_init; - RouteEval full_eval; - OrderXover order_cross; - PartialMappedXover pm_cross; - EdgeXover edge_cross; - CitySwap city_swap_mut; - -// Local search - TwoOptInit pmx_two_opt_init; - TwoOptNext pmx_two_opt_next; - TwoOptIncrEval pmx_two_opt_incr_eval; - moBestImprSelect pmx_two_opt_move_select; - moHC hc (pmx_two_opt_init, pmx_two_opt_next, pmx_two_opt_incr_eval, pmx_two_opt_move_select, full_eval); - eoPop pop (POP_SIZE, route_init); - peoMultiStart initParallelHC (hc); - peoWrapper parallelHC (initParallelHC, pop); - initParallelHC.setOwner(parallelHC); - peo :: run( ); - peo :: finalize( ); - - if (getNodeRank()==1) - { - std :: cout << "\nResult before the EA\n"; - pop.sort(); - for(unsigned i=0;i cont (NUM_GEN); - eoCheckPoint checkpoint (cont); - eoEvalFuncCounter< Route > eval(full_eval); - eoStochTournamentSelect select_one; - eoSelectNumber select (select_one, POP_SIZE); - eoSGATransform transform (order_cross, CROSS_RATE, city_swap_mut, MUT_RATE); - eoEPReplacement replace (2); - eoEasyEA< Route > eaAlg( checkpoint, eval, select, transform, replace ); - peoWrapper parallelEA( eaAlg, pop); - peo :: run (); - peo :: finalize (); - - if (getNodeRank()==1) - { - std :: cout << "\nResult after the EA\n"; - pop.sort(); - for(unsigned i=0;i -#include - -typedef eoRealParticle < double >Indi; - -double f (const Indi & _indi) -{ - double sum; - sum=_indi[1]-pow(_indi[0],2); - sum=100*pow(sum,2); - sum+=pow((1-_indi[0]),2); - return (-sum); -} - -template -class eoResizerInit: public eoInit -{ - public: - - typedef typename EOT::AtomType AtomType; - - eoResizerInit(unsigned _size) - : size(_size){} - - virtual void operator()(EOT& chrom) - { - chrom.resize(size); - chrom.invalidate(); - } - private : - unsigned size; -}; - - -int main( int __argc, char** __argv ) -{ - - peo :: init( __argc, __argv ); - const unsigned int VEC_SIZE = 2; - const unsigned int POP_SIZE = 20; - const unsigned int NEIGHBORHOOD_SIZE= 6; - const unsigned int MAX_GEN = 300; - const double INIT_POSITION_MIN = -2.0; - const double INIT_POSITION_MAX = 2.0; - const double INIT_VELOCITY_MIN = -1.; - const double INIT_VELOCITY_MAX = 1.; - const double omega = 1; - const double C1 = 0.5; - const double C2 = 2.; - rng.reseed (time(0)); - eoGenContinue < Indi > genContPara (MAX_GEN); - eoCombinedContinue continuatorPara (genContPara); - eoCheckPoint checkpoint(continuatorPara); - eoUniformGenerator < double >uGen (INIT_POSITION_MIN, INIT_POSITION_MAX); - eoUniformGenerator < double >sGen (INIT_VELOCITY_MIN, INIT_VELOCITY_MAX); - eoVelocityInitFixedLength < Indi > veloRandom (VEC_SIZE, sGen); - eoFirstIsBestInit < Indi > localInit; - eoRealVectorBounds bndsFlight(VEC_SIZE,INIT_POSITION_MIN,INIT_POSITION_MAX); - eoStandardFlight < Indi > flight(bndsFlight); - eoLinearTopology topology(NEIGHBORHOOD_SIZE); - eoRealVectorBounds bnds(VEC_SIZE,INIT_VELOCITY_MIN,INIT_VELOCITY_MAX); - eoStandardVelocity < Indi > velocity (topology,omega,C1,C2,bnds); - - eoResizerInit sizeInit(VEC_SIZE); - // need at least a size initialization - eoPop < Indi > pop(POP_SIZE,sizeInit); - eoInitFixedLength < Indi > randomSeq (VEC_SIZE, uGen); - peoMultiStart initRandom (randomSeq); - peoWrapper random (initRandom,pop); - initRandom.setOwner(random); - peo :: run( ); - peo :: finalize( ); - -// Parallel algorithm - - peo :: init (__argc, __argv); - peoEvalFunc plainEval(f); - peoPopEval< Indi > eval(plainEval); - eoInitializer init(eval,veloRandom,localInit,topology,pop); - eoSyncEasyPSO psa(init,checkpoint,eval, velocity, flight); - peoWrapper parallelPSO( psa, pop); - eval.setOwner(parallelPSO); - peo :: run(); - peo :: finalize(); - if (getNodeRank()==1) - { - pop.sort(); - std::cout << "Final population :\n" << pop << std::endl; - } -} diff --git a/trunk/paradiseo-peo/tutorial/Wrapper/param b/trunk/paradiseo-peo/tutorial/Wrapper/param deleted file mode 100644 index eb843c65f..000000000 --- a/trunk/paradiseo-peo/tutorial/Wrapper/param +++ /dev/null @@ -1,12 +0,0 @@ -## miscallenous parameters - ---debug=false - -## deployment schema - ---schema=schema.xml - -## parameters - ---inst=../examples/tsp/benchs/eil101.tsp - diff --git a/trunk/paradiseo-peo/tutorial/Wrapper/schema.xml b/trunk/paradiseo-peo/tutorial/Wrapper/schema.xml deleted file mode 100644 index 23da1d55e..000000000 --- a/trunk/paradiseo-peo/tutorial/Wrapper/schema.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - 1 - 2 - - - - - - -