added new tutorial dir

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@467 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
legrand 2007-06-29 11:58:51 +00:00
commit 71169cf7f0
61 changed files with 3459 additions and 0 deletions

View file

@ -0,0 +1,16 @@
#
#####################################################################################
### 1) Definitions (required for tsp target)
######################################################################################
SET(TSP_EXAMPLE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/examples/tsp CACHE PATH "TSP example directory")
######################################################################################
######################################################################################
### 2) Where must cmake go now ?
######################################################################################
SUBDIRS(examples Lesson1 Lesson2)
######################################################################################

View file

@ -0,0 +1,16 @@
######################################################################################
### 0) Need lesson1 directory
######################################################################################
SET(TUTORIAL_LESSON1_DIR ${CMAKE_CURRENT_SOURCE_DIR})
######################################################################################
######################################################################################
### 1) Where must cmake go now ?
######################################################################################
SUBDIRS(src)
######################################################################################

View file

@ -0,0 +1,11 @@
## miscallenous parameters
--debug=false
## deployment schema
--schema=../schema.xml
## parameters
--inst=../../examples/tsp/benchs/eil101.tsp

View file

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<schema>
<group scheduler="0">
<node name="0" num_workers="0">
</node>
<node name="1" num_workers="0">
<runner>1</runner>
</node>
<node name="2" num_workers="1">
</node>
<node name="3" num_workers="1">
</node>
</group>
</schema>

View file

@ -0,0 +1,75 @@
######################################################################################
### 0) Set the compiler
######################################################################################
SET (CMAKE_CXX_COMPILER mpicxx)
######################################################################################
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${EO_SRC_DIR})
INCLUDE_DIRECTORIES(${MO_SRC_DIR})
INCLUDE_DIRECTORIES(${PEO_SRC_DIR})
INCLUDE_DIRECTORIES(${TSP_EXAMPLE_DIR}/src)
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries (mandatory: before 3) )
######################################################################################
LINK_DIRECTORIES( ${EO_SRC_DIR}
${EO_SRC_DIR}/utils
${PEO_DIR}/build
${TSP_EXAMPLE_DIR}/build)
######################################################################################
######################################################################################
### 3) Define your target(s): just an executable here
######################################################################################
# no matter what is the OS, hopefully
ADD_EXECUTABLE(tspExample main.cpp)
ADD_DEPENDENCIES(tspExample tsp)
ADD_DEPENDENCIES(tspExample peo)
ADD_DEPENDENCIES(tspExample rmc_mpi)
SET(EXECUTABLE_OUTPUT_PATH ${TUTORIAL_LESSON1_DIR}/build)
######################################################################################
######################################################################################
### 4) Optionnal: define your target(s)'s version: no effect for windows
######################################################################################
SET(LESSON1_VERSION "1.0.beta")
SET_TARGET_PROPERTIES(tspExample PROPERTIES VERSION "${LESSON1_VERSION}")
######################################################################################
######################################################################################
### 5) Link the librairies
######################################################################################
TARGET_LINK_LIBRARIES(tspExample ${XML2_LIBS}) # define in CMakeLists.txt at PEO root dir
TARGET_LINK_LIBRARIES(tspExample tsp)
TARGET_LINK_LIBRARIES(tspExample peo)
TARGET_LINK_LIBRARIES(tspExample rmc_mpi)
TARGET_LINK_LIBRARIES(tspExample eo)
TARGET_LINK_LIBRARIES(tspExample eoutils)
######################################################################################

View file

