diff --git a/trunk/paradiseo-peo/tutorial/CMakeLists.txt b/trunk/paradiseo-peo/tutorial/CMakeLists.txt index 75912cafb..0dd4364c9 100644 --- a/trunk/paradiseo-peo/tutorial/CMakeLists.txt +++ b/trunk/paradiseo-peo/tutorial/CMakeLists.txt @@ -3,14 +3,14 @@ ### 1) Definitions (required for tsp target) ###################################################################################### -SET(TSP_SRC_DIR ${ParadisEO-PEO_SOURCE_DIR}/tutorial/examples/tsp) -SET(TSP_BINARY_DIR ${ParadisEO-PEO_BINARY_DIR}/tutorial/examples/tsp) +#SET(TSP_SRC_DIR ${ParadisEO-PEO_SOURCE_DIR}/tutorial/examples/tsp) +#SET(TSP_BINARY_DIR ${ParadisEO-PEO_BINARY_DIR}/tutorial/examples/tsp) ###################################################################################### ###################################################################################### ### 2) Where must cmake go now ? ###################################################################################### -SUBDIRS(examples Lesson1 Lesson2 Lesson3 Lesson4 Lesson5 Lesson6 Walkthrough) +SUBDIRS(Lesson1 Lesson2 Lesson3 Lesson4 Lesson5) ###################################################################################### diff --git a/trunk/paradiseo-peo/tutorial/Lesson1/CMakeLists.txt b/trunk/paradiseo-peo/tutorial/Lesson1/CMakeLists.txt index 8f9cc5115..f142b04d2 100644 --- a/trunk/paradiseo-peo/tutorial/Lesson1/CMakeLists.txt +++ b/trunk/paradiseo-peo/tutorial/Lesson1/CMakeLists.txt @@ -5,14 +5,14 @@ SET (CMAKE_CXX_COMPILER mpicxx) -ADD_CUSTOM_TARGET(install DEPENDS ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson1/lesson.param ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson1/schema.xml) +ADD_CUSTOM_TARGET(install DEPENDS ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson1/param ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson1/schema.xml) ADD_CUSTOM_COMMAND( TARGET install POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson1/lesson.param + ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson1/param ${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson1) ADD_CUSTOM_COMMAND( TARGET install @@ -21,13 +21,7 @@ ADD_CUSTOM_COMMAND( ARGS -E copy_if_different ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson1/schema.xml ${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson1) -ADD_CUSTOM_COMMAND( - TARGET install - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson1/ParadisEO-PEO_Lesson1.pdf - ${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson1) + ###################################################################################### @@ -35,7 +29,7 @@ ADD_CUSTOM_COMMAND( ### 1) Include the sources ###################################################################################### -INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src ${MO_SRC_DIR}/src ${ParadisEO-PEO_SOURCE_DIR}/src ${TSP_SRC_DIR}) +INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src ${MO_SRC_DIR}/src ${ParadisEO-PEO_SOURCE_DIR}/src) ###################################################################################### @@ -45,12 +39,12 @@ INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src ${MO_SRC_DIR}/src ${ParadisEO-PEO_SOURCE_D ###################################################################################### IF(NOT WIN32 OR CYGWIN) - LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${ParadisEO-PEO_BINARY_DIR}/lib ${TSP_BINARY_DIR}/lib) + LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${ParadisEO-PEO_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}) + LINK_DIRECTORIES(${EO_BIN_DIR}\\lib\\${CMAKE_BUILD_TYPE} ${ParadisEO-PEO_BINARY_DIR}\\lib\\${CMAKE_BUILD_TYPE}) ENDIF(WIN32 AND NOT CYGWIN) ###################################################################################### @@ -59,8 +53,10 @@ ENDIF(WIN32 AND NOT CYGWIN) ### 3) Define your target(s): just an executable here ###################################################################################### -ADD_EXECUTABLE(tspExample main.cpp) -ADD_DEPENDENCIES(tspExample tsp peo rmc_mpi) +ADD_EXECUTABLE(pso mainPSO.cpp) +ADD_DEPENDENCIES(pso peo rmc_mpi) +ADD_EXECUTABLE(ea mainEA.cpp) +ADD_DEPENDENCIES(ea peo rmc_mpi) ###################################################################################### @@ -69,7 +65,8 @@ ADD_DEPENDENCIES(tspExample tsp peo rmc_mpi) ###################################################################################### SET(LESSON1_VERSION ${GLOBAL_VERSION}) -SET_TARGET_PROPERTIES(tspExample PROPERTIES VERSION "${LESSON1_VERSION}") +SET_TARGET_PROPERTIES(pso PROPERTIES VERSION "${LESSON1_VERSION}") +SET_TARGET_PROPERTIES(ea PROPERTIES VERSION "${LESSON1_VERSION}") ###################################################################################### @@ -77,7 +74,8 @@ SET_TARGET_PROPERTIES(tspExample PROPERTIES VERSION "${LESSON1_VERSION}") ### 5) Link the librairies ###################################################################################### -TARGET_LINK_LIBRARIES(tspExample ${XML2_LIBS} tsp peo rmc_mpi eo eoutils) +TARGET_LINK_LIBRARIES(pso ${XML2_LIBS} peo rmc_mpi eo eoutils) +TARGET_LINK_LIBRARIES(ea ${XML2_LIBS} peo rmc_mpi eo eoutils) ###################################################################################### diff --git a/trunk/paradiseo-peo/tutorial/Lesson1/doclsn.h b/trunk/paradiseo-peo/tutorial/Lesson1/doclsn.h deleted file mode 100644 index 544edc583..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson1/doclsn.h +++ /dev/null @@ -1,498 +0,0 @@ -//! \mainpage Creating a simple ParadisEO-PEO Evolutionary Algorithm -//! -//! \section structure Introduction -//! -//! One of the first steps in designing an evolutionary algorithm using the ParadisEO-PEO framework -//! consists in having a clear overview of the implemented algorithm. A brief pseudo-code description is offered -//! bellow - the entire source code for the ParadisEO-PEO evolutionary algorithm is defined in the peoEA.h -//! header file. The main elements to be considered when building an evolutionary algorithm are the transformation -//! operators, i.e. crossover and mutation, the evaluation function, the continuation criterion and the selection -//! and replacement strategy. -//! -//! -//! -//! -//! -//! -//! -//! -//!
do {    
         select( population, offsprings );   // select the offsprings from the current population
         transform( offsprings );   // crossover and mutation operators are applied on the selected offsprings
         evaluate( offsprings );   // evaluation step of the resulting offsprings
         replace( population, offsprings );   // replace the individuals in the current population whith individuals from the offspring population, according to a specified replacement strategy
} while ( eaCheckpointContinue( population ) );   // checkpoint operators are applied on the current population
-//! -//! The peoEA class offers an elementary evolutionary algorithm implementation. The peoEA class has the underlying structure -//! for including parallel evaluation and parallel transformation operators, migration operators etc. Although there is -//! no restriction on using the algorithms provided by the EO framework, no parallelism is provided - the EO implementation is exclusively sequential. -//!
-//! -//! \section requirements Requirements -//! -//! You should have already installed the ParadisEO-PEO package - this requires several additional packages which should be already -//! included in the provided archive. The installation script has to be launched in order to configure and compile all the required -//! components. At the end of the installation phase you should end up having a directory tree resembling the following: -//! -//!
     ... -//!
     paradiseo-mo -//!
     paradiseo-moeo -//!
     paradiseo-peo -//!
            docs -//!
            examples -//!
                   lesson1 -//!
                   lesson2 -//!
                   ... -//!
                   shared -//!
                   ... -//!
            src -//!
            ... -//!
     ... -//!
-//!
-//! -//! The source-code for this tutorial may be found in the paradiseo-peo/examples/lesson1 directory, in the main.cpp file. -//! We strongly encourage creating a backup copy of the file if you consider modifying the source code. For a complete reference on the -//! TSP-related classes and definitions please refer to the files under the paradiseo-peo/examples/shared. After the installation -//! phase you should end up having an tspExample executable file in the paradiseo-peo/examples/lesson1 directory. -//! We will discuss testing and launching aspects later in the tutorial. -//! -//! You are supposed to be familiar with working in C/C++ (with an extensive use of templates) and you should have at least an introductory -//! background in working with the EO framework. -//! -//!
-//! NOTE: All the presented examples have as case study the Traveling Salesman Problem (TSP). All the presented tutorials rely -//! on a common shared source code defining transformation operators, -//! evaluation functions, etc. for the TSP problem. For a complete understanding of the presented tutorials please take your time for -//! consulting and for studying the additional underlying defined classes. -//!

-//! -//! \section problemDef Problem Definition and Representation -//! -//! As we are not directly concerned with the Traveling Salesman Problem, and to some extent out of scope, no in depth details are offered -//! for the TSP. The problem requires finding the shortest path connecting a given set of cities, while visiting each of -//! the specified cities only once and returning to the startpoint city. The problem is known to be NP-complete, i.e. no polynomial -//! time algorithm exists for solving the problem in exact manner. -//! -//! The construction of a ParadisEO-PEO evolutionary algorithm requires following a few simple steps - please take your time to study the signature -//! of the peoEA constructor: -//! -//! -//! -//! -//!
-//!      peoEA( -//!
            eoContinue< EOT >& __cont, -//!
            peoPopEval< EOT >& __pop_eval, -//!
            eoSelect< EOT >& __select, -//!
            peoTransform< EOT >& __trans, -//!
            eoReplacement< EOT >& __replace -//!
     ); -//!
-//! \image html peoEA.png -//!
-//! -//! A few remarks have to be made: while most of the parameters are passed as EO-specific types, the evaluation and the transformation objects have to be -//! derived from the ParadisEO-PEO peoPopEval and peoTransform classes. Derived classes like the peoParaPopEval and peoParaSGATransform classes allow -//! for parallel evaluation of the population and parallel transformation operators, respectively. Wrappers are provided thus allowing to make use -//! of the EO classes. -//! -//! In the followings, the main required elements for building an evolutionary algorithm are enumerated. For complete details regarding the -//! implementation aspects of each of the components, please refer to the common shared source code. -//! Each of the bellow referred header files may be found in the pardiseo-peo/examples/shared directory. -//! -//!
    -//!
  1. representation - the first decision to be taken concerns the representation of the individuals. You may create your -//! own representation or you may use/derive one of the predefined classes of the EO framework.
    -//! -//! For our case study, the TSP, each city is defined as a Node in the node.h header file - in fact an unsigned value defined -//! as typedef unsigned Node. Moreover, each individual (of the evolutionary algorithm) is represented as a Route object, a vector of Node objects, in -//! the route.h header file - typedef eoVector< int, Node > Route. The definition of the Route object implies two -//! elements: (1) a route is a vector of nodes, and (2) the fitness is an integer value (please refer to the eoVector -//! definition in the EO framework). -//! -//! In addition you should also take a look in the route_init.h header file which includes the RouteInit class, defined for -//! initializing in random manner Route objects. -//!
  2. -//!
  3. evaluation function - having a representation model, an evaluation object has to be defined, implementing a specific -//! fitness function. The designed class has to be derived (directly or indirectly) from the peoPopEval class - you have the choice of -//! using peoSeqPopEval or peoParaPopEval for sequential and parallel evaluation, respectively. These classes act as wrappers requiring -//! the specification of an EO evaluation object derived from the eoEvalFunc class - please refer to their respective documentation.
    -//! -//! The fitness function for our TSP case study is implemented in the route_eval.h header file. The class is derived from the eoEvalFunc -//! EO class, being defined as class RouteEval : public eoEvalFunc< Route >. -//!
  4. -//!
  5. transformation operators - in order to assure the evolution of the initial population, transformation operators have to be defined. -//! Depending on your problem, you may specify quadruple operators (two input individuals, two output resulting individuals), i.e. crossover operators, -//! binary operators (one input individual and one output resulting individual), i.e. mutation operators, or combination of both types. As for the -//! evaluation function, the signature of the peoEA constructor requires specifying a peoTransform derived object as transformation operator. -//! -//! The transform operators, crossover and mutation, for the herein presented example are defined in the order_xover.h and the city_swap.h -//! header files, respectively. -//!
  6. -//!
  7. continuation criterion - the evolutionary algorithm evolves in an iterative manner; a continuation criterion has to be specified. -//! One of the most common and simplest options considers a maximum number of generations. It is your choice whether to use -//! a predefined EO class for specifying the continuation criterion or using a custom defined class. In the later case you have to -//! make sure that your class derives the eoContinue class.
    -//!
  8. -//!
  9. selection strategy - at each iteration a set of individuals are selected for applying the transform operators, in order -//! to obtain the offspring population. As the specified parameter has to be derived from the eoSelect it is your option of whether using -//! the EO provided selection strategies or implementing your own, as long as it inherits the eoSelect class. -//! -//! For our example we chose to use the eoRankingSelect strategy, provided in the EO framework. -//!
  10. -//!
  11. replacement strategy - once the offspring population is obtained, the offsprings have to be integrated back into the initial -//! population, according to a given strategy. For custom defined strategies you have to inherit the eoReplacement EO class. We chose to -//! use an eoPlusReplacement as strategy (please review the EO documentation for details on the different strategies available). -//!
  12. -//!
