main.cpp

00001 // "main.cpp"
00002 
00003 // (c) OPAC Team, LIFL, January 2006
00004 
00005 /* 
00006    Contact: paradiseo-help@lists.gforge.inria.fr
00007 */
00008 
00009 #include "route.h"
00010 #include "route_init.h"
00011 #include "route_eval.h"
00012 
00013 #include "order_xover.h"
00014 #include "city_swap.h"
00015 
00016 #include "param.h"
00017 
00018 #include <paradiseo>
00019 
00020 
00021 #define POP_SIZE 10
00022 #define NUM_GEN 100
00023 #define CROSS_RATE 1.0
00024 #define MUT_RATE 0.01
00025 
00026 
00027 int main( int __argc, char** __argv ) {
00028 
00029         // initializing the ParadisEO-PEO environment
00030         peo :: init( __argc, __argv );
00031 
00032 
00033         // processing the command line specified parameters
00034         loadParameters( __argc, __argv );
00035 
00036 
00037         // init, eval operators, EA operators -------------------------------------------------------------------------------------------------------------
00038 
00039         RouteInit route_init;   // random init object - creates random Route objects
00040         RouteEval full_eval;    // evaluator object - offers a fitness value for a specified Route object
00041 
00042         OrderXover crossover;   // crossover operator - creates two offsprings out of two specified parents
00043         CitySwap mutation;      // mutation operator - randomly mutates one gene for a specified individual
00044         // ------------------------------------------------------------------------------------------------------------------------------------------------
00045 
00046 
00047         // evolutionary algorithm components --------------------------------------------------------------------------------------------------------------
00048 
00049         eoPop< Route > population( POP_SIZE, route_init );      // initial population for the algorithm having POP_SIZE individuals
00050         peoSeqPopEval< Route > eaPopEval( full_eval );          // evaluator object - to be applied at each iteration on the entire population
00051 
00052         eoGenContinue< Route > eaCont( NUM_GEN );               // continuation criterion - the algorithm will iterate for NUM_GEN generations
00053         eoCheckPoint< Route > eaCheckpointContinue( eaCont );   // checkpoint object - verify at each iteration if the continuation criterion is met
00054 
00055         eoRankingSelect< Route > selectionStrategy;             // selection strategy - applied at each iteration for selecting parent individuals
00056         eoSelectNumber< Route > eaSelect( selectionStrategy, POP_SIZE ); // selection object - POP_SIZE individuals are selected at each iteration
00057 
00058         // transform operator - includes the crossover and the mutation operators with a specified associated rate
00059         eoSGATransform< Route > transform( crossover, CROSS_RATE, mutation, MUT_RATE );
00060         peoSeqTransform< Route > eaTransform( transform );      // ParadisEO transform operator (please remark the peo prefix) - wraps an e EO transform object
00061 
00062         eoPlusReplacement< Route > eaReplace;                   // replacement strategy - for replacing the initial population with offspring individuals
00063         // ------------------------------------------------------------------------------------------------------------------------------------------------
00064 
00065 
00066         // ParadisEO-PEO evolutionary algorithm -----------------------------------------------------------------------------------------------------------
00067 
00068         peoEA< Route > eaAlg( eaCheckpointContinue, eaPopEval, eaSelect, eaTransform, eaReplace );
00069         
00070         eaAlg( population );    // specifying the initial population for the algorithm, to be iteratively evolved
00071         // ------------------------------------------------------------------------------------------------------------------------------------------------
00072 
00073 
00074         peo :: run( );
00075         peo :: finalize( );
00076         // shutting down the ParadisEO-PEO environment
00077 
00078         return 0;
00079 }

Generated on Tue Jan 9 15:47:43 2007 for ParadisEO-PEO Lesson1 by  doxygen 1.4.7