@ -0,0 +1,498 @@
//! \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 <b>peoEA.h</b>
//! 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.
//!
//! <table style="border:none; border-spacing:0px;text-align:left; vertical-align:top; font-size:8pt;" border="0">
//! <tr><td><b>do</b> { &nbsp;</td> <td> &nbsp; </td></tr>
//! <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select( population, offsprings ); &nbsp;</td> <td>// select the offsprings from the current population</td></tr>
//! <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transform( offsprings ); &nbsp;</td> <td>// crossover and mutation operators are applied on the selected offsprings</td></tr>
//! <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; evaluate( offsprings ); &nbsp;</td> <td>// evaluation step of the resulting offsprings</td></tr>
//! <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; replace( population, offsprings ); &nbsp;</td> <td>// replace the individuals in the current population whith individuals from the offspring population, according to a specified replacement strategy</td></tr>
//! <tr><td>} <b>while</b> ( eaCheckpointContinue( population ) ); &nbsp;</td> <td>// checkpoint operators are applied on the current population</td></tr>
//! </table>
//!
//! 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.
//! <br/>
//!
//! \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:
//! <b>
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; ...
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; paradiseo-mo
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; paradiseo-moeo
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; paradiseo-peo
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; docs
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; examples
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lesson1
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lesson2
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; shared
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; src
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; ...
//! </b>
//! <br/>
//!
//! The source-code for this tutorial may be found in the <b>paradiseo-peo/examples/lesson1</b> directory, in the <b>main.cpp</b> 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 <b>paradiseo-peo/examples/shared</b>. After the installation
//! phase you should end up having an <b>tspExample</b> executable file in the <b>paradiseo-peo/examples/lesson1</b> 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.
//!
//! <hr/>
//! <b>NOTE</b>: All the presented examples have as case study the <i>Traveling Salesman Problem (TSP)</i>. All the presented tutorials rely
//! on a <a href="../../lsnshared/html/index.html" target="new">common shared source code</a> 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.
//! <hr/><br/>
//!
//! \section problemDef Problem Definition and Representation
//!
//! As we are not directly concerned with the <i>Traveling Salesman Problem</i>, 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:
//!
//! <table border="0" width="100%">
//! <tr><td style="vertical-align:top;">
//! &nbsp;&nbsp;&nbsp;&nbsp; peoEA(
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eoContinue< EOT >& __cont,
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; peoPopEval< EOT >& __pop_eval,
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eoSelect< EOT >& __select,
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; peoTransform< EOT >& __trans,
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eoReplacement< EOT >& __replace
//! <br/>&nbsp;&nbsp;&nbsp;&nbsp; );
//! </td>
//! <td style="vertical-align:top; text-align:center;">
//! \image html peoEA.png
//! </td></tr>
//! </table>
//!
//! 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 <a href="../../lsnshared/html/index.html" target="new">common shared source code</a>.
//! Each of the bellow referred header files may be found in the <b>pardiseo-peo/examples/shared</b> directory.
//!
//! <ol>
//! <li><i><b>representation</b></i> - 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. <br/>
//!
//! For our case study, the TSP, each city is defined as a Node in the <b>node.h</b> header file - in fact an unsigned value defined
//! as <b>typedef unsigned Node</b>. Moreover, each individual (of the evolutionary algorithm) is represented as a Route object, a vector of Node objects, in
//! the <b>route.h</b> header file - <b>typedef eoVector< int, Node > Route</b>. 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 <b>route_init.h</b> header file which includes the RouteInit class, defined for
//! initializing in random manner Route objects.
//! </li>
//! <li><i><b>evaluation function</b></i> - 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. <br/>
//!
//! The fitness function for our TSP case study is implemented in the <b>route_eval.h</b> header file. The class is derived from the eoEvalFunc
//! EO class, being defined as <b>class RouteEval : public eoEvalFunc< Route ></b>.
//! </li>
//! <li><i><b>transformation operators</b></i> - 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 <b>order_xover.h</b> and the <b>city_swap.h</b>
//! header files, respectively.
//! </li>
//! <li><i><b>continuation criterion</b></i> - 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.<br/>
//! </li>
//! <li><i><b>selection strategy</b></i> - 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.
//! </li>
//! <li><i><b>replacement strategy</b></i> - 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).
//! </li>
//! </ol>
//! <br/>
//!
//! \section example A simple example for constructing a peoEA object
//!
//! The source code for this example may be found in the <b>main.cpp</b> file, under the <b>paradiseo-peo/examples/lesson1</b> directory. Please make sure you
//! At this point you have two options: (a) you can just follow the example without touching the <b>main.cpp</b> or, (b) you can start from scratch,
//! following the presented steps, in which case you are required make a backup copy of the <b>main.cpp</b> file and replace the original file with an
//! empty one.
//!
//! <ol>
//! <li> <b>include the necessary header files</b> - 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:<br/>
//!
//! <pre>
//! ##include "route.h"
//! ##include "route_init.h"
//! ##include "route_eval.h"
//!
//! ##include "order_xover.h"
//! ##include "city_swap.h"
//! </pre>
//! In addition we require having the <i>paradiseo</i> header file, in order to use the ParadisEO-PEO features, and a header specific
//! for our problem, dealing with processing command-line parameters - the <b>param.h</b> header file. The complete picture at this point
//! with all the required header files is as follows:<br/>
//!
//! <pre>
//! ##include "route.h"
//! ##include "route_init.h"
//! ##include "route_eval.h"
//!
//! ##include "order_xover.h"
//! ##include "city_swap.h"
//!
//! ##include "param.h"
//!
//! ##include &lt;paradiseo&gt;
//! </pre>
//! <b>NOTE</b>: the <b><i>paradiseo</i></b> 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 <b><i>paradiseo</i></b> header file or to explicitly include different header files,
//! like the <b>peoEA.h</b> header file, for example.
//!
//! </li>
//! <li> <b>define problem specific parameters</b> - 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.<br/>
//!
//! <pre>
//! ##include "route.h"
//! ##include "route_init.h"
//! ##include "route_eval.h"
//!
//! ##include "order_xover.h"
//! ##include "city_swap.h"
//!
//! ##include "param.h"
//!
//! ##include &lt;paradiseo&gt;
//!
//!
//! ##define POP_SIZE 10
//! ##define NUM_GEN 100
//! ##define CROSS_RATE 1.0
//! ##define MUT_RATE 0.01
//! </pre>
//! </li>
//! <li> <b>construct the skeleton of a simple ParadisEO-PEO program</b> - 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.<br/>
//!
//! <pre>
//! ...
//!
//! int main( int __argc, char** __argv ) {
//!
//! <i>//</i> initializing the ParadisEO-PEO environment
//! peo :: init( __argc, __argv );
//!
//! <i>//</i> processing the command line specified parameters
//! loadParameters( __argc, __argv );
//!
//!
//! <i>//</i> EVOLUTIONARY ALGORITHM TO BE DEFINED
//!
//!
//! peo :: run( );
//! peo :: finalize( );
//! <i>//</i> shutting down the ParadisEO-PEO environment
//!
//! return 0;
//! }
//! </pre>
//! </li>
//! <li> <b>initialization functors, evaluation function and transform operators</b> - 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.<br/>
//!
//! <pre>
//! RouteInit route_init; <i>//</i> random init object - creates random Route objects
//! RouteEval full_eval; <i>//</i> evaluator object - offers a fitness value for a specified Route object
//!
//! OrderXover crossover; <i>//</i> crossover operator - creates two offsprings out of two specified parents
//! CitySwap mutation; <i>//</i> mutation operator - randomly mutates one gene for a specified individual
//! </pre>
//! </li>
//! <li> <b>construct the components of the evolutionary algorithm</b> - each of the components that has to be passed as parameter to the
//! <b>peoEA</b> 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.
//!
//! <ul>
//! <li> an initial population has to be specified; the constructor accepts the specification of an initializing object. Further,
//! an evaluation object is required - the <b>peoEA</b> constructor requires a <b>peoPopEval</b> derived class.
//! </li>
//! </ul>
//! <pre>
//! eoPop< Route > population( POP_SIZE, route_init ); <i>//</i> 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
//! </pre>
//! <ul>
//! <li> the evolutionary algorithm continues to iterate till a continuation criterion is not met. For our case we consider
//! a fixed number of generations. The continuation criterion has to be specified as a checkpoint object, thus requiring
//! the creation of an <i>eoCheckPoint</i> object in addition.
//! </li>
//! </ul>
//! <pre>
//! eoGenContinue< Route > eaCont( NUM_GEN ); <i>//</i> continuation criterion - the algorithm will iterate for NUM_GEN generations
//! eoCheckPoint< Route > eaCheckpointContinue( eaCont ); <i>//</i> checkpoint object - verify at each iteration if the continuation criterion is met
//! </pre>
//! <ul>
//! <li> selection strategy - we are required to specify a selection strategy for extracting individuals out of the parent
//! population; in addition the number of individuals to be selected has to be specified.
//! </li>
//! </ul>
//! <pre>
//! eoRankingSelect< Route > selectionStrategy; <i>//</i> selection strategy - applied at each iteration for selecting parent individuals
//! eoSelectNumber< Route > eaSelect( selectionStrategy, POP_SIZE ); <i>//</i> selection object - POP_SIZE individuals are selected at each iteration
//! </pre>
//! <ul>
//! <li> transformation operators - we have to integrate the crossover and the mutation functors into an object which may be passed
//! as a parameter when creating the <b>peoEA</b> object. The constructor of <b>peoEA</b> requires a <b>peoTransform</b> derived
//! object. Associated probabilities have to be specified also.
//! </li>
//! </ul>
//! <pre>
//! <i>//</i> 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 ); <i>//</i> ParadisEO transform operator (please remark the peo prefix) - wraps an e EO transform object
//! </pre>
//! <ul>
//! <li> replacement strategy - required for defining the way for integrating the resulting offsprings into the initial population.
//! At your option whether you would like to chose one of the predefined replacement strategies that come with the EO framework
//! or if you want to define your own.
//! </li>
//! </ul>
//! <pre>
//! eoPlusReplacement< Route > eaReplace; <i>//</i> replacement strategy - for replacing the initial population with offspring individuals
//! </pre>
//! </li>
//! <li> <b>evolutionary algorithm</b> - 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.
//!
//! <pre>
//! peoEA< Route > eaAlg( eaCheckpointContinue, eaPopEval, eaSelect, eaTransform, eaReplace );
//!
//! eaAlg( population ); // specifying the initial population for the algorithm, to be iteratively evolved
//! </pre>
//! </li>
//! </ol>
//!
//! If you have not missed any of the enumerated points, your program should be like the following:
//!
//! <pre>
//! ##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
//!
//!
//! int main( int __argc, char** __argv ) {
//!
//! <i>//</i> initializing the ParadisEO-PEO environment
//! peo :: init( __argc, __argv );
//!
//!
//! <i>//</i> processing the command line specified parameters
//! loadParameters( __argc, __argv );
//!
//!
//! <i>//</i> init, eval operators, EA operators -------------------------------------------------------------------------------------------------------------
//!
//! RouteInit route_init; <i>//</i> random init object - creates random Route objects
//! RouteEval full_eval; <i>//</i> evaluator object - offers a fitness value for a specified Route object
//!
//! OrderXover crossover; <i>//</i> crossover operator - creates two offsprings out of two specified parents
//! CitySwap mutation; <i>//</i> mutation operator - randomly mutates one gene for a specified individual
//! <i>//</i> ------------------------------------------------------------------------------------------------------------------------------------------------
//!
//!
//! <i>//</i> evolutionary algorithm components --------------------------------------------------------------------------------------------------------------
//!
//! eoPop< Route > population( POP_SIZE, route_init ); <i>//</i> initial population for the algorithm having POP_SIZE individuals
//! peoSeqPopEval< Route > eaPopEval( full_eval ); <i>//</i> evaluator object - to be applied at each iteration on the entire population
//!
//! eoGenContinue< Route > eaCont( NUM_GEN ); <i>//</i> continuation criterion - the algorithm will iterate for NUM_GEN generations
//! eoCheckPoint< Route > eaCheckpointContinue( eaCont ); <i>//</i> checkpoint object - verify at each iteration if the continuation criterion is met
//!
//! eoRankingSelect< Route > selectionStrategy; <i>//</i> selection strategy - applied at each iteration for selecting parent individuals
//! eoSelectNumber< Route > eaSelect( selectionStrategy, POP_SIZE ); <i>//</i> selection object - POP_SIZE individuals are selected at each iteration
//!
//! <i>//</i> 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 ); <i>//</i> ParadisEO transform operator (please remark the peo prefix) - wraps an e EO transform object
//!
//! eoPlusReplacement< Route > eaReplace; <i>//</i> replacement strategy - for replacing the initial population with offspring individuals
//! <i>//</i> ------------------------------------------------------------------------------------------------------------------------------------------------
//!
//!
//! <i>//</i> ParadisEO-PEO evolutionary algorithm -----------------------------------------------------------------------------------------------------------
//!
//! peoEA< Route > eaAlg( eaCheckpointContinue, eaPopEval, eaSelect, eaTransform, eaReplace );
//!
//! eaAlg( population ); <i>//</i> specifying the initial population for the algorithm, to be iteratively evolved
//! <i>//</i> ------------------------------------------------------------------------------------------------------------------------------------------------
//!
//!
//! peo :: run( );
//! peo :: finalize( );
//! <i>//</i> shutting down the ParadisEO-PEO environment
//!
//! return 0;
//! }
//! </pre>
//!
//!
//! \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 <b>main.cpp</b> - 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 <b>paradiseo-peo/examples/lesson1</b> directory - you should open a console and you should change your current directory to the one of Lesson1.
//!
//! <b>Compilation</b>: being in the <b>paradiseo-peo/examples/lesson1</b> directory, you have to type <i>make</i>. As a result the <b>main.cpp</b> file
//! will be compiled and you should obtain an executable file called <b>tspExample</b>. If you have errors, please verify any of the followings:
//!
//! <ul>
//! <li>you are under the right directory - you can verify by typing the <i>pwd</i> command - you should have something like <b>.../paradiseo-peo/examples/lesson1</b></li>
//! <li>you saved your modifications in a file called <b>main.cpp</b>, in the <b>paradiseo-peo/examples/lesson1</b> directory</li>
//! <li>there are no differences between the example presented above and your file</li>
//! </ul>
//!
//! <b>NOTE</b>: in order to successfully compile your program you should already have installed an MPI distribution in your system.
//!
//! <b>Execution</b>: the execution of a ParadisEO-PEO program requires having already created an environment for launching MPI programs. For <i>MPICH-2</i>,
//! 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 <b>schema.xml</b>, which, for our case, has
//! the following structure:
//!
//! <pre>
//! <?xml version="1.0"?>
//!
//! <schema>
//! <group scheduler="0">
//! <node name="0" num_workers="0">
//! </node>
//!
//! <node name="1" num_workers="0">
//! <runner>1</runner>
//! </node>
//!
//! <node name="2" num_workers="1">
//! </node>
//! <node name="3" num_workers="1">
//! </node>
//! </group>
//! </schema>
//! </pre>
//!
//! 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 <b>paradiseo-peo/examples/lesson1</b>
//! directory you have to type the following command:
//!
//! <b>mpiexec -n 4 ./tspExample @lesson.param</b>
//!
//! <b>NOTE</b>: 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:
//! <pre>
//! 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]
//! </pre>
//!
//!
//! \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 <b>main.cpp</b> file, replace the line
//! <pre>
//! peo<b>Seq</b>PopEval< Route > eaPopEval( full_eval );
//! </pre>
//! with
//! <pre>
//! peo<b>Para</b>PopEval< Route > eaPopEval( full_eval );
//! </pre>
//! 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 <b>schema.xml</b> 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.