-//!
-//! -//! \section example A simple example for constructing a peoEA object -//! -//! The source code for this example may be found in the main.cpp file, under the paradiseo-peo/examples/lesson1 directory. Please make sure you -//! At this point you have two options: (a) you can just follow the example without touching the main.cpp or, (b) you can start from scratch, -//! following the presented steps, in which case you are required make a backup copy of the main.cpp file and replace the original file with an -//! empty one. -//! -//!
    -//!
  1. include the necessary header files - as we will be using Route objects, we have to include the files -//! which define the Route type, the initializing functor and the evaluation functions. Furthermore, in order to make use of -//! transform operators, we require having the headers which define the crossover and the mutation operators. -//! All these files may be found in the shared directory that we mentioned in the beginning. At this point you -//! should have something like the following:
    -//! -//!
    -//!		##include "route.h"
    -//!		##include "route_init.h"
    -//!		##include "route_eval.h"
    -//!		
    -//!		##include "order_xover.h"
    -//!		##include "city_swap.h"
    -//!		
    -//! In addition we require having the paradiseo header file, in order to use the ParadisEO-PEO features, and a header specific -//! for our problem, dealing with processing command-line parameters - the param.h header file. The complete picture at this point -//! with all the required header files is as follows:
    -//! -//!
    -//!		##include "route.h"
    -//!		##include "route_init.h"
    -//!		##include "route_eval.h"
    -//!		
    -//!		##include "order_xover.h"
    -//!		##include "city_swap.h"
    -//!
    -//!		##include "param.h"
    -//!
    -//!		##include <paradiseo>
    -//!		
    -//! NOTE: the paradiseo header file is in fact a "super-header" - it includes all the esential ParadisEO-PEO header files. -//! It is at at your choice if you want use the paradiseo header file or to explicitly include different header files, -//! like the peoEA.h header file, for example. -//! -//!
  2. -//!
  3. define problem specific parameters - in our case we have to specify how many individuals we want to have in our population, the number -//! of generations for the evolutionary algorithm to iterate and the probabilities associated with the crossover and mutation operators.
    -//! -//!
    -//!		##include "route.h"
    -//!		##include "route_init.h"
    -//!		##include "route_eval.h"
    -//!		
    -//!		##include "order_xover.h"
    -//!		##include "city_swap.h"
    -//!
    -//!		##include "param.h"
    -//!
    -//!		##include <paradiseo>
    -//!
    -//!
    -//!		##define POP_SIZE 10
    -//!		##define NUM_GEN 100
    -//!		##define CROSS_RATE 1.0
    -//!		##define MUT_RATE 0.01
    -//!		
    -//!
  4. -//!
  5. construct the skeleton of a simple ParadisEO-PEO program - the main function including the code for initializing the ParadisEO-PEO -//! environment, for loading problem data and for shutting down the ParadisEO-PEO environment. From this point on we will make -//! abstraction of the previous part referring only to the main function.
    -//! -//!
    -//!		...
    -//!		
    -//!		int main( int __argc, char** __argv ) {
    -//!		
    -//!			// initializing the ParadisEO-PEO environment
    -//!			peo :: init( __argc, __argv );
    -//!		
    -//!			// processing the command line specified parameters
    -//!			loadParameters( __argc, __argv );
    -//!		
    -//!
    -//!			// EVOLUTIONARY ALGORITHM TO BE DEFINED
    -//!
    -//!		
    -//!			peo :: run( );
    -//!			peo :: finalize( );
    -//!			// shutting down the ParadisEO-PEO environment
    -//!		
    -//!			return 0;
    -//!		}
    -//!		
    -//!
  6. -//!
  7. initialization functors, evaluation function and transform operators - basically we only need to create instances for each of the -//! enumerated objects, to be passed later as parameters for higher-level components of the evolutionary algorithm.
    -//! -//!
    -//!		RouteInit route_init;	// random init object - creates random Route objects
    -//!		RouteEval full_eval;	// evaluator object - offers a fitness value for a specified Route object
    -//!
    -//!		OrderXover crossover;	// crossover operator - creates two offsprings out of two specified parents
    -//!		CitySwap mutation;	// mutation operator - randomly mutates one gene for a specified individual
    -//!		
    -//!
  8. -//!
  9. construct the components of the evolutionary algorithm - each of the components that has to be passed as parameter to the -//! peoEA constructor has to be defined along with the associated parameters. Except for the requirement to provide the -//! appropriate objects (for example, a peoPopEval derived object must be specified for the evaluation functor), there is no strict -//! path to follow. It is your option what elements to mix, depending on your problem - we aimed for simplicity in our example. -//! -//! -//!
    -//!		eoPop< Route > population( POP_SIZE, route_init );	// initial population for the algorithm having POP_SIZE individuals
    -//!		peoSeqPopEval< Route > eaPopEval( full_eval );		// evaluator object - to be applied at each iteration on the entire population
    -//!		
    -//! -//!
    -//!		eoGenContinue< Route > eaCont( NUM_GEN );		// continuation criterion - the algorithm will iterate for NUM_GEN generations
    -//!		eoCheckPoint< Route > eaCheckpointContinue( eaCont );	// checkpoint object - verify at each iteration if the continuation criterion is met
    -//!		
    -//! -//!
    -//!		eoRankingSelect< Route > selectionStrategy;		// selection strategy - applied at each iteration for selecting parent individuals
    -//!		eoSelectNumber< Route > eaSelect( selectionStrategy, POP_SIZE ); // selection object - POP_SIZE individuals are selected at each iteration
    -//!		
    -//! -//!
    -//!		// transform operator - includes the crossover and the mutation operators with a specified associated rate
    -//!		eoSGATransform< Route > transform( crossover, CROSS_RATE, mutation, MUT_RATE );
    -//!		peoSeqTransform< Route > eaTransform( transform );	// ParadisEO transform operator (please remark the peo prefix) - wraps an e EO transform object
    -//!		
    -//! -//!
    -//!		eoPlusReplacement< Route > eaReplace;			// replacement strategy - for replacing the initial population with offspring individuals
    -//!		
    -//!
  10. -//!
  11. evolutionary algorithm - having defined all the previous components, we are ready for instanciating an evolutionary algorithm. -//! In the end we have to associate a population with the algorithm, which will serve as the initial population, to be iteratively evolved. -//! -//!
    -//!		peoEA< Route > eaAlg( eaCheckpointContinue, eaPopEval, eaSelect, eaTransform, eaReplace );
    -//!
    -//!		eaAlg( population );	// specifying the initial population for the algorithm, to be iteratively evolved
    -//!		
    -//!
  12. -//!