View file

@ -0,0 +1,79 @@
// "main.cpp"
// (c) OPAC Team, LIFL, January 2006
/*
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 <paradiseo>
#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;
}

View file

@ -0,0 +1,241 @@
# Doxyfile 1.4.7
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "ParadisEO-PEO Lesson1"
PROJECT_NUMBER = 0.1
OUTPUT_DIRECTORY = ../../docs/html/lesson1
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

View file

@ -0,0 +1,16 @@
######################################################################################
### 0) Need lesson1 directory
######################################################################################
SET(TUTORIAL_LESSON2_DIR ${CMAKE_CURRENT_SOURCE_DIR})
######################################################################################
######################################################################################
### 1) Where must cmake go now ?
######################################################################################
SUBDIRS(src)
######################################################################################

View file

@ -0,0 +1,12 @@
## miscallenous parameters
--debug=false
## deployment schema
--schema=../schema.xml
## parameters
--inst=../../examples/tsp/benchs/eil101.tsp

View file

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<schema>
<group scheduler="0">
<node name="0" num_workers="0">
</node>
<node name="1" num_workers="0">
<runner>1</runner>
</node>
<node name="2" num_workers="1">
</node>
<node name="3" num_workers="1">
</node>
</group>
</schema>

View file

@ -0,0 +1,75 @@
######################################################################################
### 0) Set the compiler
######################################################################################
SET (CMAKE_CXX_COMPILER mpicxx)
######################################################################################
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${EO_SRC_DIR})
INCLUDE_DIRECTORIES(${MO_SRC_DIR})
INCLUDE_DIRECTORIES(${PEO_SRC_DIR})
INCLUDE_DIRECTORIES(${TSP_EXAMPLE_DIR}/src)
######################################################################################
######################################################################################
### 2) Specify where CMake can find the libraries (mandatory: before 3) )
######################################################################################
LINK_DIRECTORIES( ${EO_SRC_DIR}
${EO_SRC_DIR}/utils
${PEO_DIR}/build
${TSP_EXAMPLE_DIR}/build)
######################################################################################
######################################################################################
### 3) Define your target(s): just an executable here
######################################################################################
# no matter what is the OS, hopefully
ADD_EXECUTABLE(tspExample main.cpp)
ADD_DEPENDENCIES(tspExample tsp)
ADD_DEPENDENCIES(tspExample peo)
ADD_DEPENDENCIES(tspExample rmc_mpi)
SET(EXECUTABLE_OUTPUT_PATH ${TUTORIAL_LESSON2_DIR}/build)
######################################################################################
######################################################################################
### 4) Optionnal: define your target(s)'s version: no effect for windows
######################################################################################
SET(LESSON2_VERSION "1.0.beta")
SET_TARGET_PROPERTIES(tspExample PROPERTIES VERSION "${LESSON2_VERSION}")
######################################################################################
######################################################################################
### 5) Link the librairies
######################################################################################
TARGET_LINK_LIBRARIES(tspExample ${XML2_LIBS}) # define in CMakeLists.txt at PEO root dir
TARGET_LINK_LIBRARIES(tspExample tsp)
TARGET_LINK_LIBRARIES(tspExample peo)
TARGET_LINK_LIBRARIES(tspExample rmc_mpi)
TARGET_LINK_LIBRARIES(tspExample eo)
TARGET_LINK_LIBRARIES(tspExample eoutils)
######################################################################################

View file

@ -0,0 +1,162 @@
// "main_ga.cpp"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include "param.h"
#include "route_init.h"
#include "route_eval.h"
#include "order_xover.h"
#include "edge_xover.h"
#include "partial_mapped_xover.h"
#include "city_swap.h"
#include "part_route_eval.h"
#include "merge_route_eval.h"
#include "two_opt_init.h"
#include "two_opt_next.h"
#include "two_opt_incr_eval.h"
#include <paradiseo>
#define POP_SIZE 10
#define NUM_GEN 100
#define CROSS_RATE 1.0
#define MUT_RATE 0.01
#define NUM_PART_EVALS 2
#define MIG_FREQ 10
#define MIG_SIZE 10
#define HYBRID_SIZE 3
int main (int __argc, char * * __argv) {
peo :: init (__argc, __argv);
loadParameters (__argc, __argv); /* Processing some parameters relative to the tackled
problem (TSP) */
RouteInit route_init; /* Its builds random routes */
RouteEval full_eval; /* Full route evaluator */
MergeRouteEval merge_eval;
std :: vector <eoEvalFunc <Route> *> part_eval;
for (unsigned i = 1 ; i <= NUM_PART_EVALS ; i ++)
part_eval.push_back (new PartRouteEval ((float) (i - 1) / NUM_PART_EVALS, (float) i / NUM_PART_EVALS));
OrderXover order_cross; /* Recombination */
PartialMappedXover pm_cross;
EdgeXover edge_cross;
CitySwap city_swap_mut; /* Mutation */
RingTopology topo;
/** The first EA **/
eoPop <Route> ox_pop (POP_SIZE, route_init); /* Population */
eoGenContinue <Route> ox_cont (NUM_GEN); /* A fixed number of iterations */
eoCheckPoint <Route> ox_checkpoint (ox_cont); /* Checkpoint */
peoParaPopEval <Route> ox_pop_eval (part_eval, merge_eval);
eoStochTournamentSelect <Route> ox_select_one;
eoSelectNumber <Route> ox_select (ox_select_one, POP_SIZE);
eoSGATransform <Route> ox_transform (order_cross, CROSS_RATE, city_swap_mut, MUT_RATE);
peoSeqTransform <Route> ox_para_transform (ox_transform);
eoEPReplacement <Route> ox_replace (2);
/* The migration policy */
eoPeriodicContinue <Route> ox_mig_cont (MIG_FREQ); /* Migration occurs periodically */
eoRandomSelect <Route> ox_mig_select_one; /* Emigrants are randomly selected */
eoSelectNumber <Route> ox_mig_select (ox_mig_select_one, MIG_SIZE);
eoPlusReplacement <Route> ox_mig_replace; /* Immigrants replace the worse individuals */
peoAsyncIslandMig <Route> ox_mig (ox_mig_cont, ox_mig_select, ox_mig_replace, topo, ox_pop, ox_pop);
//peoSyncIslandMig <Route> ox_mig (MIG_FREQ, ox_mig_select, ox_mig_replace, topo, ox_pop, ox_pop);
ox_checkpoint.add (ox_mig);
peoEA <Route> ox_ea (ox_checkpoint, ox_pop_eval, ox_select, ox_para_transform, ox_replace);
ox_mig.setOwner (ox_ea);
ox_ea (ox_pop); /* Application to the given population */
/** The second EA **/
eoPop <Route> pmx_pop (POP_SIZE, route_init); /* Population */
eoGenContinue <Route> pmx_cont (NUM_GEN); /* A fixed number of iterations */
eoCheckPoint <Route> pmx_checkpoint (pmx_cont); /* Checkpoint */
peoSeqPopEval <Route> pmx_pop_eval (full_eval);
eoRankingSelect <Route> pmx_select_one;
eoSelectNumber <Route> pmx_select (pmx_select_one, POP_SIZE);
eoSGATransform <Route> pmx_transform (pm_cross, CROSS_RATE, city_swap_mut, MUT_RATE);
peoSeqTransform <Route> pmx_para_transform (pmx_transform);
eoPlusReplacement <Route> pmx_replace;
/* The migration policy */
eoPeriodicContinue <Route> pmx_mig_cont (MIG_FREQ); /* Migration occurs periodically */
eoRandomSelect <Route> pmx_mig_select_one; /* Emigrants are randomly selected */
eoSelectNumber <Route> pmx_mig_select (pmx_mig_select_one, MIG_SIZE);
eoPlusReplacement <Route> pmx_mig_replace; /* Immigrants replace the worse individuals */
peoAsyncIslandMig <Route> pmx_mig (pmx_mig_cont, pmx_mig_select, pmx_mig_replace, topo, pmx_pop, pmx_pop);
//peoSyncIslandMig <Route> pmx_mig (MIG_FREQ, pmx_mig_select, pmx_mig_replace, topo, pmx_pop, pmx_pop);
pmx_checkpoint.add (pmx_mig);
/* Hybridization with a Local Search */
TwoOptInit pmx_two_opt_init;
TwoOptNext pmx_two_opt_next;
TwoOptIncrEval pmx_two_opt_incr_eval;
moBestImprSelect <TwoOpt> pmx_two_opt_move_select;
moHC <TwoOpt> hc (pmx_two_opt_init, pmx_two_opt_next, pmx_two_opt_incr_eval, pmx_two_opt_move_select, full_eval);
eoPeriodicContinue <Route> pmx_ls_cont (MIG_FREQ); /* Hybridization occurs periodically */
eoRandomSelect <Route> pmx_ls_select_one; /* ? */
eoSelectNumber <Route> pmx_ls_select (pmx_ls_select_one, HYBRID_SIZE);
eoPlusReplacement <Route> pmx_ls_replace;
peoSyncMultiStart <Route> pmx_ls (pmx_ls_cont, pmx_ls_select, pmx_ls_replace, hc, pmx_pop);
pmx_checkpoint.add (pmx_ls);
peoEA <Route> pmx_ea (pmx_checkpoint, pmx_pop_eval, pmx_select, pmx_para_transform, pmx_replace);
pmx_mig.setOwner (pmx_ea);
pmx_ls.setOwner (pmx_ea);
pmx_ea (pmx_pop); /* Application to the given population */
/** The third EA **/
eoPop <Route> edge_pop (POP_SIZE, route_init); /* Population */
eoGenContinue <Route> edge_cont (NUM_GEN); /* A fixed number of iterations */
eoCheckPoint <Route> edge_checkpoint (edge_cont); /* Checkpoint */
peoSeqPopEval <Route> edge_pop_eval (full_eval);
eoRankingSelect <Route> edge_select_one;
eoSelectNumber <Route> edge_select (edge_select_one, POP_SIZE);
peoParaSGATransform <Route> edge_para_transform (edge_cross, CROSS_RATE, city_swap_mut, MUT_RATE);
eoPlusReplacement <Route> edge_replace;
/* The migration policy */
eoPeriodicContinue <Route> edge_mig_cont (MIG_FREQ); /* Migration occurs periodically */
eoRandomSelect <Route> edge_mig_select_one; /* Emigrants are randomly selected */
eoSelectNumber <Route> edge_mig_select (edge_mig_select_one, MIG_SIZE);
eoPlusReplacement <Route> edge_mig_replace; /* Immigrants replace the worse individuals */
peoAsyncIslandMig <Route> edge_mig (edge_mig_cont, edge_mig_select, edge_mig_replace, topo, edge_pop, edge_pop);
//peoSyncIslandMig <Route> edge_mig (MIG_FREQ, edge_mig_select, edge_mig_replace, topo, edge_pop, edge_pop);
edge_checkpoint.add (edge_mig);
peoEA <Route> edge_ea (edge_checkpoint, edge_pop_eval, edge_select, edge_para_transform, edge_replace);
edge_mig.setOwner (edge_ea);
edge_ea (edge_pop); /* Application to the given population */
peo :: run ();
peo :: finalize (); /* Termination */
return 0;
}

View file

@ -0,0 +1,241 @@
# Doxyfile 1.4.7
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "ParadisEO-PEO Lesson2"
PROJECT_NUMBER = 0.1
OUTPUT_DIRECTORY = ../../docs/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

View file

@ -0,0 +1,9 @@
######################################################################################
### 1) Where must cmake go now ?
######################################################################################
SUBDIRS(tsp)
######################################################################################

View file

@ -0,0 +1,9 @@
######################################################################################
### 1) Where must cmake go now ?
######################################################################################
SUBDIRS(src)
######################################################################################

View file

@ -0,0 +1,108 @@
NAME : eil101.opt.tour
COMMENT : Optimum tour for eil101.tsp (Length 629)
TYPE : TOUR
DIMENSION : 101
TOUR_SECTION
1
69
27
101
53
28
26
12
80
68
29
24
54
55
25
4
39
67
23
56
75
41
22
74
72
73
21
40
58
13
94
95
97
87
2
57
15
43
42
14
44
38
86
16
61
85
91
100
98
37
92
59
93
99
96
6
89
52
18
83
60
5
84
17
45
8
46
47
36
49
64
63
90
32
10
62
11
19
48
82
7
88
31
70
30
20
66
71
65
35
34
78
81
9
51
33
79
3
77
76
50
-1
EOF

View file