-//! -//! If you have not missed any of the enumerated points, your program should be like the following: -//! -//!
-//! ##include "route.h"
-//! ##include "route_init.h"
-//! ##include "route_eval.h"
-//! 
-//! ##include "order_xover.h"
-//! ##include "city_swap.h"
-//! 
-//! ##include "param.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 ) {
-//! 
-//! 	// initializing the ParadisEO-PEO environment
-//! 	peo :: init( __argc, __argv );
-//! 
-//! 
-//! 	// processing the command line specified parameters
-//! 	loadParameters( __argc, __argv );
-//! 
-//! 
-//! 	// init, eval operators, EA operators -------------------------------------------------------------------------------------------------------------
-//! 
-//! 	RouteInit route_init;	// random init object - creates random Route objects
-//! 	RouteEval full_eval;	// evaluator object - offers a fitness value for a specified Route object
-//! 
-//! 	OrderXover crossover;	// crossover operator - creates two offsprings out of two specified parents
-//! 	CitySwap mutation;	// mutation operator - randomly mutates one gene for a specified individual
-//! 	// ------------------------------------------------------------------------------------------------------------------------------------------------
-//! 
-//! 
-//! 	// evolutionary algorithm components --------------------------------------------------------------------------------------------------------------
-//! 
-//! 	eoPop< Route > population( POP_SIZE, route_init );	// initial population for the algorithm having POP_SIZE individuals
-//! 	peoSeqPopEval< Route > eaPopEval( full_eval );		// evaluator object - to be applied at each iteration on the entire population
-//! 
-//! 	eoGenContinue< Route > eaCont( NUM_GEN );		// continuation criterion - the algorithm will iterate for NUM_GEN generations
-//! 	eoCheckPoint< Route > eaCheckpointContinue( eaCont );	// checkpoint object - verify at each iteration if the continuation criterion is met
-//! 
-//! 	eoRankingSelect< Route > selectionStrategy;		// selection strategy - applied at each iteration for selecting parent individuals
-//! 	eoSelectNumber< Route > eaSelect( selectionStrategy, POP_SIZE ); // selection object - POP_SIZE individuals are selected at each iteration
-//! 
-//! 	// transform operator - includes the crossover and the mutation operators with a specified associated rate
-//! 	eoSGATransform< Route > transform( crossover, CROSS_RATE, mutation, MUT_RATE );
-//! 	peoSeqTransform< Route > eaTransform( transform );	// ParadisEO transform operator (please remark the peo prefix) - wraps an e EO transform object
-//! 
-//! 	eoPlusReplacement< Route > eaReplace;			// replacement strategy - for replacing the initial population with offspring individuals
-//! 	// ------------------------------------------------------------------------------------------------------------------------------------------------
-//! 
-//! 
-//! 	// ParadisEO-PEO evolutionary algorithm -----------------------------------------------------------------------------------------------------------
-//! 
-//! 	peoEA< Route > eaAlg( eaCheckpointContinue, eaPopEval, eaSelect, eaTransform, eaReplace );
-//! 	
-//! 	eaAlg( population );	// specifying the initial population for the algorithm, to be iteratively evolved
-//! 	// ------------------------------------------------------------------------------------------------------------------------------------------------
-//! 
-//! 
-//! 	peo :: run( );
-//! 	peo :: finalize( );
-//! 	// shutting down the ParadisEO-PEO environment
-//! 
-//! 	return 0;
-//! }
-//! 
-//! -//! -//! \section testing Compilation and Execution -//! -//! First, please make sure that you followed all the previous steps in defining the evolutionary algorithm. Your file should be called main.cpp - please -//! make sure you do not rename the file (we will be using a pre-built makefile, thus you are required not to change the file names). Please make sure you -//! are in the paradiseo-peo/examples/lesson1 directory - you should open a console and you should change your current directory to the one of Lesson1. -//! -//! Compilation: being in the paradiseo-peo/examples/lesson1 directory, you have to type make. As a result the main.cpp file -//! will be compiled and you should obtain an executable file called tspExample. If you have errors, please verify any of the followings: -//! -//! -//! -//! NOTE: in order to successfully compile your program you should already have installed an MPI distribution in your system. -//! -//! Execution: the execution of a ParadisEO-PEO program requires having already created an environment for launching MPI programs. For MPICH-2, -//! for example, this requires starting a ring of daemons. The implementation that we provided as an example is sequential and includes no parallelism - we -//! will see in the end how to include also parallelism. Executing a parallel program requires specifying a mapping of resources, in order to assing different -//! algorithms to different machines, define worker machines etc. This mapping is defined by an XML file called schema.xml, which, for our case, has -//! the following structure: -//! -//!
-//!	
-//!	
-//!	
-//!		
-//!			
-//!			
-//!			
-//!			
-//!			1
-//!			
-//!			
-//!			
-//!			
-//!			
-//!			
-//!		
-//!	
-//! 
-//! -//! Not going into details, the XML file presented above describes a mapping which includes four nodes, the first one having the role of scheduler, -//! the second one being the node on which the evolutionary algorithm is actually executed and the third and the fourth ones being slave nodes. Overall -//! the mapping says that we will be launching four processes, out of which only one will be executing the evolutionary algorithm. The other node entries -//! in the XML file have no real functionality as we have no parallelism in our program - the entries were created for you convenience, in order to provide -//! a smooth transition to creating a parallel program. -//! -//! Launching the program may be different, depending on your MPI distribution - for MPICH-2, in a console, in the paradiseo-peo/examples/lesson1 -//! directory you have to type the following command: -//! -//! mpiexec -n 4 ./tspExample @lesson.param -//! -//! NOTE: the "-n 4" indicates the number of processes to be launched. The last argument, "@lesson.param", indicates a file which specifies different -//! application specific parameters (the mapping file to be used, for example, whether to use logging or not, etc). -//! -//! The result of your execution should be similar to the following: -//!
-//! 	Loading '../data/eil101.tsp'.
-//! 	NAME: eil101.
-//! 	COMMENT: 101-city problem (Christofides/Eilon).
-//! 	TYPE: TSP.
-//! 	DIMENSION: 101.
-//! 	EDGE_WEIGHT_TYPE: EUC_2D.
-//! 	Loading '../data/eil101.tsp'.
-//! 	NAME: eil101.
-//! 	COMMENT: 101-city problem (Christofides/Eilon).
-//! 	EOF.
-//! 	TYPE: TSP.
-//! 	DIMENSION: 101.
-//! 	EDGE_WEIGHT_TYPE: EUC_2D.
-//! 	EOF.
-//! 	Loading '../data/eil101.tsp'.
-//! 	NAME: eil101.
-//! 	COMMENT: 101-city problem (Christofides/Eilon).
-//! 	TYPE: TSP.
-//! 	DIMENSION: 101.
-//! 	EDGE_WEIGHT_TYPE: EUC_2D.
-//! 	EOF.
-//! 	Loading '../data/eil101.tsp'.
-//! 	NAME: eil101.
-//! 	COMMENT: 101-city problem (Christofides/Eilon).
-//! 	TYPE: TSP.
-//! 	DIMENSION: 101.
-//! 	EDGE_WEIGHT_TYPE: EUC_2D.
-//! 	EOF.
-//! 	STOP in eoGenContinue: Reached maximum number of generations [100/100]
-//!	
-//! -//! -//! \section paraIntro Introducing parallelism -//! -//! Creating parallel programs with ParadisEO-PEO represents an easy task once you have the basic structure for your program. For experimentation, -//! in the main.cpp file, replace the line -//!
-//!	peoSeqPopEval< Route > eaPopEval( full_eval );
-//! 
-//! with -//!
-//!	peoParaPopEval< Route > eaPopEval( full_eval );
-//! 
-//! The second line only tells that we would like to evaluate individuals in parallel - this is very interesting if you have a time consuming fitness -//! evaluation function. If you take another look on the schema.xml XML file you will see the last two nodes being marked as slaves (the "num_workers" -//! attribute - these nodes will be used for computing the fitness of the individuals. -//! -//! At this point you only have to recompile your program and to launch it again - as we are not using a time consuming fitness fitness function, the -//! effects might not be visible - you may increase the number of individuals to experiment. diff --git a/trunk/paradiseo-peo/tutorial/Lesson1/main.cpp b/trunk/paradiseo-peo/tutorial/Lesson1/main.cpp deleted file mode 100644 index 7478eb329..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson1/main.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* -* -* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 -* -* Sebastien Cahon, Alexandru-Adrian Tantar -* -* This software is governed by the CeCILL license under French law and -* abiding by the rules of distribution of free software. You can use, -* modify and/ or redistribute the software under the terms of the CeCILL -* license as circulated by CEA, CNRS and INRIA at the following URL -* "http://www.cecill.info". -* -* As a counterpart to the access to the source code and rights to copy, -* modify and redistribute granted by the license, users are provided only -* with a limited warranty and the software's author, the holder of the -* economic rights, and the successive licensors have only limited liability. -* -* In this respect, the user's attention is drawn to the risks associated -* with loading, using, modifying and/or developing or reproducing the -* software by the user in light of its specific status of free software, -* that may mean that it is complicated to manipulate, and that also -* therefore means that it is reserved for developers and experienced -* professionals having in-depth computer knowledge. Users are therefore -* encouraged to load and test the software's suitability as regards their -* requirements in conditions enabling the security of their systems and/or -* data to be ensured and, more generally, to use and operate it in the -* same conditions as regards security. -* The fact that you are presently reading this means that you have had -* knowledge of the CeCILL license and that you accept its terms. -* -* ParadisEO WebSite : http://paradiseo.gforge.inria.fr -* Contact: paradiseo-help@lists.gforge.inria.fr -* -*/ - -#include "route.h" -#include "route_init.h" -#include "route_eval.h" - -#include "order_xover.h" -#include "city_swap.h" - -#include "param.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 ) { - - // initializing the ParadisEO-PEO environment - peo :: init( __argc, __argv ); - - - // processing the command line specified parameters - loadParameters( __argc, __argv ); - - - // init, eval operators, EA operators ------------------------------------------------------------------------------------------------------------- - - RouteInit route_init; // random init object - creates random Route objects - RouteEval full_eval; // evaluator object - offers a fitness value for a specified Route object - - OrderXover crossover; // crossover operator - creates two offsprings out of two specified parents - CitySwap mutation; // mutation operator - randomly mutates one gene for a specified individual - // ------------------------------------------------------------------------------------------------------------------------------------------------ - - - // evolutionary algorithm components -------------------------------------------------------------------------------------------------------------- - - eoPop< Route > population( POP_SIZE, route_init ); // initial population for the algorithm having POP_SIZE individuals - peoSeqPopEval< Route > eaPopEval( full_eval ); // evaluator object - to be applied at each iteration on the entire population - - eoGenContinue< Route > eaCont( NUM_GEN ); // continuation criterion - the algorithm will iterate for NUM_GEN generations - eoCheckPoint< Route > eaCheckpointContinue( eaCont ); // checkpoint object - verify at each iteration if the continuation criterion is met - - eoRankingSelect< Route > selectionStrategy; // selection strategy - applied at each iteration for selecting parent individuals - eoSelectNumber< Route > eaSelect( selectionStrategy, POP_SIZE ); // selection object - POP_SIZE individuals are selected at each iteration - - // transform operator - includes the crossover and the mutation operators with a specified associated rate - eoSGATransform< Route > transform( crossover, CROSS_RATE, mutation, MUT_RATE ); - peoSeqTransform< Route > eaTransform( transform ); // ParadisEO transform operator (please remark the peo prefix) - wraps an e EO transform object - - eoPlusReplacement< Route > eaReplace; // replacement strategy - for replacing the initial population with offspring individuals - // ------------------------------------------------------------------------------------------------------------------------------------------------ - - - // ParadisEO-PEO evolutionary algorithm ----------------------------------------------------------------------------------------------------------- - - peoEA< Route > eaAlg( eaCheckpointContinue, eaPopEval, eaSelect, eaTransform, eaReplace ); - - eaAlg( population ); // specifying the initial population for the algorithm, to be iteratively evolved - // ------------------------------------------------------------------------------------------------------------------------------------------------ - - - peo :: run( ); - peo :: finalize( ); - // shutting down the ParadisEO-PEO environment - - if(getNodeRank()==1) - std::cout<<"\n\nPopulation :\n"< +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, INRIA, 2007 +* +* Clive Canape +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#include +#include + +typedef eoReal Indi; + +//Evaluation function + +double f (const Indi & _indi) +{ + // Rosenbrock function f(x) = 100*(x[1]-x[0]^2)^2+(1-x[0])^2 + // => optimal : f* = 0 , with x* =(1,1) + + 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[]) +{ + + +// Initialization of the parallel environment : thanks this instruction, ParadisEO-PEO can initialize himself + peo :: init( __argc, __argv ); + +//Parameters + + const unsigned int VEC_SIZE = 2; // Don't change this parameter when you are resolving the Rosenbrock function + const unsigned int POP_SIZE = 20; // As with a sequential algorithm, you change the size of the population + const unsigned int MAX_GEN = 300; // Define the number of maximal generation + const double INIT_POSITION_MIN = -2.0; // For initialize x + const double INIT_POSITION_MAX = 2.0; // In the case of the Rosenbrock function : -2 < x[i] < 2 + const float CROSS_RATE = 0.8; // Crossover rate + const double EPSILON = 0.01; // Range for real uniform mutation + const float MUT_RATE = 0.3; // Mutation rate + rng.reseed (time(0)); + +// Stopping + eoGenContinue < Indi > genContPara (MAX_GEN); + eoCombinedContinue continuatorPara (genContPara); + eoCheckPoint checkpoint(continuatorPara); + + + /* In this lesson, you should define a peoEvalFunc witch will allow to initialize : + * + * - peoSeqPopEval : using to the sequential evaluation + * + * OR + * + * - peoParaPopEval : using to the parallel evaluation + * + */ + +// For a parallel evaluation + peoEvalFunc plainEval(f); + peoParaPopEval< Indi > eval(plainEval); + + +// Initialization + eoUniformGenerator < double >uGen (INIT_POSITION_MIN, INIT_POSITION_MAX); + eoInitFixedLength < Indi > random (VEC_SIZE, uGen); + +// Selection + eoRankingSelect selectionStrategy; + eoSelectNumber select(selectionStrategy,POP_SIZE); + +// Transformation + eoSegmentCrossover crossover; // Crossover + eoUniformMutation mutation(EPSILON); // Mutation + eoSGATransform transform(crossover,CROSS_RATE,mutation,MUT_RATE); + peoSeqTransform eaTransform(transform); + +// Replacement + eoPlusReplacement replace; + +// Creation of the population + eoPop < Indi > pop; + pop.append (POP_SIZE, random); + +//Parallel algorithm + peoEA Algo(checkpoint,eval,select,eaTransform,replace); + Algo(pop); + + peo :: run(); + peo :: finalize(); + if(getNodeRank()==1) + std::cout << "Final population :\n" << pop << std::endl; +} diff --git a/trunk/paradiseo-peo/tutorial/Lesson4/main.cpp b/trunk/paradiseo-peo/tutorial/Lesson1/mainPSO.cpp similarity index 58% rename from trunk/paradiseo-peo/tutorial/Lesson4/main.cpp rename to trunk/paradiseo-peo/tutorial/Lesson1/mainPSO.cpp index 75f076531..6ebeba39d 100644 --- a/trunk/paradiseo-peo/tutorial/Lesson4/main.cpp +++ b/trunk/paradiseo-peo/tutorial/Lesson1/mainPSO.cpp @@ -1,7 +1,7 @@ /* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 +* (C) OPAC Team, INRIA, 2007 * * Clive Canape * @@ -31,98 +31,112 @@ * * ParadisEO WebSite : http://paradiseo.gforge.inria.fr * Contact: paradiseo-help@lists.gforge.inria.fr -* clive.canape@inria.fr +* */ -//For define a parallel PSO or a sequential PSO -#define PARA - #include typedef eoRealParticle < double >Indi; + //Evaluation function double f (const Indi & _indi) { - //Levy function f* = -21.502356 x*=(1,1,1,-9.752356 ) for vector size = 4 + // Rosenbrock function f(x) = 100*(x[1]-x[0]^2)^2+(1-x[0])^2 + // => optimal : f* = 0 , with x* =(1,1) - const double PI = 4.0 * atan(1.0); - double sum=0.; - for (unsigned i = 0; i < _indi.size()-1; i++) - sum+=pow((_indi[i]-1),2)*(1+pow(sin(3*PI*_indi[i+1]),2)); - sum+=pow(sin(3*PI*_indi[0]),2); - sum+=(_indi[_indi.size()-1]-1)*(1+pow(sin(2*PI*_indi[_indi.size()-1]),2)); + 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[]) { -#ifdef PARA -//Initialization - peo :: init( __argc, __argv ); -#endif + +// Initialization of the parallel environment : thanks this instruction, ParadisEO-PEO can initialize himself + peo :: init( __argc, __argv ); + //Parameters - const unsigned int VEC_SIZE = 4; - const unsigned int POP_SIZE = 20; - const unsigned int NEIGHBORHOOD_SIZE= 5; - const unsigned int MAX_GEN = 500; - const double INIT_POSITION_MIN = -10.0; - const double INIT_POSITION_MAX = 1.0; - const double INIT_VELOCITY_MIN = -1; - const double INIT_VELOCITY_MAX = 1; - const double C1 = 0.5; - const double C2 = 2; + + const unsigned int VEC_SIZE = 2; // Don't change this parameter when you are resolving the Rosenbrock function + + const unsigned int POP_SIZE = 20; // As with a sequential algorithm, you change the size of the population + + const unsigned int NEIGHBORHOOD_SIZE= 6; // This parameter define the neighborhoods in the PSO's topology + + const unsigned int MAX_GEN = 150; // Define the number of maximal generation + + const double INIT_POSITION_MIN = -2.0; // For initialize x + const double INIT_POSITION_MAX = 2.0; // In the case of the Rosenbrock function : -2 < x[i] < 2 + + const double INIT_VELOCITY_MIN = -1.; // For initialize PSO's velocity + const double INIT_VELOCITY_MAX = 1.; // ie Lesson 6 of ParadisEO-EO + + const double C1 = 0.5; // For calculate the velocity + const double C2 = 2.; // ie Lesson 6 of ParadisEO-EO rng.reseed (time(0)); -#ifndef PARA - eoEvalFuncPtr plainEval(f); - eoEvalFuncCounter < Indi > eval (plainEval); -#else - peoEvalFuncPSO plainEval(f); - eoEvalFuncCounter < Indi > evalSeq (plainEval); - peoParaPopEval< Indi > eval(plainEval); -#endif - eoUniformGenerator < double >uGen (INIT_POSITION_MIN, INIT_POSITION_MAX); - eoInitFixedLength < Indi > random (VEC_SIZE, uGen); -//Velocity - eoUniformGenerator < double >sGen (INIT_VELOCITY_MIN, INIT_VELOCITY_MAX); - eoVelocityInitFixedLength < Indi > veloRandom (VEC_SIZE, sGen); -//Initializing the best - eoFirstIsBestInit < Indi > localInit; -//Flight - eoRealVectorBounds bndsFlight(VEC_SIZE,INIT_POSITION_MIN,INIT_POSITION_MAX); - eoStandardFlight < Indi > flight(bndsFlight); - eoPop < Indi > pop; - pop.append (POP_SIZE, random); -#ifndef PARA - apply(eval, pop); -#else -//The first evaluation must be sequential - apply(evalSeq, pop); -#endif - apply < Indi > (veloRandom, pop); - apply < Indi > (localInit, pop); -//Topology - eoLinearTopology topology(NEIGHBORHOOD_SIZE); - topology.setup(pop); - eoRealVectorBounds bnds(VEC_SIZE,INIT_VELOCITY_MIN,INIT_VELOCITY_MAX); - eoStandardVelocity < Indi > velocity (topology,C1,C2,bnds); + +// Stopping eoGenContinue < Indi > genContPara (MAX_GEN); eoCombinedContinue continuatorPara (genContPara); eoCheckPoint checkpoint(continuatorPara); -#ifndef PARA -//Sequential algorithm - eoSyncEasyPSO < Indi > psa(checkpoint, eval, velocity, flight); - psa (pop); - pop.sort (); - std::cout << "Final population :\n" << pop << std::endl; -#else + + + + + /* In this lesson, you should define a peoEvalFuncPSO witch will allow to initialize : + * + * - peoSeqPopEval : using to the sequential evaluation + * + * OR + * + * - peoParaPopEval : using to the parallel evaluation + * + */ + +// For a parallel evaluation + peoEvalFuncPSO plainEval(f); + peoParaPopEval< Indi > eval(plainEval); + + + + + +// Initialization + eoUniformGenerator < double >uGen (INIT_POSITION_MIN, INIT_POSITION_MAX); + eoInitFixedLength < Indi > random (VEC_SIZE, uGen); + +// Velocity (ie Lesson 6 of ParadisEO-PEO) + eoUniformGenerator < double >sGen (INIT_VELOCITY_MIN, INIT_VELOCITY_MAX); + eoVelocityInitFixedLength < Indi > veloRandom (VEC_SIZE, sGen); + +// Initializing the best (ie Lesson 6 of ParadisEO-PEO) + eoFirstIsBestInit < Indi > localInit; + +// Flight (ie Lesson 6 of ParadisEO-PEO) + eoRealVectorBounds bndsFlight(VEC_SIZE,INIT_POSITION_MIN,INIT_POSITION_MAX); + eoStandardFlight < Indi > flight(bndsFlight); + +// Creation of the population + eoPop < Indi > pop; + pop.append (POP_SIZE, random); + +// Initialization + peoInitializer init(eval,veloRandom,localInit,pop); + +// Topology (ie Lesson 6 of ParadisEO-PEO) + eoLinearTopology topology(NEIGHBORHOOD_SIZE); + eoRealVectorBounds bnds(VEC_SIZE,INIT_VELOCITY_MIN,INIT_VELOCITY_MAX); + eoStandardVelocity < Indi > velocity (topology,C1,C2,bnds); + //Parallel algorithm - peoPSO < Indi > psa(checkpoint, eval, velocity, flight); + peoPSO < Indi > psa(init,checkpoint, eval, velocity, flight); psa(pop); peo :: run(); peo :: finalize(); if(getNodeRank()==1) std::cout << "Final population :\n" << pop << std::endl; -#endif } diff --git a/trunk/paradiseo-peo/tutorial/Lesson1/paradiseo-peo-lsn.doxyfile b/trunk/paradiseo-peo/tutorial/Lesson1/paradiseo-peo-lsn.doxyfile index b7ecda59e..dcbaf631a 100644 --- a/trunk/paradiseo-peo/tutorial/Lesson1/paradiseo-peo-lsn.doxyfile +++ b/trunk/paradiseo-peo/tutorial/Lesson1/paradiseo-peo-lsn.doxyfile @@ -239,3 +239,4 @@ DOT_CLEANUP = YES # Configuration::additions related to the search engine #--------------------------------------------------------------------------- SEARCHENGINE = YES + diff --git a/trunk/paradiseo-peo/tutorial/Lesson5/lesson.param b/trunk/paradiseo-peo/tutorial/Lesson1/param similarity index 74% rename from trunk/paradiseo-peo/tutorial/Lesson5/lesson.param rename to trunk/paradiseo-peo/tutorial/Lesson1/param index 6ba37c292..730f547e1 100644 --- a/trunk/paradiseo-peo/tutorial/Lesson5/lesson.param +++ b/trunk/paradiseo-peo/tutorial/Lesson1/param @@ -4,4 +4,6 @@ ## deployment schema ---schema=schema.xml \ No newline at end of file +--schema=schema.xml + + diff --git a/trunk/paradiseo-peo/tutorial/Lesson1/schema.xml b/trunk/paradiseo-peo/tutorial/Lesson1/schema.xml index 3edea1488..f34107574 100644 --- a/trunk/paradiseo-peo/tutorial/Lesson1/schema.xml +++ b/trunk/paradiseo-peo/tutorial/Lesson1/schema.xml @@ -13,6 +13,7 @@ + diff --git a/trunk/paradiseo-peo/tutorial/Lesson2/CMakeLists.txt b/trunk/paradiseo-peo/tutorial/Lesson2/CMakeLists.txt deleted file mode 100644 index 34d510325..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson2/CMakeLists.txt +++ /dev/null @@ -1,105 +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/Lesson2/lesson.param ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson2/schema.xml) - -ADD_CUSTOM_COMMAND( - TARGET install - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson2/lesson.param - ${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson2) -ADD_CUSTOM_COMMAND( - TARGET install - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson2/schema.xml - ${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson2) -ADD_CUSTOM_COMMAND( - TARGET install - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson2/ParadisEO-PEO_Lesson2.pdf - ${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson2) -###################################################################################### - - -###################################################################################### -### 1) Include the sources -###################################################################################### - -INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src ${MO_SRC_DIR}/src ${ParadisEO-PEO_SOURCE_DIR}/src ${TSP_SRC_DIR}) - -###################################################################################### - - -###################################################################################### -### 2) Specify where CMake can find the libraries -###################################################################################### - -IF(NOT WIN32 OR CYGWIN) - LINK_DIRECTORIES(${EO_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(tspExample main.cpp) -ADD_DEPENDENCIES(tspExample tsp peo rmc_mpi) -###################################################################################### - - -###################################################################################### -### 4) Optionnal: define properties -###################################################################################### - -SET(LESSON2_VERSION ${GLOBAL_VERSION}) -SET_TARGET_PROPERTIES(tspExample PROPERTIES VERSION "${LESSON2_VERSION}") -###################################################################################### - - -###################################################################################### -### 5) Link the librairies -###################################################################################### - -TARGET_LINK_LIBRARIES(tspExample ${XML2_LIBS} tsp peo rmc_mpi eo eoutils) - -###################################################################################### - - -###################################################################################### -### 6) Windows advanced config - especially for Microsoft Visual Studio 8 -###################################################################################### - - IF(CMAKE_CXX_COMPILER MATCHES cl) - IF(NOT WITH_SHARED_LIBS) - IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005") - SET(CMAKE_CXX_FLAGS "/nologo /W3 /Gy") - SET(CMAKE_CXX_FLAGS_DEBUG "/MTd /Z7 /Od") - SET(CMAKE_CXX_FLAGS_RELEASE "/MT /O2") - SET(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O2") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MTd /Z7 /Od") - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") - - ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005") - ENDIF(NOT WITH_SHARED_LIBS) - ENDIF(CMAKE_CXX_COMPILER MATCHES cl) -###################################################################################### - - - diff --git a/trunk/paradiseo-peo/tutorial/Lesson2/ParadisEO-PEO_Lesson2.pdf b/trunk/paradiseo-peo/tutorial/Lesson2/ParadisEO-PEO_Lesson2.pdf deleted file mode 100755 index d99d43f1a..000000000 Binary files a/trunk/paradiseo-peo/tutorial/Lesson2/ParadisEO-PEO_Lesson2.pdf and /dev/null differ diff --git a/trunk/paradiseo-peo/tutorial/Lesson2/lesson.param b/trunk/paradiseo-peo/tutorial/Lesson2/lesson.param deleted file mode 100644 index eb843c65f..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson2/lesson.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/Lesson2/main.cpp b/trunk/paradiseo-peo/tutorial/Lesson2/main.cpp deleted file mode 100644 index 0933bb72f..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson2/main.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* -* -* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 -* -* Sebastien Cahon, Alexandru-Adrian Tantar -* -* This software is governed by the CeCILL license under French law and -* abiding by the rules of distribution of free software. You can use, -* modify and/ or redistribute the software under the terms of the CeCILL -* license as circulated by CEA, CNRS and INRIA at the following URL -* "http://www.cecill.info". -* -* As a counterpart to the access to the source code and rights to copy, -* modify and redistribute granted by the license, users are provided only -* with a limited warranty and the software's author, the holder of the -* economic rights, and the successive licensors have only limited liability. -* -* In this respect, the user's attention is drawn to the risks associated -* with loading, using, modifying and/or developing or reproducing the -* software by the user in light of its specific status of free software, -* that may mean that it is complicated to manipulate, and that also -* therefore means that it is reserved for developers and experienced -* professionals having in-depth computer knowledge. Users are therefore -* encouraged to load and test the software's suitability as regards their -* requirements in conditions enabling the security of their systems and/or -* data to be ensured and, more generally, to use and operate it in the -* same conditions as regards security. -* The fact that you are presently reading this means that you have had -* knowledge of the CeCILL license and that you accept its terms. -* -* ParadisEO WebSite : http://paradiseo.gforge.inria.fr -* Contact: paradiseo-help@lists.gforge.inria.fr -* -*/ - -#include "route.h" -#include "route_init.h" -#include "route_eval.h" - -#include "order_xover.h" -#include "city_swap.h" - -#include "param.h" - -#include "merge_route_eval.h" -#include "part_route_eval.h" - - -#include - - -#define POP_SIZE 10 -#define NUM_GEN 100 -#define CROSS_RATE 1.0 -#define MUT_RATE 0.01 - -#define NUM_PART_EVALS 2 - - -// by default, parallel evaluation of the population is performed; -// for parallel fitness evaluation, uncomment the following line - -#define PARALLEL_FIT_EVALUATION - - -int main( int __argc, char** __argv ) { - - // initializing the ParadisEO-PEO environment - peo :: init( __argc, __argv ); - - - // processing the command line specified parameters - loadParameters( __argc, __argv ); - - - // init, eval operators, EA operators ------------------------------------------------------------------------------------------------------------- - - RouteInit route_init; // random init object - creates random Route objects - RouteEval full_eval; // evaluator object - offers a fitness value for a specified Route object - - OrderXover crossover; // crossover operator - creates two offsprings out of two specified parents - CitySwap mutation; // mutation operator - randomly mutates one gene for a specified individual - // ------------------------------------------------------------------------------------------------------------------------------------------------ - - - // evolutionary algorithm components -------------------------------------------------------------------------------------------------------------- - - eoPop< Route > population( POP_SIZE, route_init ); // initial population for the algorithm having POP_SIZE individuals - - - #ifdef PARALLEL_FIT_EVALUATION - - MergeRouteEval merge_eval; - - std :: vector< eoEvalFunc< Route >* > part_eval; - for ( unsigned index = 1; index <= NUM_PART_EVALS; index++ ) - part_eval.push_back( new PartRouteEval( ( float )( index - 1 ) / NUM_PART_EVALS, ( float )index / NUM_PART_EVALS ) ); - - peoParaPopEval< Route > ox_pop_eval( part_eval, merge_eval ); - - #else - - peoParaPopEval< Route > ox_pop_eval( full_eval ); - - #endif - - - - peoParaPopEval< Route > eaPopEval( full_eval ); // evaluator object - to be applied at each iteration on the entire population - - eoGenContinue< Route > eaCont( NUM_GEN ); // continuation criterion - the algorithm will iterate for NUM_GEN generations - eoCheckPoint< Route > eaCheckpointContinue( eaCont ); // checkpoint object - verify at each iteration if the continuation criterion is met - - eoRankingSelect< Route > selectionStrategy; // selection strategy - applied at each iteration for selecting parent individuals - eoSelectNumber< Route > eaSelect( selectionStrategy, POP_SIZE ); // selection object - POP_SIZE individuals are selected at each iteration - - // transform operator - includes the crossover and the mutation operators with a specified associated rate - eoSGATransform< Route > transform( crossover, CROSS_RATE, mutation, MUT_RATE ); - peoSeqTransform< Route > eaTransform( transform ); // ParadisEO transform operator (please remark the peo prefix) - wraps an e EO transform object - - eoPlusReplacement< Route > eaReplace; // replacement strategy - for replacing the initial population with offspring individuals - // ------------------------------------------------------------------------------------------------------------------------------------------------ - - - // ParadisEO-PEO evolutionary algorithm ----------------------------------------------------------------------------------------------------------- - - peoEA< Route > eaAlg( eaCheckpointContinue, eaPopEval, eaSelect, eaTransform, eaReplace ); - - eaAlg( population ); // specifying the initial population for the algorithm, to be iteratively evolved - // ------------------------------------------------------------------------------------------------------------------------------------------------ - - - peo :: run( ); - peo :: finalize( ); - - if(getNodeRank()==1) - std::cout<<"\n\nPopulation :\n"< +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, INRIA, 2007 +* +* Clive Canape +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#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 ); + 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)); + eoGenContinue < Indi > genContPara (MAX_GEN); + eoCombinedContinue continuatorPara (genContPara); + eoCheckPoint checkpoint(continuatorPara); + peoEvalFunc plainEval(f); + peoSeqPopEval< Indi > eval(plainEval); // Here, the evaluation is sequential + 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); + + /******************************************************************************************/ + + /* In this lesson, you can choose between : + * + * - A sequential transformation (crossover + mutation) : eoSGATransform transform(crossover,CROSS_RATE,mutation,MUT_RATE); + * peoSeqTransform eaTransform(transform); + * + * OR + * + * - A parallel transformation (crossover + mutation) : peoParaSGATransform eaTransform(crossover,CROSS_RATE,mutation,MUT_RATE); + * + * Unfortunately, if you don't use a crossover which creates two children with two parents, + * you can't use this operator. + * In this case, you should send a mail to : paradiseo-help@lists.gforge.inria.fr + */ + + peoParaSGATransform eaTransform(crossover,CROSS_RATE,mutation,MUT_RATE); + +/******************************************************************************************/ + + eoPlusReplacement replace; + eoPop < Indi > pop; + pop.append (POP_SIZE, random); + peoEA Algo(checkpoint,eval,select,eaTransform,replace); + Algo(pop); + peo :: run(); + peo :: finalize(); + if(getNodeRank()==1) + std::cout << "Final population :\n" << pop << std::endl; +} diff --git a/trunk/paradiseo-peo/tutorial/Lesson2/paradiseo-peo-lsn.doxyfile b/trunk/paradiseo-peo/tutorial/Lesson2/paradiseo-peo-lsn.doxyfile deleted file mode 100644 index 318d06ba0..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson2/paradiseo-peo-lsn.doxyfile +++ /dev/null @@ -1,241 +0,0 @@ -# Doxyfile 1.4.7 - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = "ParadisEO-PEO Lesson2" -PROJECT_NUMBER = 0.1 -OUTPUT_DIRECTORY = ../../../doc/html/lesson2 -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 diff --git a/trunk/paradiseo-peo/tutorial/Lesson4/lesson.param b/trunk/paradiseo-peo/tutorial/Lesson2/param similarity index 74% rename from trunk/paradiseo-peo/tutorial/Lesson4/lesson.param rename to trunk/paradiseo-peo/tutorial/Lesson2/param index 6ba37c292..730f547e1 100644 --- a/trunk/paradiseo-peo/tutorial/Lesson4/lesson.param +++ b/trunk/paradiseo-peo/tutorial/Lesson2/param @@ -4,4 +4,6 @@ ## deployment schema ---schema=schema.xml \ No newline at end of file +--schema=schema.xml + + diff --git a/trunk/paradiseo-peo/tutorial/Lesson2/schema.xml b/trunk/paradiseo-peo/tutorial/Lesson2/schema.xml deleted file mode 100644 index 3edea1488..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson2/schema.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - 1 - - - - - - - - - diff --git a/trunk/paradiseo-peo/tutorial/Lesson3/CMakeLists.txt b/trunk/paradiseo-peo/tutorial/Lesson3/CMakeLists.txt deleted file mode 100644 index 6aad38f4b..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson3/CMakeLists.txt +++ /dev/null @@ -1,105 +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/Lesson3/lesson.param ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson3/schema.xml) - -ADD_CUSTOM_COMMAND( - TARGET install - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson3/lesson.param - ${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson3) -ADD_CUSTOM_COMMAND( - TARGET install - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson3/schema.xml - ${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson3) -ADD_CUSTOM_COMMAND( - TARGET install - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson3/ParadisEO-PEO_Lesson3.pdf - ${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson3) -###################################################################################### - - -###################################################################################### -### 1) Include the sources -###################################################################################### - -INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src ${MO_SRC_DIR}/src ${ParadisEO-PEO_SOURCE_DIR}/src ${TSP_SRC_DIR}) - -###################################################################################### - - -###################################################################################### -### 2) Specify where CMake can find the libraries -###################################################################################### - -IF(NOT WIN32 OR CYGWIN) - LINK_DIRECTORIES(${EO_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(tspExample main.cpp) -ADD_DEPENDENCIES(tspExample tsp peo rmc_mpi) -###################################################################################### - - -###################################################################################### -### 4) Optionnal: define properties -###################################################################################### - -SET(LESSON3_VERSION ${GLOBAL_VERSION}) -SET_TARGET_PROPERTIES(tspExample PROPERTIES VERSION "${LESSON3_VERSION}") -###################################################################################### - - -###################################################################################### -### 5) Link the librairies -###################################################################################### - -TARGET_LINK_LIBRARIES(tspExample ${XML2_LIBS} tsp peo rmc_mpi eo eoutils) - -###################################################################################### - - -###################################################################################### -### 6) Windows advanced config - especially for Microsoft Visual Studio 8 -###################################################################################### - - IF(CMAKE_CXX_COMPILER MATCHES cl) - IF(NOT WITH_SHARED_LIBS) - IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005") - SET(CMAKE_CXX_FLAGS "/nologo /W3 /Gy") - SET(CMAKE_CXX_FLAGS_DEBUG "/MTd /Z7 /Od") - SET(CMAKE_CXX_FLAGS_RELEASE "/MT /O2") - SET(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O2") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MTd /Z7 /Od") - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") - - ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005") - ENDIF(NOT WITH_SHARED_LIBS) - ENDIF(CMAKE_CXX_COMPILER MATCHES cl) -###################################################################################### - - - diff --git a/trunk/paradiseo-peo/tutorial/Lesson3/ParadisEO-PEO_Lesson3.pdf b/trunk/paradiseo-peo/tutorial/Lesson3/ParadisEO-PEO_Lesson3.pdf deleted file mode 100755 index dda6ad44f..000000000 Binary files a/trunk/paradiseo-peo/tutorial/Lesson3/ParadisEO-PEO_Lesson3.pdf and /dev/null differ diff --git a/trunk/paradiseo-peo/tutorial/Lesson3/main.cpp b/trunk/paradiseo-peo/tutorial/Lesson3/main.cpp deleted file mode 100644 index a7caa0c8a..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson3/main.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* -* -* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 -* -* Sebastien Cahon, Alexandru-Adrian Tantar -* -* This software is governed by the CeCILL license under French law and -* abiding by the rules of distribution of free software. You can use, -* modify and/ or redistribute the software under the terms of the CeCILL -* license as circulated by CEA, CNRS and INRIA at the following URL -* "http://www.cecill.info". -* -* As a counterpart to the access to the source code and rights to copy, -* modify and redistribute granted by the license, users are provided only -* with a limited warranty and the software's author, the holder of the -* economic rights, and the successive licensors have only limited liability. -* -* In this respect, the user's attention is drawn to the risks associated -* with loading, using, modifying and/or developing or reproducing the -* software by the user in light of its specific status of free software, -* that may mean that it is complicated to manipulate, and that also -* therefore means that it is reserved for developers and experienced -* professionals having in-depth computer knowledge. Users are therefore -* encouraged to load and test the software's suitability as regards their -* requirements in conditions enabling the security of their systems and/or -* data to be ensured and, more generally, to use and operate it in the -* same conditions as regards security. -* The fact that you are presently reading this means that you have had -* knowledge of the CeCILL license and that you accept its terms. -* -* ParadisEO WebSite : http://paradiseo.gforge.inria.fr -* Contact: paradiseo-help@lists.gforge.inria.fr -* -*/ - -#include "route.h" -#include "route_init.h" -#include "route_eval.h" - -#include "order_xover.h" -#include "city_swap.h" - -#include "param.h" - - -#include - - -#define POP_SIZE 10 -#define NUM_GEN 100 -#define CROSS_RATE 1.0 -#define MUT_RATE 0.01 - -#define MIG_FREQ 10 -#define MIG_SIZE 5 - - -int main( int __argc, char** __argv ) { - - // initializing the ParadisEO-PEO environment - peo :: init( __argc, __argv ); - - - // processing the command line specified parameters - loadParameters( __argc, __argv ); - - - // init, eval operators, EA operators ------------------------------------------------------------------------------------------------------------- - - RouteInit route_init; // random init object - creates random Route objects - RouteEval full_eval; // evaluator object - offers a fitness value for a specified Route object - - OrderXover crossover; // crossover operator - creates two offsprings out of two specified parents - CitySwap mutation; // mutation operator - randomly mutates one gene for a specified individual - // ------------------------------------------------------------------------------------------------------------------------------------------------ - - - // evolutionary algorithm components -------------------------------------------------------------------------------------------------------------- - - eoPop< Route > population( POP_SIZE, route_init ); // initial population for the algorithm having POP_SIZE individuals - peoParaPopEval< Route > eaPopEval( full_eval ); // evaluator object - to be applied at each iteration on the entire population - - eoGenContinue< Route > eaCont( NUM_GEN ); // continuation criterion - the algorithm will iterate for NUM_GEN generations - eoCheckPoint< Route > eaCheckpointContinue( eaCont ); // checkpoint object - verify at each iteration if the continuation criterion is met - - eoRankingSelect< Route > selectionStrategy; // selection strategy - applied at each iteration for selecting parent individuals - eoSelectNumber< Route > eaSelect( selectionStrategy, POP_SIZE ); // selection object - POP_SIZE individuals are selected at each iteration - - // transform operator - includes the crossover and the mutation operators with a specified associated rate - eoSGATransform< Route > transform( crossover, CROSS_RATE, mutation, MUT_RATE ); - peoSeqTransform< Route > eaTransform( transform ); // ParadisEO transform operator (please remark the peo prefix) - wraps an e EO transform object - - eoPlusReplacement< Route > eaReplace; // replacement strategy - for replacing the initial population with offspring individuals - // ------------------------------------------------------------------------------------------------------------------------------------------------ - - - - RingTopology topology; - - // migration policy and components ---------------------------------------------------------------------------------------------------------------- - - eoPeriodicContinue< Route > mig_cont( MIG_FREQ ); // migration occurs periodically - - eoRandomSelect< Route > mig_select_one; // emigrants are randomly selected - eoSelectNumber< Route > mig_select( mig_select_one, MIG_SIZE ); - - eoPlusReplacement< Route > mig_replace; // immigrants replace the worse individuals - - peoSyncIslandMig< Route > mig( MIG_FREQ, mig_select, mig_replace, topology, population, population ); - //peoAsyncIslandMig< Route > mig( mig_cont, mig_select, mig_replace, topology, population, population ); - - eaCheckpointContinue.add( mig ); - // ------------------------------------------------------------------------------------------------------------------------------------------------ - - - - - - // ParadisEO-PEO evolutionary algorithm ----------------------------------------------------------------------------------------------------------- - - peoEA< Route > eaAlg( eaCheckpointContinue, eaPopEval, eaSelect, eaTransform, eaReplace ); - - mig.setOwner( eaAlg ); - - eaAlg( population ); // specifying the initial population for the algorithm, to be iteratively evolved - // ------------------------------------------------------------------------------------------------------------------------------------------------ - - - - - // evolutionary algorithm components -------------------------------------------------------------------------------------------------------------- - - eoPop< Route > population2( POP_SIZE, route_init ); // initial population for the algorithm having POP_SIZE individuals - peoParaPopEval< Route > eaPopEval2( full_eval ); // evaluator object - to be applied at each iteration on the entire population - - eoGenContinue< Route > eaCont2( NUM_GEN ); // continuation criterion - the algorithm will iterate for NUM_GEN generations - eoCheckPoint< Route > eaCheckpointContinue2( eaCont2 ); // checkpoint object - verify at each iteration if the continuation criterion is met - - eoRankingSelect< Route > selectionStrategy2; // selection strategy - applied at each iteration for selecting parent individuals - eoSelectNumber< Route > eaSelect2( selectionStrategy2, POP_SIZE ); // selection object - POP_SIZE individuals are selected at each iteration - - // transform operator - includes the crossover and the mutation operators with a specified associated rate - eoSGATransform< Route > transform2( crossover, CROSS_RATE, mutation, MUT_RATE ); - peoSeqTransform< Route > eaTransform2( transform2 ); // ParadisEO transform operator (please remark the peo prefix) - wraps an e EO transform object - - eoPlusReplacement< Route > eaReplace2; // replacement strategy - for replacing the initial population with offspring individuals - // ------------------------------------------------------------------------------------------------------------------------------------------------ - - - - - // migration policy and components ---------------------------------------------------------------------------------------------------------------- - - eoPeriodicContinue< Route > mig_cont2( MIG_FREQ ); // migration occurs periodically - - eoRandomSelect< Route > mig_select_one2; // emigrants are randomly selected - eoSelectNumber< Route > mig_select2( mig_select_one2, MIG_SIZE ); - - eoPlusReplacement< Route > mig_replace2; // immigrants replace the worse individuals - - peoSyncIslandMig< Route > mig2( MIG_FREQ, mig_select2, mig_replace2, topology, population2, population2 ); - //peoAsyncIslandMig< Route > mig2( mig_cont2, mig_select2, mig_replace2, topology, population2, population2 ); - - eaCheckpointContinue2.add( mig2 ); - // ------------------------------------------------------------------------------------------------------------------------------------------------ - - - - - - // ParadisEO-PEO evolutionary algorithm ----------------------------------------------------------------------------------------------------------- - - peoEA< Route > eaAlg2( eaCheckpointContinue2, eaPopEval2, eaSelect2, eaTransform2, eaReplace2 ); - - mig2.setOwner( eaAlg2 ); - - eaAlg2( population2 ); // specifying the initial population for the algorithm, to be iteratively evolved - // ------------------------------------------------------------------------------------------------------------------------------------------------ - - - - peo :: run( ); - peo :: finalize( ); - - if(getNodeRank()==1) - { - std::cout << "Population 1 :\n" << population << std::endl; - std::cout << "Population 2 :\n" << population2 << std::endl; - } - // shutting down the ParadisEO-PEO environment - - return 0; -} diff --git a/trunk/paradiseo-peo/tutorial/Lesson3/mainEA.cpp b/trunk/paradiseo-peo/tutorial/Lesson3/mainEA.cpp new file mode 100644 index 000000000..eda971e92 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/Lesson3/mainEA.cpp @@ -0,0 +1,148 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, INRIA, 2007 +* +* Clive Canape +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#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 ); + 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; + // MIG_FREQ define the frequence of the migration. + const unsigned int MIG_FREQ = 10; + // MIG_SIZE define the size of each migration. + const unsigned int MIG_SIZE = 5; + rng.reseed (time(0)); + + // Define the topology of your island model + RingTopology topology; + + // First algorithm + /*****************************************************************************************/ + eoGenContinue < Indi > genContPara (MAX_GEN); + eoCombinedContinue continuatorPara (genContPara); + eoCheckPoint checkpoint(continuatorPara); + peoEvalFunc plainEval(f); + peoSeqPopEval< Indi > eval(plainEval); // Here, the evaluation is sequential + 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); + peoSeqTransform eaTransform(transform); // Here, the transformation is sequential + eoPlusReplacement replace; + eoPop < Indi > pop; + pop.append (POP_SIZE, random); + + eoPeriodicContinue mig_cont( MIG_FREQ ); // Migration occurs periodically + eoRandomSelect mig_select_one; // Emigrants are randomly selected + eoSelectNumber mig_select (mig_select_one,MIG_SIZE); + eoPlusReplacement mig_replace; // Immigrants replace the worse individuals + +/*****************************************************************************************/ + +// Second algorithm (on the same model but with others names) + /*****************************************************************************************/ + eoGenContinue < Indi > genContPara2 (MAX_GEN); + eoCombinedContinue continuatorPara2 (genContPara2); + eoCheckPoint checkpoint2(continuatorPara2); + peoEvalFunc plainEval2(f); + peoSeqPopEval< Indi > eval2(plainEval2); + 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); + eoSGATransform transform2(crossover2,CROSS_RATE,mutation2,MUT_RATE); + peoSeqTransform eaTransform2(transform2); + eoPlusReplacement replace2; + eoPop < Indi > pop2; + pop2.append (POP_SIZE, random2); + eoPeriodicContinue mig_cont2( MIG_FREQ ); + eoRandomSelect mig_select_one2; + eoSelectNumber mig_select2 (mig_select_one2,MIG_SIZE); + eoPlusReplacement mig_replace2; + +/*****************************************************************************************/ + +// You can choose between : +// +// - Synchrone communication : peoSyncIslandMig mig(MIG_FREQ,mig_select,mig_replace,topology,pop,pop); +// - Asynchrone communication : peoAsyncIslandMig mig(mig_cont,mig_select,mig_replace,topology,pop,pop); +// With a grid, you should use an asynchrone communication + peoAsyncIslandMig mig(mig_cont,mig_select,mig_replace,topology,pop,pop2); + checkpoint.add(mig); + peoAsyncIslandMig mig2(mig_cont2,mig_select2,mig_replace2,topology,pop2,pop); + checkpoint2.add(mig2); + +// Initialization of the algorithms + peoEA Algo(checkpoint,eval,select,eaTransform,replace); + mig.setOwner(Algo); + Algo(pop); + peoEA Algo2(checkpoint2,eval2,select2,eaTransform2,replace2); + mig2.setOwner(Algo2); + Algo2(pop2); + + peo :: run(); + peo :: finalize(); + if(getNodeRank()==1) + { + std::cout << "Final population 1 :\n" << pop << std::endl; + std::cout << "Final population 2 :\n" << pop2 << std::endl; + } +} diff --git a/trunk/paradiseo-peo/tutorial/Lesson5/main.cpp b/trunk/paradiseo-peo/tutorial/Lesson3/mainPSO.cpp similarity index 58% rename from trunk/paradiseo-peo/tutorial/Lesson5/main.cpp rename to trunk/paradiseo-peo/tutorial/Lesson3/mainPSO.cpp index 1f97d78c2..7c726fea3 100644 --- a/trunk/paradiseo-peo/tutorial/Lesson5/main.cpp +++ b/trunk/paradiseo-peo/tutorial/Lesson3/mainPSO.cpp @@ -1,7 +1,7 @@ /* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 +* (C) OPAC Team, INRIA, 2007 * * Clive Canape * @@ -31,136 +31,122 @@ * * ParadisEO WebSite : http://paradiseo.gforge.inria.fr * Contact: paradiseo-help@lists.gforge.inria.fr -* clive.canape@inria.fr +* */ #include -// You can choose : a replacement or an affectation on the velocity -#define REPLAC - typedef eoRealParticle < double >Indi; - -//Evaluation function double f (const Indi & _indi) { - //Levy function f* = -21.502356 x*=(1,1,1,-9.752356 ) for vector size = 4 - - const double PI = 4.0 * atan(1.0); - double sum=0.; - for (unsigned i = 0; i < _indi.size()-1; i++) - sum+=pow((_indi[i]-1),2)*(1+pow(sin(3*PI*_indi[i+1]),2)); - sum+=pow(sin(3*PI*_indi[0]),2); - sum+=(_indi[_indi.size()-1]-1)*(1+pow(sin(2*PI*_indi[_indi.size()-1]),2)); + 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[]) { -//Initialization - peo :: init( __argc, __argv ); -//Parameters - - const unsigned int MIG_FREQ = 10; // 1 or 2 for peoPSOVelocity ... - const unsigned int VEC_SIZE = 4; - const unsigned int POP_SIZE = 10; - const unsigned int NEIGHBORHOOD_SIZE= 5; - const unsigned int MAX_GEN = 100; - const double INIT_POSITION_MIN = -10.0; - const double INIT_POSITION_MAX = 1.0; - const double INIT_VELOCITY_MIN = -1; - const double INIT_VELOCITY_MAX = 1; - const double C1 = 1; - const double C2 = 0.5; -// c3 is used to calculate of an affectation on the velocity - const double C3 = 2; +// In this lesson, we define two algorithms of the PSO witch represente two islands. +// Obviously, you can define more algorithms. + + // The parameters are commun between the two algorithms. + /*****************************************************************************************/ + 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 = 150; + 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 C1 = 0.5; + const double C2 = 2.; + // C3 is used for the calculation of one of the strategies of the island model. + const double C3 = 2.; + // MIG_FREQ define the frequence of the migration. + const unsigned int MIG_FREQ = 10; // The optimal value is 1 or 2 for the component peoPSOVelocity. rng.reseed (time(0)); - - peoEvalFuncPSO plainEval(f); + /*****************************************************************************************/ + + // Define the topology of your island model + RingTopology topologyMig; + + // First algorithm + /*****************************************************************************************/ + peoEvalFuncPSO plainEval(f); + peoSeqPopEval< Indi > eval(plainEval); // Here, the evaluation is sequential ! eoUniformGenerator < double >uGen (INIT_POSITION_MIN, INIT_POSITION_MAX); - eoInitFixedLength < Indi > random (VEC_SIZE, uGen); + eoInitFixedLength < Indi > random (VEC_SIZE, uGen); eoUniformGenerator < double >sGen (INIT_VELOCITY_MIN, INIT_VELOCITY_MAX); - eoVelocityInitFixedLength < Indi > veloRandom (VEC_SIZE, sGen); + eoVelocityInitFixedLength < Indi > veloRandom (VEC_SIZE, sGen); eoFirstIsBestInit < Indi > localInit; eoRealVectorBounds bndsFlight(VEC_SIZE,INIT_POSITION_MIN,INIT_POSITION_MAX); - eoStandardFlight < Indi > flight(bndsFlight); - eoEvalFuncCounter < Indi > evalSeq (plainEval); - peoParaPopEval< Indi > eval(plainEval); + eoStandardFlight < Indi > flight(bndsFlight); eoPop < Indi > pop; - pop.append (POP_SIZE, random); - apply(evalSeq, pop); - apply < Indi > (veloRandom, pop); - apply < Indi > (localInit, pop); + pop.append (POP_SIZE, random); + peoInitializer init(eval,veloRandom,localInit,pop); eoLinearTopology topology(NEIGHBORHOOD_SIZE); - topology.setup(pop); eoRealVectorBounds bnds(VEC_SIZE,INIT_VELOCITY_MIN,INIT_VELOCITY_MAX); eoStandardVelocity < Indi > velocity (topology,C1,C2,bnds); eoGenContinue < Indi > genContPara (MAX_GEN); eoCheckPoint checkpoint(genContPara); - RingTopology topologyMig; - /*******************************************************************/ - eoPeriodicContinue< Indi > mig_cont( MIG_FREQ ); + // Specific implementation for the island model + eoPeriodicContinue< Indi > mig_cont( MIG_FREQ ); peoPSOSelect mig_selec(topology); eoSelectNumber< Indi > mig_select(mig_selec); -#ifndef REPLAC - peoPSOVelocity mig_replace(C3,velocity); -#else + // If you want to use a replacement stategy : peoPSOReplacement mig_replace; + // If you want to use a consideration of the migration in the calculation of the velocity : peoPSOVelocity mig_replace(C3,velocity); peoPSOReplacement mig_replace; -#endif -/*****************************************************************/ - - +/*****************************************************************************************/ + + // Second algorithm (on the same model but with others names) +/*****************************************************************************************/ peoEvalFuncPSO plainEval2(f); + peoSeqPopEval< Indi > eval2(plainEval2); eoUniformGenerator < double >uGen2 (INIT_POSITION_MIN, INIT_POSITION_MAX); - eoInitFixedLength < Indi > random2 (VEC_SIZE, uGen); + eoInitFixedLength < Indi > random2 (VEC_SIZE, uGen2); eoUniformGenerator < double >sGen2 (INIT_VELOCITY_MIN, INIT_VELOCITY_MAX); - eoVelocityInitFixedLength < Indi > veloRandom2 (VEC_SIZE, sGen2); + eoVelocityInitFixedLength < Indi > veloRandom2 (VEC_SIZE, sGen2); eoFirstIsBestInit < Indi > localInit2; eoRealVectorBounds bndsFlight2(VEC_SIZE,INIT_POSITION_MIN,INIT_POSITION_MAX); - eoStandardFlight < Indi > flight2(bndsFlight2); - eoEvalFuncCounter < Indi > evalSeq2 (plainEval2); - peoParaPopEval< Indi > eval2(plainEval2); + eoStandardFlight < Indi > flight2(bndsFlight2); eoPop < Indi > pop2; - pop2.append (POP_SIZE, random2); - apply(evalSeq2, pop2); - apply < Indi > (veloRandom2, pop2); - apply < Indi > (localInit2, pop2); + pop2.append (POP_SIZE, random2); + peoInitializer init2(eval2,veloRandom2,localInit2,pop2); eoLinearTopology topology2(NEIGHBORHOOD_SIZE); - topology2.setup(pop2); eoRealVectorBounds bnds2(VEC_SIZE,INIT_VELOCITY_MIN,INIT_VELOCITY_MAX); eoStandardVelocity < Indi > velocity2 (topology2,C1,C2,bnds2); eoGenContinue < Indi > genContPara2 (MAX_GEN); eoCheckPoint checkpoint2(genContPara2); - /*******************************************************************/ - eoPeriodicContinue< Indi > mig_cont2( MIG_FREQ ); + eoPeriodicContinue< Indi > mig_cont2( MIG_FREQ ); peoPSOSelect mig_selec2(topology2); eoSelectNumber< Indi > mig_select2(mig_selec2); -#ifndef REPLAC - peoPSOVelocity mig_replace2(C3,velocity2); -#else peoPSOReplacement mig_replace2; -#endif -/*******************************************************************/ +/*****************************************************************************************/ - peoAsyncIslandMig< Indi > mig( mig_cont, mig_select, mig_replace, topologyMig, pop, pop2); + // Define the communication between the islands + peoAsyncIslandMig< Indi > mig( mig_cont, mig_select, mig_replace, topologyMig, pop, pop); checkpoint.add( mig ); - peoAsyncIslandMig< Indi > mig2( mig_cont2, mig_select2, mig_replace2, topologyMig, pop2, pop); - checkpoint.add( mig2 ); - - peoPSO < Indi > psa(checkpoint, eval, velocity, flight); + peoAsyncIslandMig< Indi > mig2( mig_cont2, mig_select2, mig_replace2, topologyMig, pop2, pop2); + checkpoint2.add( mig2 ); + // Initialization of the algorithms + peoPSO < Indi > psa(init,checkpoint, eval, velocity, flight); mig.setOwner( psa ); psa(pop); - peoPSO < Indi > psa2(checkpoint2, eval2, velocity2, flight2); + peoPSO < Indi > psa2(init2,checkpoint2, eval2, velocity2, flight2); mig2.setOwner( psa2 ); psa2(pop2); - + peo :: run(); peo :: finalize(); if(getNodeRank()==1) { - std::cout << "Population 1 :\n" << pop << std::endl; + std::cout << "Population 1 :\n" << pop << std::endl; std::cout << "Population 2 :\n" << pop2 << std::endl; } } diff --git a/trunk/paradiseo-peo/tutorial/Lesson3/paradiseo-peo-lsn.doxyfile b/trunk/paradiseo-peo/tutorial/Lesson3/paradiseo-peo-lsn.doxyfile deleted file mode 100644 index 1d97a8596..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson3/paradiseo-peo-lsn.doxyfile +++ /dev/null @@ -1,241 +0,0 @@ -# Doxyfile 1.4.7 - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = "ParadisEO-PEO Lesson3" -PROJECT_NUMBER = 0.1 -OUTPUT_DIRECTORY = ../../../doc/html/lesson3 -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 diff --git a/trunk/paradiseo-peo/tutorial/Lesson1/lesson.param b/trunk/paradiseo-peo/tutorial/Lesson3/param similarity index 60% rename from trunk/paradiseo-peo/tutorial/Lesson1/lesson.param rename to trunk/paradiseo-peo/tutorial/Lesson3/param index eb843c65f..730f547e1 100644 --- a/trunk/paradiseo-peo/tutorial/Lesson1/lesson.param +++ b/trunk/paradiseo-peo/tutorial/Lesson3/param @@ -6,7 +6,4 @@ --schema=schema.xml -## parameters - ---inst=../examples/tsp/benchs/eil101.tsp diff --git a/trunk/paradiseo-peo/tutorial/Lesson3/schema.xml b/trunk/paradiseo-peo/tutorial/Lesson3/schema.xml deleted file mode 100644 index 9b8bf316c..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson3/schema.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - 1 - 2 - - - - - - - - - diff --git a/trunk/paradiseo-peo/tutorial/Lesson4/CMakeLists.txt b/trunk/paradiseo-peo/tutorial/Lesson4/CMakeLists.txt deleted file mode 100644 index 7a4ac3edc..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson4/CMakeLists.txt +++ /dev/null @@ -1,98 +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/Lesson4/lesson.param ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson4/schema.xml) - -ADD_CUSTOM_COMMAND( - TARGET install - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson4/lesson.param - ${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson4) -ADD_CUSTOM_COMMAND( - TARGET install - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson4/schema.xml - ${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson4) -###################################################################################### - - -###################################################################################### -### 1) Include the sources -###################################################################################### - -INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src ${MO_SRC_DIR}/src ${ParadisEO-PEO_SOURCE_DIR}/src) - -###################################################################################### - - -###################################################################################### -### 2) Specify where CMake can find the libraries -###################################################################################### - -IF(NOT WIN32 OR CYGWIN) - LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${ParadisEO-PEO_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}) -ENDIF(WIN32 AND NOT CYGWIN) -###################################################################################### - - -###################################################################################### -### 3) Define your target(s): just an executable here -###################################################################################### - -ADD_EXECUTABLE(psoExample main.cpp) -ADD_DEPENDENCIES(psoExample peo rmc_mpi) -###################################################################################### - - -###################################################################################### -### 4) Optionnal: define properties -###################################################################################### - -SET(LESSON4_VERSION ${GLOBAL_VERSION}) -SET_TARGET_PROPERTIES(psoExample PROPERTIES VERSION "${LESSON4_VERSION}") -###################################################################################### - - -###################################################################################### -### 5) Link the librairies -###################################################################################### - -TARGET_LINK_LIBRARIES(psoExample ${XML2_LIBS} peo rmc_mpi eo eoutils) - -###################################################################################### - - -###################################################################################### -### 6) Windows advanced config - especially for Microsoft Visual Studio 8 -###################################################################################### - - IF(CMAKE_CXX_COMPILER MATCHES cl) - IF(NOT WITH_SHARED_LIBS) - IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005") - SET(CMAKE_CXX_FLAGS "/nologo /W3 /Gy") - SET(CMAKE_CXX_FLAGS_DEBUG "/MTd /Z7 /Od") - SET(CMAKE_CXX_FLAGS_RELEASE "/MT /O2") - SET(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O2") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MTd /Z7 /Od") - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") - - ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005") - ENDIF(NOT WITH_SHARED_LIBS) - ENDIF(CMAKE_CXX_COMPILER MATCHES cl) -###################################################################################### - - - diff --git a/trunk/paradiseo-peo/tutorial/Lesson4/mainEA.cpp b/trunk/paradiseo-peo/tutorial/Lesson4/mainEA.cpp new file mode 100644 index 000000000..878e7dea2 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/Lesson4/mainEA.cpp @@ -0,0 +1,152 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, INRIA, 2007 +* +* Clive Canape +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#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[]) +{ + +// In this lesson, we can see an exemple of an evolutionary algorithms with three islands. +// The evaluation is parallel. +// The transformation is parallel. + + peo :: init( __argc, __argv ); + 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; + const unsigned int MIG_FREQ = 10; + const unsigned int MIG_SIZE = 5; + rng.reseed (time(0)); + RingTopology topology; + eoGenContinue < Indi > genContPara (MAX_GEN); + eoCombinedContinue continuatorPara (genContPara); + eoCheckPoint checkpoint(continuatorPara); + peoEvalFunc plainEval(f); + peoParaPopEval< Indi > eval(plainEval); + 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); + peoParaSGATransform eaTransform(crossover,CROSS_RATE,mutation,MUT_RATE); + eoPlusReplacement replace; + eoPop < Indi > pop; + pop.append (POP_SIZE, random); + eoPeriodicContinue mig_cont( MIG_FREQ ); + eoRandomSelect mig_select_one; + eoSelectNumber mig_select (mig_select_one,MIG_SIZE); + eoPlusReplacement mig_replace; + eoGenContinue < Indi > genContPara2 (MAX_GEN); + eoCombinedContinue continuatorPara2 (genContPara2); + eoCheckPoint checkpoint2(continuatorPara2); + peoEvalFunc plainEval2(f); + peoParaPopEval< Indi > eval2(plainEval2); + 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); + peoParaSGATransform eaTransform2(crossover2,CROSS_RATE,mutation2,MUT_RATE); + eoPlusReplacement replace2; + eoPop < Indi > pop2; + pop2.append (POP_SIZE, random2); + eoPeriodicContinue mig_cont2( MIG_FREQ ); + eoRandomSelect mig_select_one2; + eoSelectNumber mig_select2 (mig_select_one2,MIG_SIZE); + eoPlusReplacement mig_replace2; + eoGenContinue < Indi > genContPara3 (MAX_GEN); + eoCombinedContinue continuatorPara3 (genContPara3); + eoCheckPoint checkpoint3(continuatorPara3); + peoEvalFunc plainEval3(f); + peoParaPopEval< Indi > eval3(plainEval3); + eoUniformGenerator < double >uGen3 (INIT_POSITION_MIN, INIT_POSITION_MAX); + eoInitFixedLength < Indi > random3 (VEC_SIZE, uGen3); + eoRankingSelect selectionStrategy3; + eoSelectNumber select3(selectionStrategy3,POP_SIZE); + eoSegmentCrossover crossover3; + eoUniformMutation mutation3(EPSILON); + peoParaSGATransform eaTransform3(crossover3,CROSS_RATE,mutation3,MUT_RATE); + eoPlusReplacement replace3; + eoPop < Indi > pop3; + pop3.append (POP_SIZE, random3); + eoPeriodicContinue mig_cont3( MIG_FREQ ); + eoRandomSelect mig_select_one3; + eoSelectNumber mig_select3 (mig_select_one3,MIG_SIZE); + eoPlusReplacement mig_replace3; + peoAsyncIslandMig mig(mig_cont,mig_select,mig_replace,topology,pop,pop2); + checkpoint.add(mig); + peoAsyncIslandMig mig2(mig_cont2,mig_select2,mig_replace2,topology,pop2,pop); + checkpoint2.add(mig2); + peoAsyncIslandMig mig3(mig_cont3,mig_select3,mig_replace3,topology,pop3,pop); + checkpoint3.add(mig3); + peoEA Algo(checkpoint,eval,select,eaTransform,replace); + mig.setOwner(Algo); + Algo(pop); + peoEA Algo2(checkpoint2,eval2,select2,eaTransform2,replace2); + mig2.setOwner(Algo2); + Algo2(pop2); + peoEA Algo3(checkpoint3,eval3,select3,eaTransform3,replace3); + mig3.setOwner(Algo3); + Algo3(pop3); + + peo :: run(); + peo :: finalize(); + if(getNodeRank()==1) + { + std::cout << "Final population 1 :\n" << pop << std::endl; + std::cout << "Final population 2 :\n" << pop2 << std::endl; + std::cout << "Final population 3 :\n" << pop3 << std::endl; + } +} diff --git a/trunk/paradiseo-peo/tutorial/Lesson4/mainPSO.cpp b/trunk/paradiseo-peo/tutorial/Lesson4/mainPSO.cpp new file mode 100644 index 000000000..ac20ddbb2 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/Lesson4/mainPSO.cpp @@ -0,0 +1,159 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, INRIA, 2007 +* +* Clive Canape +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#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[]) +{ + +// In this lesson, we can see an exemple of a PSO with three islands. +// The stategy of migration is the replacement. +// The evaluation is parallel. + + 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 = 150; + 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 C1 = 0.5; + const double C2 = 2.; + const double C3 = 2.; + const unsigned int MIG_FREQ = 10; + rng.reseed (time(0)); + RingTopology topologyMig; + peoEvalFuncPSO plainEval(f); + peoParaPopEval< 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); + peoInitializer init(eval,veloRandom,localInit,pop); + eoLinearTopology topology(NEIGHBORHOOD_SIZE); + eoRealVectorBounds bnds(VEC_SIZE,INIT_VELOCITY_MIN,INIT_VELOCITY_MAX); + eoStandardVelocity < Indi > velocity (topology,C1,C2,bnds); + eoGenContinue < Indi > genContPara (MAX_GEN); + eoCheckPoint checkpoint(genContPara); + eoPeriodicContinue< Indi > mig_cont( MIG_FREQ ); + peoPSOSelect mig_selec(topology); + eoSelectNumber< Indi > mig_select(mig_selec); + peoPSOReplacement mig_replace; + peoEvalFuncPSO plainEval2(f); + peoParaPopEval< 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); + eoPop < Indi > pop2; + pop2.append (POP_SIZE, random2); + peoInitializer init2(eval2,veloRandom2,localInit2,pop2); + eoLinearTopology topology2(NEIGHBORHOOD_SIZE); + eoRealVectorBounds bnds2(VEC_SIZE,INIT_VELOCITY_MIN,INIT_VELOCITY_MAX); + eoStandardVelocity < Indi > velocity2 (topology2,C1,C2,bnds2); + eoGenContinue < Indi > genContPara2 (MAX_GEN); + eoCheckPoint checkpoint2(genContPara2); + eoPeriodicContinue< Indi > mig_cont2( MIG_FREQ ); + peoPSOSelect mig_selec2(topology2); + eoSelectNumber< Indi > mig_select2(mig_selec2); + peoPSOReplacement mig_replace2; + peoEvalFuncPSO plainEval3(f); + peoParaPopEval< Indi > eval3(plainEval3); + eoUniformGenerator < double >uGen3 (INIT_POSITION_MIN, INIT_POSITION_MAX); + eoInitFixedLength < Indi > random3 (VEC_SIZE, uGen3); + eoUniformGenerator < double >sGen3 (INIT_VELOCITY_MIN, INIT_VELOCITY_MAX); + eoVelocityInitFixedLength < Indi > veloRandom3 (VEC_SIZE, sGen3); + eoFirstIsBestInit < Indi > localInit3; + eoRealVectorBounds bndsFlight3(VEC_SIZE,INIT_POSITION_MIN,INIT_POSITION_MAX); + eoStandardFlight < Indi > flight3(bndsFlight3); + eoPop < Indi > pop3; + pop3.append (POP_SIZE, random3); + peoInitializer init3(eval3,veloRandom3,localInit3,pop3); + eoLinearTopology topology3(NEIGHBORHOOD_SIZE); + eoRealVectorBounds bnds3(VEC_SIZE,INIT_VELOCITY_MIN,INIT_VELOCITY_MAX); + eoStandardVelocity < Indi > velocity3 (topology3,C1,C2,bnds3); + eoGenContinue < Indi > genContPara3 (MAX_GEN); + eoCheckPoint checkpoint3(genContPara3); + eoPeriodicContinue< Indi > mig_cont3( MIG_FREQ ); + peoPSOSelect mig_selec3(topology3); + eoSelectNumber< Indi > mig_select3(mig_selec3); + peoPSOReplacement mig_replace3; + peoAsyncIslandMig< Indi > mig( mig_cont, mig_select, mig_replace, topologyMig, pop, pop2); + checkpoint.add( mig ); + peoAsyncIslandMig< Indi > mig2( mig_cont2, mig_select2, mig_replace2, topologyMig, pop2, pop3); + checkpoint2.add( mig2 ); + peoAsyncIslandMig< Indi > mig3( mig_cont3, mig_select3, mig_replace3, topologyMig, pop3, pop); + checkpoint3.add( mig3 ); + peoPSO < Indi > psa(init,checkpoint, eval, velocity, flight); + mig.setOwner( psa ); + psa(pop); + peoPSO < Indi > psa2(init2,checkpoint2, eval2, velocity2, flight2); + mig2.setOwner( psa2 ); + psa2(pop2); + peoPSO < Indi > psa3(init3,checkpoint3, eval3, velocity3, flight3); + mig3.setOwner( psa3 ); + psa3(pop3); + + peo :: run(); + peo :: finalize(); + if(getNodeRank()==1) + { + std::cout << "Population 1 :\n" << pop << std::endl; + std::cout << "Population 2 :\n" << pop2 << std::endl; + std::cout << "Population 3 :\n" << pop3 << std::endl; + } +} diff --git a/trunk/paradiseo-peo/tutorial/Lesson4/paradiseo-peo.lsn.doxyfile b/trunk/paradiseo-peo/tutorial/Lesson4/paradiseo-peo-lsn.doxyfile similarity index 99% rename from trunk/paradiseo-peo/tutorial/Lesson4/paradiseo-peo.lsn.doxyfile rename to trunk/paradiseo-peo/tutorial/Lesson4/paradiseo-peo-lsn.doxyfile index 35766a845..bd82ebc84 100644 --- a/trunk/paradiseo-peo/tutorial/Lesson4/paradiseo-peo.lsn.doxyfile +++ b/trunk/paradiseo-peo/tutorial/Lesson4/paradiseo-peo-lsn.doxyfile @@ -239,3 +239,4 @@ DOT_CLEANUP = YES # Configuration::additions related to the search engine #--------------------------------------------------------------------------- SEARCHENGINE = YES + diff --git a/trunk/paradiseo-peo/tutorial/Lesson3/lesson.param b/trunk/paradiseo-peo/tutorial/Lesson4/param similarity index 60% rename from trunk/paradiseo-peo/tutorial/Lesson3/lesson.param rename to trunk/paradiseo-peo/tutorial/Lesson4/param index eb843c65f..730f547e1 100644 --- a/trunk/paradiseo-peo/tutorial/Lesson3/lesson.param +++ b/trunk/paradiseo-peo/tutorial/Lesson4/param @@ -6,7 +6,4 @@ --schema=schema.xml -## parameters - ---inst=../examples/tsp/benchs/eil101.tsp diff --git a/trunk/paradiseo-peo/tutorial/Lesson4/schema.xml b/trunk/paradiseo-peo/tutorial/Lesson4/schema.xml deleted file mode 100644 index 9b8bf316c..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson4/schema.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - 1 - 2 - - - - - - - - - diff --git a/trunk/paradiseo-peo/tutorial/Lesson5/CMakeLists.txt b/trunk/paradiseo-peo/tutorial/Lesson5/CMakeLists.txt deleted file mode 100644 index 469ac6dfe..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson5/CMakeLists.txt +++ /dev/null @@ -1,98 +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/Lesson5/lesson.param ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson5/schema.xml) - -ADD_CUSTOM_COMMAND( - TARGET install - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson5/lesson.param - ${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson5) -ADD_CUSTOM_COMMAND( - TARGET install - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson5/schema.xml - ${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson5) -###################################################################################### - - -###################################################################################### -### 1) Include the sources -###################################################################################### - -INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src ${MO_SRC_DIR}/src ${ParadisEO-PEO_SOURCE_DIR}/src) - -###################################################################################### - - -###################################################################################### -### 2) Specify where CMake can find the libraries -###################################################################################### - -IF(NOT WIN32 OR CYGWIN) - LINK_DIRECTORIES(${EO_BIN_DIR}/lib ${ParadisEO-PEO_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}) -ENDIF(WIN32 AND NOT CYGWIN) -###################################################################################### - - -###################################################################################### -### 3) Define your target(s): just an executable here -###################################################################################### - -ADD_EXECUTABLE(psoExample main.cpp) -ADD_DEPENDENCIES(psoExample peo rmc_mpi) -###################################################################################### - - -###################################################################################### -### 4) Optionnal: define properties -###################################################################################### - -SET(LESSON4_VERSION ${GLOBAL_VERSION}) -SET_TARGET_PROPERTIES(psoExample PROPERTIES VERSION "${LESSON4_VERSION}") -###################################################################################### - - -###################################################################################### -### 5) Link the librairies -###################################################################################### - -TARGET_LINK_LIBRARIES(psoExample ${XML2_LIBS} peo rmc_mpi eo eoutils) - -###################################################################################### - - -###################################################################################### -### 6) Windows advanced config - especially for Microsoft Visual Studio 8 -###################################################################################### - - IF(CMAKE_CXX_COMPILER MATCHES cl) - IF(NOT WITH_SHARED_LIBS) - IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005") - SET(CMAKE_CXX_FLAGS "/nologo /W3 /Gy") - SET(CMAKE_CXX_FLAGS_DEBUG "/MTd /Z7 /Od") - SET(CMAKE_CXX_FLAGS_RELEASE "/MT /O2") - SET(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O2") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MTd /Z7 /Od") - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") - - ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005") - ENDIF(NOT WITH_SHARED_LIBS) - ENDIF(CMAKE_CXX_COMPILER MATCHES cl) -###################################################################################### - - - diff --git a/trunk/paradiseo-peo/tutorial/Lesson5/mainEA.cpp b/trunk/paradiseo-peo/tutorial/Lesson5/mainEA.cpp new file mode 100644 index 000000000..8ce3d8f31 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/Lesson5/mainEA.cpp @@ -0,0 +1,43 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, INRIA, 2007 +* +* Clive Canape +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#include +#include + +int main (int __argc, char *__argv[]) +{ + std::cout<<"\nHybridization\n"; +} diff --git a/trunk/paradiseo-peo/tutorial/Lesson5/mainPSO.cpp b/trunk/paradiseo-peo/tutorial/Lesson5/mainPSO.cpp new file mode 100644 index 000000000..6087c7195 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/Lesson5/mainPSO.cpp @@ -0,0 +1,42 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, INRIA, 2007 +* +* Clive Canape +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#include + +int main (int __argc, char *__argv[]) +{ + std::cout<<"\nHybridization\n"; +} diff --git a/trunk/paradiseo-peo/tutorial/Lesson5/paradiseo-peo.lsn.doxyfile b/trunk/paradiseo-peo/tutorial/Lesson5/paradiseo-peo-lsn.doxyfile similarity index 99% rename from trunk/paradiseo-peo/tutorial/Lesson5/paradiseo-peo.lsn.doxyfile rename to trunk/paradiseo-peo/tutorial/Lesson5/paradiseo-peo-lsn.doxyfile index 8a0b3d3fe..c0f644a90 100644 --- a/trunk/paradiseo-peo/tutorial/Lesson5/paradiseo-peo.lsn.doxyfile +++ b/trunk/paradiseo-peo/tutorial/Lesson5/paradiseo-peo-lsn.doxyfile @@ -239,3 +239,4 @@ DOT_CLEANUP = YES # Configuration::additions related to the search engine #--------------------------------------------------------------------------- SEARCHENGINE = YES + diff --git a/trunk/paradiseo-peo/tutorial/Lesson5/param b/trunk/paradiseo-peo/tutorial/Lesson5/param new file mode 100644 index 000000000..730f547e1 --- /dev/null +++ b/trunk/paradiseo-peo/tutorial/Lesson5/param @@ -0,0 +1,9 @@ +## miscallenous parameters + +--debug=false + +## deployment schema + +--schema=schema.xml + + diff --git a/trunk/paradiseo-peo/tutorial/Lesson5/schema.xml b/trunk/paradiseo-peo/tutorial/Lesson5/schema.xml deleted file mode 100644 index 9b8bf316c..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson5/schema.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - 1 - 2 - - - - - - - - - diff --git a/trunk/paradiseo-peo/tutorial/Lesson6/CMakeLists.txt b/trunk/paradiseo-peo/tutorial/Lesson6/CMakeLists.txt deleted file mode 100644 index d4e2ec44f..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson6/CMakeLists.txt +++ /dev/null @@ -1,99 +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/Lesson6/lesson.param ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson6/schema.xml) - -ADD_CUSTOM_COMMAND( - TARGET install - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson6/lesson.param - ${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson6) -ADD_CUSTOM_COMMAND( - TARGET install - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - ${ParadisEO-PEO_SOURCE_DIR}/tutorial/Lesson6/schema.xml - ${ParadisEO-PEO_BINARY_DIR}/tutorial/Lesson6) - -###################################################################################### - - -###################################################################################### -### 1) Include the sources -###################################################################################### - -INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src ${MO_SRC_DIR}/src ${ParadisEO-PEO_SOURCE_DIR}/src ${TSP_SRC_DIR}) - -###################################################################################### - - -###################################################################################### -### 2) Specify where CMake can find the libraries -###################################################################################### - -IF(NOT WIN32 OR CYGWIN) - LINK_DIRECTORIES(${EO_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(tspExample main.cpp) -ADD_DEPENDENCIES(tspExample tsp peo rmc_mpi) -###################################################################################### - - -###################################################################################### -### 4) Optionnal: define properties -###################################################################################### - -SET(LESSON6_VERSION ${GLOBAL_VERSION}) -SET_TARGET_PROPERTIES(tspExample PROPERTIES VERSION "${LESSON6_VERSION}") -###################################################################################### - - -###################################################################################### -### 5) Link the librairies -###################################################################################### - -TARGET_LINK_LIBRARIES(tspExample ${XML2_LIBS} tsp peo rmc_mpi eo eoutils) - -###################################################################################### - - -###################################################################################### -### 6) Windows advanced config - especially for Microsoft Visual Studio 8 -###################################################################################### - - IF(CMAKE_CXX_COMPILER MATCHES cl) - IF(NOT WITH_SHARED_LIBS) - IF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005") - SET(CMAKE_CXX_FLAGS "/nologo /W3 /Gy") - SET(CMAKE_CXX_FLAGS_DEBUG "/MTd /Z7 /Od") - SET(CMAKE_CXX_FLAGS_RELEASE "/MT /O2") - SET(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O2") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MTd /Z7 /Od") - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") - - ENDIF(CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005") - ENDIF(NOT WITH_SHARED_LIBS) - ENDIF(CMAKE_CXX_COMPILER MATCHES cl) -###################################################################################### - - - diff --git a/trunk/paradiseo-peo/tutorial/Lesson6/lesson.param b/trunk/paradiseo-peo/tutorial/Lesson6/lesson.param deleted file mode 100644 index eb843c65f..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson6/lesson.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/Lesson6/main.cpp b/trunk/paradiseo-peo/tutorial/Lesson6/main.cpp deleted file mode 100644 index 5287a4fec..000000000 --- a/trunk/paradiseo-peo/tutorial/Lesson6/main.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* -* -* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 -* -* Clive Canape -* -* This software is governed by the CeCILL license under French law and -* abiding by the rules of distribution of free software. You can use, -* modify and/ or redistribute the software under the terms of the CeCILL -* license as circulated by CEA, CNRS and INRIA at the following URL -* "http://www.cecill.info". -* -* As a counterpart to the access to the source code and rights to copy, -* modify and redistribute granted by the license, users are provided only -* with a limited warranty and the software's author, the holder of the -* economic rights, and the successive licensors have only limited liability. -* -* In this respect, the user's attention is drawn to the risks associated -* with loading, using, modifying and/or developing or reproducing the -* software by the user in light of its specific status of free software, -* that may mean that it is complicated to manipulate, and that also -* therefore means that it is reserved for developers and experienced -* professionals having in-depth computer knowledge. Users are therefore -* encouraged to load and test the software's suitability as regards their -* requirements in conditions enabling the security of their systems and/or -* data to be ensured and, more generally, to use and operate it in the -* same conditions as regards security. -* The fact that you are presently reading this means that you have had -* knowledge of the CeCILL license and that you accept its terms. -* -* ParadisEO WebSite : http://paradiseo.gforge.inria.fr -* Contact: paradiseo-help@lists.gforge.inria.fr -* clive.canape@inria.fr -*/ - -#include "route.h" -#include "route_init.h" -#include "route_eval.h" - -#include "order_xover.h" -#include "city_swap.h" - -#include "param.h" - -#include "merge_route_eval.h" -#include "part_route_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 ) { - - // initializing the ParadisEO-PEO environment - peo :: init( __argc, __argv ); - - - // processing the command line specified parameters - loadParameters( __argc, __argv ); - - // init, eval operators, EA operators ------------------------------------------------------------------------------------------------------------- - - RouteInit route_init; // random init object - creates random Route objects - RouteEval full_eval; // evaluator object - offers a fitness value for a specified Route object - OrderXover crossover; // crossover operator - creates two offsprings out of two specified parents - CitySwap mutation; // mutation operator - randomly mutates one gene for a specified individual - // ------------------------------------------------------------------------------------------------------------------------------------------------ - - - // evolutionary algorithm components -------------------------------------------------------------------------------------------------------------- - - /* - * You can change the size of the population thanks POP_SIZE - * - */ - - eoPop< Route > population( POP_SIZE, route_init ); - - /* - * If you want to use a parallel evaluation : peoParaPopEval< Route > eaPopEval( full_eval ); - * Else, you can use a sequential evaluation : peoSeqPopEval< Route > eaPopEval( full_eval ); - * - */ - peoParaPopEval< Route > eaPopEval( full_eval ); - - /* - * Continuation criterion - */ - eoGenContinue< Route > eaCont( NUM_GEN ); - eoCheckPoint< Route > eaCheckpointContinue( eaCont ); - - /* - * Selection strategy - */ - eoRankingSelect< Route > selectionStrategy; - eoSelectNumber< Route > eaSelect( selectionStrategy, POP_SIZE ); - - /* With this transform operator, you can use a parallel crossover and a parallel mutation - * - * Unfortunately, if you don't use a crossover which creates two children with two parents, - * you can't use this operator. - * In this case, you should send a mail to : paradiseo-help@lists.gforge.inria.fr - * - */ - peoParaSGATransform< Route > eaTransform( crossover, CROSS_RATE, mutation, MUT_RATE ); // ParadisEO transform operator (please remark the peo prefix) - wraps an e EO transform object - - /* - * Replacement strategy - */ - eoPlusReplacement< Route > eaReplace; - - - // ParadisEO-PEO evolutionary algorithm ----------------------------------------------------------------------------------------------------------- - - peoEA< Route > eaAlg( eaCheckpointContinue, eaPopEval, eaSelect, eaTransform, eaReplace ); - - eaAlg( population ); // specifying the initial population for the algorithm, to be iteratively evolved - // ------------------------------------------------------------------------------------------------------------------------------------------------ - - - peo :: run( ); - peo :: finalize( ); - - if(getNodeRank()==1) - std::cout<<"\n\nPopulation :\n"< - - - - - - - - 1 - - - - - - - - -