@ -0,0 +1,108 @@
NAME : eil101
COMMENT : 101-city problem (Christofides/Eilon)
TYPE : TSP
DIMENSION : 101
EDGE_WEIGHT_TYPE : EUC_2D
NODE_COORD_SECTION
1 41 49
2 35 17
3 55 45
4 55 20
5 15 30
6 25 30
7 20 50
8 10 43
9 55 60
10 30 60
11 20 65
12 50 35
13 30 25
14 15 10
15 30 5
16 10 20
17 5 30
18 20 40
19 15 60
20 45 65
21 45 20
22 45 10
23 55 5
24 65 35
25 65 20
26 45 30
27 35 40
28 41 37
29 64 42
30 40 60
31 31 52
32 35 69
33 53 52
34 65 55
35 63 65
36 2 60
37 20 20
38 5 5
39 60 12
40 40 25
41 42 7
42 24 12
43 23 3
44 11 14
45 6 38
46 2 48
47 8 56
48 13 52
49 6 68
50 47 47
51 49 58
52 27 43
53 37 31
54 57 29
55 63 23
56 53 12
57 32 12
58 36 26
59 21 24
60 17 34
61 12 24
62 24 58
63 27 69
64 15 77
65 62 77
66 49 73
67 67 5
68 56 39
69 37 47
70 37 56
71 57 68
72 47 16
73 44 17
74 46 13
75 49 11
76 49 42
77 53 43
78 61 52
79 57 48
80 56 37
81 55 54
82 15 47
83 14 37
84 11 31
85 16 22
86 4 18
87 28 18
88 26 52
89 26 35
90 31 67
91 15 19
92 22 22
93 18 24
94 26 27
95 25 24
96 22 27
97 25 21
98 19 21
99 20 26
100 18 18
101 35 35
EOF

View file

@ -0,0 +1,66 @@
######################################################################################
### 1) Include the sources
######################################################################################
INCLUDE_DIRECTORIES(${EO_SRC_DIR})
INCLUDE_DIRECTORIES(${MO_SRC_DIR})
INCLUDE_DIRECTORIES(${PEO_SRC_DIR})
######################################################################################
######################################################################################
### 2) Define your target(s): just the tsp lib here
######################################################################################
SET(TSP_LIB_OUTPUT_PATH ${TSP_EXAMPLE_DIR}/build)
SET(LIBRARY_OUTPUT_PATH ${TSP_LIB_OUTPUT_PATH})
SET (TSP_SOURCES data.h
data.cpp
opt_route.h
opt_route.cpp
param.h
param.cpp
node.h
node.cpp
route.h
route.cpp
route_init.h
route_init.cpp
route_eval.h
route_eval.cpp
two_opt.h
two_opt.cpp
two_opt_init.h
two_opt_init.cpp
two_opt_incr_eval.h
two_opt_incr_eval.cpp
two_opt_next.h
two_opt_next.cpp
order_xover.h
order_xover.cpp
partial_mapped_xover.h
partial_mapped_xover.cpp
edge_xover.h
edge_xover.cpp
city_swap.h
city_swap.cpp
part_route_eval.h
part_route_eval.cpp
merge_route_eval.h
merge_route_eval.cpp)
ADD_LIBRARY(tsp STATIC ${TSP_SOURCES})
######################################################################################
######################################################################################
### 3) Optionnal: define your lib's version
######################################################################################
SET(TSP_VERSION "1.0.beta")
SET_TARGET_PROPERTIES(tsp PROPERTIES VERSION "${TSP_VERSION}")
######################################################################################

View file

@ -0,0 +1,21 @@
// "city_swap.cpp"
// (c) OPAC Team, LIFL, 2002
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <utils/eoRNG.h>
#include "city_swap.h"
bool CitySwap :: operator () (Route & __route) {
std :: swap (__route [rng.random (__route.size ())],
__route [rng.random (__route.size ())]) ;
__route.invalidate () ;
return true ;
}

View file

@ -0,0 +1,26 @@
// "city_swap.h"
// (c) OPAC Team, LIFL, 2002
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef city_swap_h
#define city_swap_h
#include <eoOp.h>
#include "route.h"
/** Its swaps two vertices
randomly choosen */
class CitySwap : public eoMonOp <Route> {
public :
bool operator () (Route & __route) ;
} ;
#endif

View file

@ -0,0 +1,98 @@
// "data.cpp"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <utils/eoParser.h>
#include "data.h"
#include "node.h"
#define MAX_TRASH_LENGTH 1000
#define MAX_FIELD_LENGTH 1000
#define MAX_LINE_LENGTH 1000
static void getNextField (FILE * __f, char * __buff) {
char trash [MAX_TRASH_LENGTH];
fscanf (__f, "%[ \t:\n]", trash); /* Discarding sep. */
fscanf (__f, "%[^:\n]", __buff); /* Reading the field */
fgetc (__f);
}
static void getLine (FILE * __f, char * __buff) {
char trash [MAX_TRASH_LENGTH];
fscanf (__f, "%[ \t:\n]", trash); /* Discarding sep. */
fscanf (__f, "%[^\n]", __buff); /* Reading the line */
}
void loadData (const char * __filename) {
FILE * f = fopen (__filename, "r");
if (f) {
printf ("Loading '%s'.\n", __filename);
char field [MAX_FIELD_LENGTH];
getNextField (f, field); /* Name */
assert (strstr (field, "NAME"));
getNextField (f, field);
printf ("NAME: %s.\n", field);
getNextField (f, field); /* Comment */
assert (strstr (field, "COMMENT"));
getLine (f, field);
printf ("COMMENT: %s.\n", field);
getNextField (f, field); /* Type */
assert (strstr (field, "TYPE"));
getNextField (f, field);
printf ("TYPE: %s.\n", field);
getNextField (f, field); /* Dimension */
assert (strstr (field, "DIMENSION"));
getNextField (f, field);
printf ("DIMENSION: %s.\n", field);
numNodes = atoi (field);
getNextField (f, field); /* Edge weight type */
assert (strstr (field, "EDGE_WEIGHT_TYPE"));
getNextField (f, field);
printf ("EDGE_WEIGHT_TYPE: %s.\n", field);
getNextField (f, field); /* Node coord section */
assert (strstr (field, "NODE_COORD_SECTION"));
loadNodes (f);
getNextField (f, field); /* End of file */
assert (strstr (field, "EOF"));
printf ("EOF.\n");
}
else {
fprintf (stderr, "Can't open '%s'.\n", __filename);
exit (1);
}
}
void loadData (eoParser & __parser) {
/* Getting the path of the instance */
eoValueParam <std :: string> param ("", "inst", "Path of the instance") ;
__parser.processParam (param) ;
loadData (param.value ().c_str ());
}

View file

@ -0,0 +1,18 @@
// "data.h"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __data_h
#define __data_h
#include <utils/eoParser.h>
extern void loadData (const char * __filename);
extern void loadData (eoParser & __parser);
#endif

View file

@ -0,0 +1,117 @@
// "display.cpp"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <iostream>
#include <fstream>
#include <X11/Xlib.h>
#include "display.h"
#include "node.h"
#include "opt_route.h"
#define BORDER 20
#define RATIO 0.5
#define screen_width 1024
#define screen_height 768
static const char * filename;
/* Computed coordinates */
static unsigned * X_new_coord, * Y_new_coord ;
/* this variable will contain the handle to the returned graphics context. */
static GC gc;
/* this variable will contain the pointer to the Display structure */
static Display* disp;
/* this variable will store the ID of the newly created window. */
static Window win;
static int screen;
/* Create a new backing pixmap of the appropriate size */
/* Best tour */
/*
gdk_gc_set_line_attributes (gc, 2, GDK_LINE_ON_OFF_DASH, GDK_CAP_NOT_LAST, GDK_JOIN_MITER) ;
gdk_gc_set_foreground (gc, & color_green) ;
for (int i = 0 ; i < (int) numNodes ; i ++) {
gdk_draw_line (pixmap, gc,
X_new_coord [opt_route [i]],
Y_new_coord [opt_route [i]],
X_new_coord [opt_route [(i + 1) % numNodes]],
Y_new_coord [opt_route [(i + 1) % numNodes]]);
}*/
void openMainWindow (const char * __filename) {
filename = __filename;
/* Map */
int map_width = (int) (X_max - X_min);
int map_height = (int) (Y_max - Y_min);
int map_side = std :: max (map_width, map_height);
/* Calculate the window's width and height. */
int win_width = (int) (screen_width * RATIO * map_width / map_side);
int win_height = (int) (screen_height * RATIO * map_height / map_side);
/* Computing the coordinates */
X_new_coord = new unsigned [numNodes];
Y_new_coord = new unsigned [numNodes];
for (unsigned i = 0; i < numNodes; i ++) {
X_new_coord [i] = (unsigned) (win_width * (1.0 - (X_coord [i] - X_min) / map_width) + BORDER);
Y_new_coord [i] = (unsigned) (win_height * (1.0 - (Y_coord [i] - Y_min) / map_height) + BORDER);
}
/* Initialisation */
XGCValues val ;
disp = XOpenDisplay (NULL) ;
screen = DefaultScreen (disp) ;
win = XCreateSimpleWindow (disp, RootWindow (disp, screen), 0, 0, win_width + 2 * BORDER, win_height + 2 * BORDER, 2, BlackPixel (disp, screen), WhitePixel (disp, screen)) ;
val.foreground = BlackPixel(disp, screen) ;
val.background = WhitePixel(disp, screen) ;
gc = XCreateGC (disp, win, GCForeground | GCBackground, & val) ;
XMapWindow (disp, win) ;
XFlush (disp) ;
while (true) {
XClearWindow (disp, win) ;
/* Vertices as circles */
for (unsigned i = 1 ; i < numNodes ; i ++)
XDrawArc (disp, win, gc, X_new_coord [i] - 1, Y_new_coord [i] - 1, 3, 3, 0, 364 * 64) ;
/* New tour */
std :: ifstream f (filename);
if (f) {
Route route;
f >> route;
f.close ();
for (int i = 0; i < (int) numNodes; i ++)
XDrawLine (disp, win, gc,
X_new_coord [route [i]],
Y_new_coord [route [i]],
X_new_coord [route [(i + 1) % numNodes]],
Y_new_coord [route [(i + 1) % numNodes]]);
}
XFlush (disp) ;
sleep (1) ;
}
}

View file

@ -0,0 +1,16 @@
// "display.h"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __display_h
#define __display_h
#include "route.h"
extern void openMainWindow (const char * __filename);
#endif

View file

@ -0,0 +1,22 @@
// "display_best_route.cpp"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include "display_best_route.h"
#include "display.h"
DisplayBestRoute :: DisplayBestRoute (eoPop <Route> & __pop
) : pop (__pop) {
}
void DisplayBestRoute :: operator () () {
displayRoute (pop.best_element ());
}

View file

@ -0,0 +1,32 @@
// "display_best_route.h"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __display_best_route_h
#define __display_best_route_h
#include <utils/eoUpdater.h>
#include <eoPop.h>
#include "route.h"
class DisplayBestRoute : public eoUpdater {
public :
DisplayBestRoute (eoPop <Route> & __pop);
void operator () ();
private :
eoPop <Route> & pop;
};
#endif

View file

@ -0,0 +1,118 @@
// "edge_xover.cpp"
// (c) OPAC Team, LIFL, 2003
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <assert.h>
#include <values.h>
#include <utils/eoRNG.h>
#include "edge_xover.h"
void EdgeXover :: build_map (const Route & __par1, const Route & __par2) {
unsigned len = __par1.size () ;
/* Initialization */
_map.clear () ;
_map.resize (len) ;
for (unsigned i = 0 ; i < len ; i ++) {
_map [__par1 [i]].insert (__par1 [(i + 1) % len]) ;
_map [__par2 [i]].insert (__par2 [(i + 1) % len]) ;
_map [__par1 [i]].insert (__par1 [(i - 1 + len) % len]) ;
_map [__par2 [i]].insert (__par2 [(i - 1 + len) % len]) ;
}
visited.clear () ;
visited.resize (len, false) ;
}
void EdgeXover :: remove_entry (unsigned __vertex, std :: vector <std :: set <unsigned> > & __map) {
std :: set <unsigned> & neigh = __map [__vertex] ;
for (std :: set <unsigned> :: iterator it = neigh.begin () ;
it != neigh.end () ;
it ++)
__map [* it].erase (__vertex) ;
}
void EdgeXover :: add_vertex (unsigned __vertex, Route & __child) {
visited [__vertex] = true ;
__child.push_back (__vertex) ;
remove_entry (__vertex, _map) ; /* Removing entries */
}
void EdgeXover :: cross (const Route & __par1, const Route & __par2, Route & __child) {
build_map (__par1, __par2) ;
unsigned len = __par1.size () ;
/* Go ! */
__child.clear () ;
unsigned cur_vertex = rng.random (len) ;
add_vertex (cur_vertex, __child) ;
for (unsigned i = 1 ; i < len ; i ++) {
unsigned len_min_entry = MAXINT ;
std :: set <unsigned> & neigh = _map [cur_vertex] ;
for (std :: set <unsigned> :: iterator it = neigh.begin () ;
it != neigh.end () ;
it ++) {
unsigned l = _map [* it].size () ;
if (len_min_entry > l)
len_min_entry = l ;
}
std :: vector <unsigned> cand ; /* Candidates */
for (std :: set <unsigned> :: iterator it = neigh.begin () ;
it != neigh.end () ;
it ++) {
unsigned l = _map [* it].size () ;
if (len_min_entry == l)
cand.push_back (* it) ;
}
if (! cand.size ()) {
/* Oh no ! Implicit mutation */
for (unsigned j = 0 ; j < len ; j ++)
if (! visited [j])
cand.push_back (j) ;
}
cur_vertex = cand [rng.random (cand.size ())] ;
add_vertex (cur_vertex, __child) ;
}
}
bool EdgeXover :: operator () (Route & __route1, Route & __route2) {
// Init. copy
Route par [2] ;
par [0] = __route1 ;
par [1] = __route2 ;
cross (par [0], par [1], __route1) ;
cross (par [1], par [0], __route2) ;
__route1.invalidate () ;
__route2.invalidate () ;
return true ;
}

View file

@ -0,0 +1,43 @@
// "edge_xover.h"
// (c) OPAC Team, LIFL, 2003
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef edge_xover_h
#define edge_xover_h
#include <vector>
#include <set>
#include <eoOp.h>
#include "route.h"
/** Edge Crossover */
class EdgeXover : public eoQuadOp <Route> {
public :
bool operator () (Route & __route1, Route & __route2) ;
private :
void cross (const Route & __par1, const Route & __par2, Route & __child) ; /* Binary */
void remove_entry (unsigned __vertex, std :: vector <std :: set <unsigned> > & __map) ;
/* Updating the map of entries */
void build_map (const Route & __par1, const Route & __par2) ;
void add_vertex (unsigned __vertex, Route & __child) ;
std :: vector <std :: set <unsigned> > _map ; /* The handled map */
std :: vector <bool> visited ; /* Vertices that are already visited */
} ;
#endif

View file

@ -0,0 +1,17 @@
// "merge_route_eval.cpp"
// (c) OPAC Team, LIFL, 2005
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include "merge_route_eval.h"
void MergeRouteEval :: operator () (Route & __route, const int & __part_fit) {
int len = __route.fitness ();
len += __part_fit;
__route.fitness (len);
}

View file

@ -0,0 +1,24 @@
// "merge_route_eval.h"
// (c) OPAC Team, LIFL, 2005
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __merge_route_eval_h
#define __merge_route_eval_h
#include <peoAggEvalFunc.h>
#include "route.h"
class MergeRouteEval : public peoAggEvalFunc <Route> {
public :
void operator () (Route & __route, const int & __part_fit) ;
};
#endif

View file

@ -0,0 +1,25 @@
/*
file: 'mix.h'
author: S. CAHON
mail: paradiseo-help@lists.gforge.inria.fr
date: dec. 2005
*/
#ifndef __mix_h
#define __mix_h
#include <vector>
#include <utils/eoRNG.h>
template <class T> void mix (std :: vector <T> & __v) {
unsigned len = __v.size () ;
for (unsigned i = 0 ; i < len ; i ++)
std :: swap (__v [i], __v [rng.random (len)]) ;
}
#endif

View file

@ -0,0 +1,77 @@
// "node.cpp"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <math.h>
#include <values.h>
#include "node.h"
unsigned numNodes; /* Number of nodes */
//static unsigned * * dist; /* Square matrix of distances */
double * X_coord, * Y_coord;
double X_min = MAXDOUBLE, X_max = MINDOUBLE, Y_min = MAXDOUBLE, Y_max = MINDOUBLE;
void loadNodes (FILE * __f) {
/* Coord */
X_coord = new double [numNodes];
Y_coord = new double [numNodes];
unsigned num;
for (unsigned i = 0; i < numNodes; i ++) {
fscanf (__f, "%u%lf%lf", & num, X_coord + i, Y_coord + i);
if (X_coord [i] < X_min)
X_min = X_coord [i];
if (X_coord [i] > X_max)
X_max = X_coord [i];
if (Y_coord [i] < Y_min)
Y_min = Y_coord [i];
if (Y_coord [i] > Y_max)
Y_max = Y_coord [i];
}
/* Allocation */
/*
dist = new unsigned * [numNodes];
for (unsigned i = 0; i < numNodes; i ++)
dist [i] = new unsigned [numNodes];
*/
/* Computation of the distances */
/*
for (unsigned i = 0; i < numNodes; i ++) {
dist [i] [i] = 0;
for (unsigned j = 0; j < numNodes; j ++) {
double dx = X_coord [i] - X_coord [j], dy = Y_coord [i] - Y_coord [j];
dist [i] [j] = dist [j] [i] = (unsigned) (sqrt (dx * dx + dy * dy) + 0.5) ;
}
}*/
}
unsigned distance (Node __from, Node __to) {
// return dist [__from] [__to];
double dx = X_coord [__from] - X_coord [__to], dy = Y_coord [__from] - Y_coord [__to];
return (unsigned) (sqrt (dx * dx + dy * dy) + 0.5) ;
}

View file

@ -0,0 +1,26 @@
// "node.h"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __node_h
#define __node_h
#include <stdio.h>
typedef unsigned Node;
extern double X_min, X_max, Y_min, Y_max;
extern double * X_coord, * Y_coord;
extern unsigned numNodes; /* Number of nodes */
extern void loadNodes (FILE * __f);
extern unsigned distance (Node __from, Node __to);
#endif

View file

@ -0,0 +1,107 @@
// "opt_route.cpp"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include "opt_route.h"
#define MAX_TRASH_LENGTH 1000
#define MAX_FIELD_LENGTH 1000
#define MAX_LINE_LENGTH 1000
static void getNextField (FILE * __f, char * __buff) {
char trash [MAX_TRASH_LENGTH];
fscanf (__f, "%[ \t:\n]", trash); /* Discarding sep. */
fscanf (__f, "%[^:\n]", __buff); /* Reading the field */
fgetc (__f);
}
static void getLine (FILE * __f, char * __buff) {
char trash [MAX_TRASH_LENGTH];
fscanf (__f, "%[ \t:\n]", trash); /* Discarding sep. */
fscanf (__f, "%[^\n]", __buff); /* Reading the line */
}
static void loadBestRoute (FILE * __f) {
opt_route.clear ();
for (unsigned i = 0; i < numNodes; i ++) {
Node node;
fscanf (__f, "%u", & node);
opt_route.push_back (node - 1);
}
int d; /* -1 ! */
fscanf (__f, "%d", & d);
}
void loadOptimumRoute (const char * __filename) {
FILE * f = fopen (__filename, "r");
if (f) {
printf ("Loading '%s'.\n", __filename);
char field [MAX_FIELD_LENGTH];
getNextField (f, field); /* Name */
assert (strstr (field, "NAME"));
getNextField (f, field);
//printf ("NAME: %s.\n", field);
getNextField (f, field); /* Comment */
assert (strstr (field, "COMMENT"));
getLine (f, field);
// printf ("COMMENT: %s.\n", field);
getNextField (f, field); /* Type */
assert (strstr (field, "TYPE"));
getNextField (f, field);
//printf ("TYPE: %s.\n", field);
getNextField (f, field); /* Dimension */
assert (strstr (field, "DIMENSION"));
getNextField (f, field);
// printf ("DIMENSION: %s.\n", field);
numNodes = atoi (field);
getNextField (f, field); /* Tour section */
assert (strstr (field, "TOUR_SECTION"));
loadBestRoute (f);
getNextField (f, field); /* End of file */
assert (strstr (field, "EOF"));
//printf ("EOF.\n");
printf ("The length of the best route is %u.\n", length (opt_route));
}
else {
fprintf (stderr, "Can't open '%s'.\n", __filename);
exit (1);
}
}
void loadOptimumRoute (eoParser & __parser) {
/* Getting the path of the instance */
eoValueParam <std :: string> param ("", "optimumTour", "Optimum tour") ;
__parser.processParam (param) ;
if (strlen (param.value ().c_str ()))
loadOptimumRoute (param.value ().c_str ());
else
opt_route.fitness (0);
}
Route opt_route; /* Optimum route */

View file

@ -0,0 +1,23 @@
// "opt_route.h"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __opt_route_h
#define __opt_route_h
#include <cassert>
#include <utils/eoParser.h>
#include "route.h"
extern void loadOptimumRoute (const char * __filename);
extern void loadOptimumRoute (eoParser & __parser);
extern Route opt_route; /* Optimum route */
#endif

View file

@ -0,0 +1,64 @@
// "order_xover.cpp"
// (c) OPAC Team, LIFL, 2002
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <assert.h>
#include <utils/eoRNG.h>
#include "order_xover.h"
void OrderXover :: cross (const Route & __par1, const Route & __par2, Route & __child) {
unsigned cut2 = 1 + rng.random (numNodes) ;
unsigned cut1 = rng.random (cut2);
unsigned l = 0;
/* To store vertices that have already been crossed */
std :: vector <bool> v (numNodes, false);
/* Copy of the left partial route of the first parent */
for (unsigned i = cut1 ; i < cut2 ; i ++) {
__child [l ++] = __par1 [i] ;
v [__par1 [i]] = true ;
}
/* Searching the vertex of the second path, that ended the previous first one */
unsigned from = 0 ;
for (unsigned i = 0; i < numNodes; i ++)
if (__par2 [i] == __child [cut2 - 1]) {
from = i ;
break ;
}
/* Selecting a direction (Left or Right) */
char direct = rng.flip () ? 1 : -1 ;
for (unsigned i = 0; i < numNodes + 1; i ++) {
unsigned bidule = (direct * i + from + numNodes) % numNodes;
if (! v [__par2 [bidule]]) {
__child [l ++] = __par2 [bidule] ;
v [__par2 [bidule]] = true ;
}
}
}
bool OrderXover :: operator () (Route & __route1, Route & __route2) {
// Init. copy
Route par [2] ;
par [0] = __route1 ;
par [1] = __route2 ;
cross (par [0], par [1], __route1) ;
cross (par [1], par [0], __route2) ;
__route1.invalidate () ;
__route2.invalidate () ;
return true ;
}

View file

@ -0,0 +1,28 @@
// "order_xover.h"
// (c) OPAC Team, LIFL, 2003
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef order_xover_h
#define order_xover_h
#include <eoOp.h>
#include "route.h"
/** Order Crossover */
class OrderXover : public eoQuadOp <Route> {
public :
bool operator () (Route & __route1, Route & __route2) ;
private :
void cross (const Route & __par1, const Route & __par2, Route & __child) ;
} ;
#endif

View file

@ -0,0 +1,240 @@
# Doxyfile 1.4.7
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "ParadisEO-PEO - Lessons"
PROJECT_NUMBER = 0.1
OUTPUT_DIRECTORY = ../../docs/html/lsnshared
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 =
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=../../
GENERATE_TAGFILE = ../../docs/paradiseo-peo-lsn-shared.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

View file

@ -0,0 +1,23 @@
// "param.cpp"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <utils/eoParser.h>
#include "data.h"
#include "opt_route.h"
void loadParameters (int __argc, char * * __argv) {
eoParser parser (__argc, __argv);
loadData (parser);
loadOptimumRoute (parser);
}

View file

@ -0,0 +1,14 @@
// "param.h"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __param_h
#define __param_h
extern void loadParameters (int __argc, char * * __argv);
#endif

View file

@ -0,0 +1,30 @@
// "part_route_eval.cpp"
// (c) OPAC Team, LIFL, 2003
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include "part_route_eval.h"
#include "node.h"
PartRouteEval :: PartRouteEval (float __from,
float __to
) : from (__from),
to (__to) {
}
void PartRouteEval :: operator () (Route & __route) {
unsigned len = 0 ;
for (unsigned i = (unsigned) (__route.size () * from) ;
i < (unsigned) (__route.size () * to) ;
i ++)
len += distance (__route [i], __route [(i + 1) % numNodes]) ;
__route.fitness (- (int) len) ;
}

View file

@ -0,0 +1,33 @@
// "part_route_eval.h"
// (c) OPAC Team, LIFL, 2005
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __part_route_eval_h
#define __part_route_eval_h
#include <eoEvalFunc.h>
#include "route.h"
/** Route Evaluator */
class PartRouteEval : public eoEvalFunc <Route> {
public :
/** Constructor */
PartRouteEval (float __from, float __to) ;
void operator () (Route & __route) ;
private :
float from, to ;
} ;
#endif

View file

@ -0,0 +1,61 @@
// "partial_mapped_xover.cpp"
// (c) OPAC Team, LIFL, 2003
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <assert.h>
#include <utils/eoRNG.h>
#include "partial_mapped_xover.h"
#include "mix.h"
void PartialMappedXover :: repair (Route & __route, unsigned __cut1, unsigned __cut2) {
unsigned v [__route.size ()] ; // Number of times a cities are visited ...
for (unsigned i = 0 ; i < __route.size () ; i ++)
v [i] = 0 ;
for (unsigned i = 0 ; i < __route.size () ; i ++)
v [__route [i]] ++ ;
std :: vector <unsigned> vert ;
for (unsigned i = 0 ; i < __route.size () ; i ++)
if (! v [i])
vert.push_back (i) ;
mix (vert) ;
for (unsigned i = 0 ; i < __route.size () ; i ++)
if (i < __cut1 || i >= __cut2)
if (v [__route [i]] > 1) {
__route [i] = vert.back () ;
vert.pop_back () ;
}
}
bool PartialMappedXover :: operator () (Route & __route1, Route & __route2) {
unsigned cut1 = rng.random (__route1.size ()), cut2 = rng.random (__route2.size ()) ;
if (cut2 < cut1)
std :: swap (cut1, cut2) ;
// Between the cuts
for (unsigned i = cut1 ; i < cut2 ; i ++)
std :: swap (__route1 [i], __route2 [i]) ;
// Outside the cuts
repair (__route1, cut1, cut2) ;
repair (__route2, cut1, cut2) ;
__route1.invalidate () ;
__route2.invalidate () ;
return true ;
}

View file

@ -0,0 +1,28 @@
// "partial_mapped_xover.h"
// (c) OPAC Team, LIFL, 2003
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef partial_mapped_xover_h
#define partial_mapped_xover_h
#include <eoOp.h>
#include "route.h"
/** Partial Mapped Crossover */
class PartialMappedXover : public eoQuadOp <Route> {
public :
bool operator () (Route & __route1, Route & __route2) ;
private :
void repair (Route & __route, unsigned __cut1, unsigned __cut2) ;
} ;
#endif

View file

@ -0,0 +1,21 @@
// "route.cpp"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include "route.h"
unsigned length (const Route & __route) {
unsigned len = 0 ;
for (unsigned i = 0; i < numNodes; i ++)
len += distance (__route [i], __route [(i + 1) % numNodes]) ;
return len;
}

View file

@ -0,0 +1,20 @@
// "route.h"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __route_h
#define __route_h
#include <eoVector.h>
#include "node.h"
typedef eoVector <int, Node> Route;
unsigned length (const Route & __route);
#endif

View file

@ -0,0 +1,14 @@
// "route_eval.cpp"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include "route_eval.h"
void RouteEval :: operator () (Route & __route) {
__route.fitness (- (int) length (__route));
}

View file

@ -0,0 +1,23 @@
// "route_eval.h"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __route_eval_h
#define __route_eval_h
#include <eoEvalFunc.h>
#include "route.h"
class RouteEval : public eoEvalFunc <Route> {
public :
void operator () (Route & __route) ;
} ;
#endif

View file

@ -0,0 +1,23 @@
// "route_init.cpp"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <utils/eoRNG.h>
#include "route_init.h"
#include "node.h"
void RouteInit :: operator () (Route & __route) {
__route.clear ();
for (unsigned i = 0 ; i < numNodes ; i ++)
__route.push_back (i);
for (unsigned i = 0 ; i < numNodes ; i ++)
std :: swap (__route [i], __route [rng.random (numNodes)]);
}

View file

@ -0,0 +1,23 @@
// "route_init.h"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __route_init_h
#define __route_init_h
#include <eoInit.h>
#include "route.h"
class RouteInit : public eoInit <Route> {
public :
void operator () (Route & __route);
} ;
#endif

View file

@ -0,0 +1,20 @@
// "two_opt.cpp"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include "two_opt.h"
void TwoOpt :: operator () (Route & __route) {
unsigned i = 0;
while ((2 * i) < (second - first)) {
std :: swap (__route [first + i], __route [second - i]);
i ++;
}
}

View file

@ -0,0 +1,25 @@
// "two_opt.h"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __two_opt_h
#define __two_opt_h
#include <utility>
#include <moMove.h>
#include "route.h"
class TwoOpt : public moMove <Route>, public std :: pair <unsigned, unsigned> {
public :
void operator () (Route & __route);
} ;
#endif

View file

@ -0,0 +1,24 @@
// "TwoOptIncrEval.cpp"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include "two_opt_incr_eval.h"
#include "node.h"
int TwoOptIncrEval :: operator () (const TwoOpt & __move, const Route & __route) {
/* From */
Node v1 = __route [__move.first], v1_left = __route [(__move.first - 1 + numNodes) % numNodes];
/* To */
Node v2 = __route [__move.second], v2_right = __route [(__move.second + 1) % numNodes];
if (v1 == v2 || v2_right == v1)
return __route.fitness ();
else
return __route.fitness () - distance (v1_left, v2) - distance (v1, v2_right) + distance (v1_left, v1) + distance (v2, v2_right);
}

View file

@ -0,0 +1,23 @@
// "TwoOptIncrEval.h"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __two_opt_incr_eval_h
#define __two_opt_incr_eval_h
#include <moMoveIncrEval.h>
#include "two_opt.h"
class TwoOptIncrEval : public moMoveIncrEval <TwoOpt> {
public :
int operator () (const TwoOpt & __move, const Route & __route) ;
} ;
#endif

View file

@ -0,0 +1,14 @@
// "two_opt_init.cpp"
// (c) OPAC Team, LIFL, 2003
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include "two_opt_init.h"
void TwoOptInit :: operator () (TwoOpt & __move, const Route & __route) {
__move.first = __move.second = 0;
}

View file

@ -0,0 +1,24 @@
// "two_opt_init.h"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __two_opt_init_h
#define __two_opt_init_h
#include <moMoveInit.h>
#include "two_opt.h"
class TwoOptInit : public moMoveInit <TwoOpt> {
public :
void operator () (TwoOpt & __move, const Route & __route) ;
} ;
#endif

View file

@ -0,0 +1,27 @@
// "two_opt_next.cpp"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include "two_opt_next.h"
#include "node.h"
bool TwoOptNext :: operator () (TwoOpt & __move, const Route & __route) {
if (__move.first == numNodes - 1 && __move.second == numNodes - 1)
return false;
else {
__move.second ++;
if (__move.second == numNodes) {
__move.first ++;
__move.second = __move.first;
}
return true ;
}
}

View file

@ -0,0 +1,24 @@
// "two_opt_next.h"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __two_opt_next_h
#define __two_opt_next_h
#include <moNextMove.h>
#include "two_opt.h"
class TwoOptNext : public moNextMove <TwoOpt> {
public :
bool operator () (TwoOpt & __move, const Route & __route);
};
#endif

View file

@ -0,0 +1,21 @@
// "two_opt_rand.cpp"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <utils/eoRNG.h>
#include "two_opt_rand.h"
#include "node.h"
void TwoOptRand :: operator () (TwoOpt & __move, const Route & __route) {
__move.second = rng.random (numNodes);
__move.first = rng.random (__move.second);
}

View file

@ -0,0 +1,24 @@
// "two_opt_rand.h"
// (c) OPAC Team, LIFL, January 2006
/*
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef __two_opt_rand_h
#define __two_opt_rand_h
#include <eoMoveRand.h>
#include "two_opt.h"
class TwoOptRand : public eoMoveRand <TwoOpt> {
public :
void operator () (TwoOpt & __move, const Route & __route) ;
} ;
#endif