From ff3abc32ff07665c800372ff1093deacc090e429 Mon Sep 17 00:00:00 2001 From: canape Date: Tue, 29 Jan 2008 13:50:22 +0000 Subject: [PATCH] Documentation for PEO git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@908 331e1502-861f-0410-8da2-ba01fb791d7f --- trunk/paradiseo-peo/src/peo | 4 +- trunk/paradiseo-peo/src/peo.h | 2 +- trunk/paradiseo-peo/src/peoAggEvalFunc.h | 4 +- trunk/paradiseo-peo/src/peoAsyncIslandMig.h | 151 ++++------------- trunk/paradiseo-peo/src/peoData.h | 105 ++++++++++-- trunk/paradiseo-peo/src/peoEvalFunc.h | 12 +- .../paradiseo-peo/src/peoGlobalBestVelocity.h | 19 ++- trunk/paradiseo-peo/src/peoMoeoPopEval.h | 38 +++-- trunk/paradiseo-peo/src/peoMultiStart.h | 110 +++++------- trunk/paradiseo-peo/src/peoNoAggEvalFunc.h | 6 +- trunk/paradiseo-peo/src/peoPSOSelect.h | 12 ++ trunk/paradiseo-peo/src/peoPopEval.h | 37 +++-- trunk/paradiseo-peo/src/peoSyncIslandMig.h | 157 +++++------------- trunk/paradiseo-peo/src/peoTransform.h | 42 +++-- .../src/peoWorstPositionReplacement.h | 12 +- trunk/paradiseo-peo/src/peoWrapper.h | 27 ++- 16 files changed, 354 insertions(+), 384 deletions(-) diff --git a/trunk/paradiseo-peo/src/peo b/trunk/paradiseo-peo/src/peo index e55873115..3ba8fec40 100644 --- a/trunk/paradiseo-peo/src/peo +++ b/trunk/paradiseo-peo/src/peo @@ -1,9 +1,9 @@ /* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 +* (C) OPAC Team, LIFL, 2002-2008 * -* Sebastien Cahon, Alexandru-Adrian Tantar +* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, diff --git a/trunk/paradiseo-peo/src/peo.h b/trunk/paradiseo-peo/src/peo.h index c219609c4..0fe8599ff 100644 --- a/trunk/paradiseo-peo/src/peo.h +++ b/trunk/paradiseo-peo/src/peo.h @@ -1,7 +1,7 @@ /* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 +* (C) OPAC Team, LIFL, 2002-2008 * * Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape * diff --git a/trunk/paradiseo-peo/src/peoAggEvalFunc.h b/trunk/paradiseo-peo/src/peoAggEvalFunc.h index b1d41b459..5b4780e0e 100644 --- a/trunk/paradiseo-peo/src/peoAggEvalFunc.h +++ b/trunk/paradiseo-peo/src/peoAggEvalFunc.h @@ -1,9 +1,9 @@ /* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 +* (C) OPAC Team, LIFL, 2002-2008 * -* Sebastien Cahon, Alexandru-Adrian Tantar +* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, diff --git a/trunk/paradiseo-peo/src/peoAsyncIslandMig.h b/trunk/paradiseo-peo/src/peoAsyncIslandMig.h index 4f765a803..445d24f98 100644 --- a/trunk/paradiseo-peo/src/peoAsyncIslandMig.h +++ b/trunk/paradiseo-peo/src/peoAsyncIslandMig.h @@ -1,9 +1,9 @@ /* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 +* (C) OPAC Team, LIFL, 2002-2008 * -* Sebastien Cahon, Alexandru-Adrian Tantar +* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -56,105 +56,24 @@ #include "core/peo_debug.h" -//! Class providing the basis for the asynchronous island migration model. - -//! The peoAsyncIslandMig class offers the elementary basis for implementating an -//! asynchronous island migration model - requires the specification of several basic -//! parameters, i.e. continuation criterion, selection and replacement strategies, -//! a topological model and the source and destination population for the migrating individuals. -//! As opposed to the synchronous migration model, in the asynchronous migration approach, there is -//! no synchronization step between islands after performing the emigration phase. -//! -//! The migration operator is called at the end of each generation of an evolutionary algorithms -//! as a checkpoint object - the following code exposes the structure of a classic evolutionary algorithm: -//! -//! -//! -//! -//! -//! -//! -//! -//!
do {    
         select( population, offsprings );   // select the offsprings from the current population
         transform( offsprings );   // crossover and mutation operators are applied on the selected offsprings
         evaluate( offsprings );   // evaluation step of the resulting offsprings
         replace( population, offsprings );   // replace the individuals in the current population whith individuals from the offspring population, according to a specified replacement strategy
} while ( eaCheckpointContinue( population ) );   // checkpoint operators are applied on the current population, including the migration operator, if any specified
-//! -//! Constructing an asynchronous island migration model requires having defined (1) a topological migration model, -//! (2) the control parameters of the migration process, (3) a checkpoint object associated with an evolutionary algorithm, -//! and (4) an owner object must be set. The owner object must be derived from the Runner class (for example -//! a peoEA object represents a possible owner). -//! A simple example is offered bellow: -//! -//!
    -//!
  1. topological model to be followed when performing migrations:
    -//!
    -//! -//! -//!
    RingTopology migTopology;   // a simple ring topological model - each island communicates with two other islands
    -//!
  2. -//! -//!
  3. the continuation criterion, selection and replacement strategy etc. are defined:
    -//!
    -//! -//! -//! -//! -//! -//! -//! -//! -//! -//! -//!
    eoPop< EOT > population( POP_SIZE, popInitializer );   // population of individuals to be used for the evolutionary algorithm
       
    eoPeriodicContinue< EOT > migCont( MIG_FREQ );   // migrations occur periodically at MIG_FREQ iterations
    eoRandomSelect< EOT > migSelectStrategy;   // selection strategy - in this case a random selection is applied
    eoSelectNumber< EOT > migSelect( migSelectStrategy, MIG_SIZE );   // number of individuals to be selected using the specified strategy
    eoPlusReplacement< EOT > migReplace;   // immigration strategy - the worse individuals in the destination population are replaced by the immigrant individuals
       
    peoAsyncIslandMig< EOT > asyncMigration( -//!
             migCont, migSelect, migReplace, migTopology, -//!
             population, population -//!
    );  
    // asynchronous migration object - the emigrant individuals are selected from the same from population in which the immigrant individuals are being integrated
    -//!
  4. -//! -//!
  5. creation of a checkpoint object as part of the definition of an evolutionary algoritm (details of th EA not given as being out of scope):
    -//!
    -//! -//! -//! -//! -//! -//! -//! -//!
    ...    
    eoGenContinue< EOT > eaCont( NUM_GEN );   // the evolutionary algorithm will stop after NUM_GEN generations
    eoCheckPoint< EOT > eaCheckpointContinue( eaCont );   // number of individuals to be selected using the specified strategy
    ...    
    eaCheckpointContinue.add( asyncMigration );   // adding the migration operator as checkpoint element
    ...    
    -//!
  6. -//! -//!
  7. definition of an owner evolutionary algorithm (an object inheriting the Runner class):
    -//!
    -//! -//! -//! -//! -//!
    peoEA< EOT > eaAlg( eaCheckpointContinue, eaPopEval, eaSelect, eaTransform, eaReplace);   // evolutionary algorithm having as checkpoint the eaCheckpointContinue object defined above
    asyncMigration.setOwner( eaAlg );   // setting the evolutionary algorithm as owner of the migration object
    eaAlg( population );   // applying the evolutionary algorithm on a given population
    -//!
  8. -//!
-//! -//! The source and the destination population for the migration object were specified as being the same, in step no. 2, -//! as we are usually interested in selecting the emigrants and integrating the immigrant individuals from and in, respectively, one unique -//! population, iteratively evolved by an evolutionary algorithm. There is no restriction in having two distinct populations -//! as source and destination for the emigrant and immigrant individuals respectively. -//! -//! The above steps only create an asynchronous migration object associated to an evolutionary algorithm. The creation of several -//! islands requires the reiteration of the steps 2 through 4 for creating distinct algorithms, with distinct populations and -//! the associated distinctly parametrized migration objects. The interconnecting element is the underlying topology, defined at step 1 -//! (the same C++ migTopology object has to be passed as parameter for all the migration objects, in order to interconnect them). +//! @class peoAsyncIslandMig +//! @brief Specific class for a asynchronous migration +//! @see Cooperative eoUpdater +//! @version 2.0 +//! @date january 2008 template< class EOT, class TYPE > class peoAsyncIslandMig : public Cooperative, public eoUpdater { public: - //! Constructor for the peoAsyncIslandMig class; the characteristics of the migration model are defined - //! through the specified parameters - out of the box objects provided in EO, etc., or custom, derived objects may be passed as parameters. - //! - //! @param eoContinue< EOT >& __cont - continuation criterion specifying whether the migration is performed or not; - //! @param eoSelect< EOT >& __select - selection strategy to be applied for constructing a list of emigrant individuals out of the source population; - //! @param eoReplacement< EOT >& __replace - replacement strategy used for integrating the immigrant individuals in the destination population; - //! @param Topology& __topology - topological model to be followed when performing migrations; - //! @param eoPop< EOT >& __source - source population from which the emigrant individuals are selected; - //! @param eoPop< EOT >& __destination - destination population in which the immigrant population are integrated. - peoAsyncIslandMig( + //! @brief Constructor + //! @param continuator & __cont + //! @param selector & __select + //! @param replacement & __replace + //! @param Topology& __topology + //! @param peoData & __source + //! @param eoData & __destination + peoAsyncIslandMig( continuator & __cont, selector & __select, replacement & __replace, @@ -163,33 +82,35 @@ template< class EOT, class TYPE > class peoAsyncIslandMig : public Cooperative, peoData & __destination ); - - //! Function operator to be called as checkpoint for performing the migration step. The emigrant individuals are selected - //! from the source population and sent to the next island (defined by the topology object) while the immigrant - //! individuals are integrated in the destination population. There is no need to explicitly call the function - the - //! wrapper checkpoint object (please refer to the above example) will perform the call when required. + //! @brief operator void operator()(); - - //! Auxiliary function dealing with sending the emigrant individuals. There is no need to explicitly call the function. + //! @brief Function realizing packages void pack(); - //! Auxiliary function dealing with receiving immigrant individuals. There is no need to explicitly call the function. + //! @brief Function reconstituting packages void unpack(); - //! Auxiliary function dealing with the packing of synchronization requests - not the case. + //! @brief Function packSynchronizeReq void packSynchronizeReq(); - private: - + //! @brief Function which sends some emigrants void emigrate(); + //! @brief Function which receives some immigrants void immigrate(); - private: - - continuator & cont; // continuator - selector & select; // the selection strategy - replacement & replace; // the replacement strategy - Topology& topology; // the neighboring topology + //! @param continuator & cont + //! @param selector & select + //! @param replacement & replace + //! @param Topology& topology + //! @param peoData & source + //! @param peoData & destination + //! @param std :: queue< TYPE > imm + //! @param std :: queue< TYPE > em + //! @param std :: queue< Cooperative* > coop_em + continuator & cont; + selector & select; + replacement & replace; + Topology& topology; peoData & source; peoData & destination; std :: queue< TYPE > imm; @@ -278,8 +199,8 @@ template< class EOT , class TYPE> void peoAsyncIslandMig< EOT, TYPE > :: operato if (cont.check()) { - emigrate(); // sending emigrants - immigrate(); // receiving immigrants + emigrate(); + immigrate(); } } diff --git a/trunk/paradiseo-peo/src/peoData.h b/trunk/paradiseo-peo/src/peoData.h index 98eb10b09..480f6e823 100644 --- a/trunk/paradiseo-peo/src/peoData.h +++ b/trunk/paradiseo-peo/src/peoData.h @@ -1,7 +1,7 @@ /* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 +* (C) OPAC Team, LIFL, 2002-2008 * * Clive Canape, Thomas Legrand * @@ -44,25 +44,35 @@ /************************** DEFINE A DATA ******************************************/ /**************************************************************************************/ +//! @class peoData +//! @brief Abstract class for a data exchanged by migration +//! @version 1.0 +//! @date january 2008 class peoData { public: - + + //! @brief Function realizing packages virtual void pack () {} + + //! @brief Function reconstituting packages virtual void unpack () {} }; - -// Specific implementation : migration of a population - +//! @class peoPop +//! @brief Specific class for a migration of a population +//! @see peoData eoPop +//! @version 1.0 +//! @date january 2008 template class peoPop: public eoPop, public peoData { public: + //! @brief Function realizing packages virtual void pack () { ::pack ((unsigned) this->size ()); @@ -70,6 +80,7 @@ class peoPop: public eoPop, public peoData ::pack ((*this)[i]); } + //! @brief Function reconstituting packages virtual void unpack () { unsigned n; @@ -86,28 +97,45 @@ class peoPop: public eoPop, public peoData /************************** DEFINE A CONTINUATOR ***********************************/ /**************************************************************************************/ +//! @class continuator +//! @brief Abstract class for a continuator within the exchange of data by migration +//! @version 1.0 +//! @date january 2008 class continuator { public: + + //! @brief Virtual function of check + //! @return true if the algorithm must continue virtual bool check()=0; }; -// Specific implementation : migration of a population - +//! @class eoContinuator +//! @brief Specific class for a continuator within the exchange of migration of a population +//! @see continuator +//! @version 1.0 +//! @date january 2008 template < class EOT> class eoContinuator : public continuator { public: + //! @brief Constructor + //! @param eoContinue & + //! @param eoPop & eoContinuator(eoContinue & _cont, const eoPop & _pop): cont (_cont), pop(_pop) {} + //! @brief Virtual function of check + //! @return true if the algorithm must continue virtual bool check() { return cont(pop); } protected: + //! @param eoContinue & + //! @param eoPop & eoContinue & cont ; const eoPop & pop; }; @@ -117,23 +145,39 @@ template < class EOT> class eoContinuator : public continuator /************************** DEFINE A SELECTOR **************************************/ /**************************************************************************************/ +//! @class selector +//! @brief Abstract class for a selector within the exchange of data by migration +//! @version 1.0 +//! @date january 2008 template < class TYPE> class selector { public: + + //! @brief Virtual operator on the template type + //! @param TYPE & virtual void operator()(TYPE &)=0; }; -// Specific implementation : migration of a population - +//! @class eoSelector +//! @brief Specific class for a selector within the exchange of migration of a population +//! @see selector +//! @version 1.0 +//! @date january 2008 template < class EOT, class TYPE> class eoSelector : public selector< TYPE > { public: + //! @brief Constructor + //! @param eoSelectOne & + //! @param unsigned _nb_select + //! @param TYPE & _source (with TYPE which is the template type) eoSelector(eoSelectOne & _select, unsigned _nb_select, const TYPE & _source): selector (_select), nb_select(_nb_select), source(_source) {} - - virtual void operator()(TYPE & _dest) + + //! @brief Virtual operator on the template type + //! @param TYPE & _dest + virtual void operator()(TYPE & _dest) { size_t target = static_cast(nb_select); _dest.resize(target); @@ -142,6 +186,9 @@ template < class EOT, class TYPE> class eoSelector : public selector< TYPE > } protected: + //! @param eoSelectOne & + //! @param unsigned nb_select + //! @param TYPE & source eoSelectOne & selector ; unsigned nb_select; const TYPE & source; @@ -152,27 +199,43 @@ template < class EOT, class TYPE> class eoSelector : public selector< TYPE > /************************** DEFINE A REPLACEMENT ***********************************/ /**************************************************************************************/ +//! @class replacement +//! @brief Abstract class for a replacement within the exchange of data by migration +//! @version 1.0 +//! @date january 2008 template < class TYPE> class replacement { public: + //! @brief Virtual operator on the template type + //! @param TYPE & virtual void operator()(TYPE &)=0; }; -// Specific implementation : migration of a population - +//! @class eoReplace +//! @brief Specific class for a replacement within the exchange of migration of a population +//! @see replacement +//! @version 1.0 +//! @date january 2008 template < class EOT, class TYPE> class eoReplace : public replacement< TYPE > { public: + //! @brief Constructor + //! @param eoReplacement & + //! @param TYPE & _destination (with TYPE which is the template type) eoReplace(eoReplacement & _replace, TYPE & _destination): replace(_replace), destination(_destination) {} + //! @brief Virtual operator on the template type + //! @param TYPE & _source virtual void operator()(TYPE & _source) { replace(destination, _source); } protected: + //! @param eoReplacement & + //! @param TYPE & destination eoReplacement & replace; TYPE & destination; }; @@ -182,14 +245,23 @@ template < class EOT, class TYPE> class eoReplace : public replacement< TYPE > /************************ Continuator for synchrone migartion ************************/ /**************************************************************************************/ +//! @class eoSyncContinue +//! @brief Class for a continuator within the exchange of data by synchrone migration +//! @see continuator +//! @version 1.0 +//! @date january 2008 class eoSyncContinue: public continuator { public: - + //! @brief Constructor + //! @param unsigned __period + //! @param unsigned __init_counter eoSyncContinue (unsigned __period, unsigned __init_counter = 0): period (__period),counter (__init_counter) {} + //! @brief Virtual function of check + //! @return true if the algorithm must continue virtual bool check() { return ((++ counter) % period) != 0 ; @@ -197,11 +269,10 @@ class eoSyncContinue: public continuator private: - + //! @param unsigned period + //! @param unsigned counter unsigned period; - unsigned counter; - }; diff --git a/trunk/paradiseo-peo/src/peoEvalFunc.h b/trunk/paradiseo-peo/src/peoEvalFunc.h index b6e8486f3..1443965fb 100644 --- a/trunk/paradiseo-peo/src/peoEvalFunc.h +++ b/trunk/paradiseo-peo/src/peoEvalFunc.h @@ -1,7 +1,7 @@ /* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, INRIA, 2007 +* (C) OPAC Team, INRIA, 2008 * * Clive Canape * @@ -37,6 +37,11 @@ #ifndef PEOEVALFUNC_H #define PEOEVALFUNC_H +//! @class peoEvalFunc +//! @brief Specific class for evaluation +//! @see eoEvalFunc +//! @version 1.0 +//! @date november 2007 #ifdef _MSC_VER template< class EOT, class FitT = EOT::Fitness, class FunctionArg = const EOT& > #else @@ -45,16 +50,21 @@ template< class EOT, class FitT = typename EOT::Fitness, class FunctionArg = con struct peoEvalFunc: public eoEvalFunc { + //! @brief Constructor + //! @param FitT (* _eval)( FunctionArg ) peoEvalFunc( FitT (* _eval)( FunctionArg ) ) : eoEvalFunc(), evalFunc( _eval ) {}; + //! @brief Virtual operator + //! @param EOT & _peo virtual void operator() ( EOT & _peo ) { _peo.fitness((*evalFunc)( _peo )); }; private: + //! @param FitT (* evalFunc )( FunctionArg ) FitT (* evalFunc )( FunctionArg ); }; diff --git a/trunk/paradiseo-peo/src/peoGlobalBestVelocity.h b/trunk/paradiseo-peo/src/peoGlobalBestVelocity.h index 6e3374c9c..3b8bbaa26 100644 --- a/trunk/paradiseo-peo/src/peoGlobalBestVelocity.h +++ b/trunk/paradiseo-peo/src/peoGlobalBestVelocity.h @@ -46,19 +46,28 @@ #include #include +//! @class peoGlobalBestVelocity +//! @brief Specific class for a replacement thanks to the velocity migration of a population of a PSO +//! @see eoReplacement +//! @version 1.1 +//! @date october 2007 template class peoGlobalBestVelocity : public eoReplacement { public: + //! @brief typedef : creation of VelocityType typedef typename POT::ParticleVelocityType VelocityType; - peoGlobalBestVelocity( const double & _c3, - eoVelocity < POT > &_velocity): - c3 (_c3), - velocity (_velocity) + //! @brief Constructor + //! @param double & _c3 + //! @param eoVelocity < POT > &_velocity + peoGlobalBestVelocity( const double & _c3, eoVelocity < POT > &_velocity): c3 (_c3),velocity (_velocity) {} + //! @brief Virtual operator + //! @param eoPop& _dest + //! @param eoPop& _source void operator()(eoPop& _dest, eoPop& _source) { @@ -74,6 +83,8 @@ class peoGlobalBestVelocity : public eoReplacement } protected: + //! @param double & c3 + //! @param eoVelocity < POT > & velocity const double & c3; eoVelocity < POT > & velocity; }; diff --git a/trunk/paradiseo-peo/src/peoMoeoPopEval.h b/trunk/paradiseo-peo/src/peoMoeoPopEval.h index a2a68001b..25dd7586d 100644 --- a/trunk/paradiseo-peo/src/peoMoeoPopEval.h +++ b/trunk/paradiseo-peo/src/peoMoeoPopEval.h @@ -1,9 +1,9 @@ /* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 +* (C) OPAC Team, LIFL, 2002-2008 * -* Sebastien Cahon, Alexandru-Adrian Tantar +* Clive Canape * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -45,12 +45,11 @@ #include "peoAggEvalFunc.h" #include "peoNoAggEvalFunc.h" - -//! Parallel evaluation functor wrapper. - -//! The peoMoeoPopEval represents a wrapper for creating a functor capable of applying in parallel -//! an EO-derived evaluation functor. The class offers the possibility of chosing between a single-function evaluation -//! and an aggregate evaluation function, including several sub-evalution functions. +//! @class peoPopEval +//! @brief Parallel evaluation functor wrapper with MOEO +//! @see Service eoPopEvalFunc +//! @version 1.0 +//! @date 2008 template< class EOT > class peoMoeoPopEval : public Service, public eoPopEvalFunc { @@ -72,6 +71,10 @@ template< class EOT > class peoMoeoPopEval : public Service, public eoPopEvalFun //! //! @param eoPop< EOT >& __pop - population to be evaluated by applying the evaluation functor specified in the constructor. void operator()(eoPop< EOT >& __pop); + + //! @brief Operator ()( eoPop< EOT >& __dummy, eoPop< EOT >& __pop ) + //! @param eoPop< EOT >& __dummy + //! @param eoPop< EOT >& __pop void operator()( eoPop< EOT >& __dummy, eoPop< EOT >& __pop ); //! Auxiliary function for transferring data between the process requesting an evaluation operation and the process that @@ -102,24 +105,25 @@ template< class EOT > class peoMoeoPopEval : public Service, public eoPopEvalFun void notifySendingAllResourceRequests(); private: - - + //! @param std :: vector< eoEvalFunc < EOT >* >& funcs + //! @param std :: vector< eoEvalFunc < EOT >* > one_func + //! @param peoAggEvalFunc< EOT >& merge_eval + //! @param peoNoAggEvalFunc< EOT > no_merge_eval + //! @param std :: queue< EOT* >tasks + //! @param std :: map< EOT*, std :: pair< unsigned, unsigned > > progression + //! @param unsigned num_func + //! @param EOT sol + //! @param EOT *ad_sol + //! @param unsigned total const std :: vector< eoEvalFunc < EOT >* >& funcs; std :: vector< eoEvalFunc < EOT >* > one_func; - peoAggEvalFunc< EOT >& merge_eval; peoNoAggEvalFunc< EOT > no_merge_eval; - std :: queue< EOT* >tasks; - std :: map< EOT*, std :: pair< unsigned, unsigned > > progression; - unsigned num_func; - EOT sol; - EOT *ad_sol; - unsigned total; }; diff --git a/trunk/paradiseo-peo/src/peoMultiStart.h b/trunk/paradiseo-peo/src/peoMultiStart.h index 52670d69b..a8c250929 100644 --- a/trunk/paradiseo-peo/src/peoMultiStart.h +++ b/trunk/paradiseo-peo/src/peoMultiStart.h @@ -1,9 +1,9 @@ /* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 +* (C) OPAC Team, LIFL, 2002-2008 * -* Sebastien Cahon, Alexandru-Adrian Tantar +* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -41,204 +41,188 @@ #include "core/service.h" #include "core/messaging.h" - +//! @class peoMultiStart +//! @brief Class allowing the launch of several algorithms +//! @see Service +//! @version 1.1 +//! @date january 2008 template < typename EntityType > class peoMultiStart : public Service { public: + //! @brief Constructor + //! @param AlgorithmType& externalAlgorithm template < typename AlgorithmType > peoMultiStart( AlgorithmType& externalAlgorithm ) { - singularAlgorithm = new Algorithm< AlgorithmType >( externalAlgorithm ); algorithms.push_back( singularAlgorithm ); - aggregationFunction = new NoAggregationFunction(); } + //! @brief Constructor + //! @param AlgorithmReturnType (*externalAlgorithm)( AlgorithmDataType& ) template < typename AlgorithmReturnType, typename AlgorithmDataType > peoMultiStart( AlgorithmReturnType (*externalAlgorithm)( AlgorithmDataType& ) ) { - singularAlgorithm = new FunctionAlgorithm< AlgorithmReturnType, AlgorithmDataType >( externalAlgorithm ); algorithms.push_back( singularAlgorithm ); - aggregationFunction = new NoAggregationFunction(); } - + + //! @brief Constructor + //! @param std::vector< AlgorithmType* >& externalAlgorithms + //! @param AggregationFunctionType& externalAggregationFunction template < typename AlgorithmType, typename AggregationFunctionType > peoMultiStart( std::vector< AlgorithmType* >& externalAlgorithms, AggregationFunctionType& externalAggregationFunction ) { - for ( unsigned int index = 0; index < externalAlgorithms.size(); index++ ) { - algorithms.push_back( new Algorithm< AlgorithmType >( *externalAlgorithms[ index ] ) ); } - aggregationFunction = new AggregationAlgorithm< AggregationFunctionType >( externalAggregationFunction ); } - template < typename AlgorithmReturnType, typename AlgorithmDataType, typename AggregationFunctionType > - peoMultiStart( std::vector< AlgorithmReturnType (*)( AlgorithmDataType& ) >& externalAlgorithms, - AggregationFunctionType& externalAggregationFunction ) + //! @brief Constructor + //! @param std::vector< AlgorithmReturnType (*)( AlgorithmDataType& ) >& externalAlgorithms + //! @param AggregationFunctionType& externalAggregationFunction + template < typename AlgorithmReturnType, typename AlgorithmDataType, typename AggregationFunctionType > peoMultiStart( std::vector< AlgorithmReturnType (*)( AlgorithmDataType& ) >& externalAlgorithms, AggregationFunctionType& externalAggregationFunction ) { - for ( unsigned int index = 0; index < externalAlgorithms.size(); index++ ) { - algorithms.push_back( new FunctionAlgorithm< AlgorithmReturnType, AlgorithmDataType >( externalAlgorithms[ index ] ) ); } - aggregationFunction = new AggregationAlgorithm< AggregationFunctionType >( externalAggregationFunction ); } + //! @brief Destructor ~peoMultiStart() { - for ( unsigned int index = 0; index < data.size(); index++ ) delete data[ index ]; - for ( unsigned int index = 0; index < algorithms.size(); index++ ) delete algorithms[ index ]; - - delete aggregationFunction; + for ( unsigned int index = 0; index < algorithms.size(); index++ ) delete algorithms[ index ]; + delete aggregationFunction; } - + //! @brief operator on the template type + //! @param Type& externalData template < typename Type > void operator()( Type& externalData ) { - for ( typename Type::iterator externalDataIterator = externalData.begin(); externalDataIterator != externalData.end(); externalDataIterator++ ) { - data.push_back( new DataType< EntityType >( *externalDataIterator ) ); } - functionIndex = dataIndex = idx = num_term = 0; requestResourceRequest( data.size() * algorithms.size() ); stop(); } - + //! @brief operator on the template type + //! @param Type& externalDataBegin + //! @param Type& externalDataEnd template < typename Type > void operator()( const Type& externalDataBegin, const Type& externalDataEnd ) { - for ( Type externalDataIterator = externalDataBegin; externalDataIterator != externalDataEnd; externalDataIterator++ ) { - data.push_back( new DataType< EntityType >( *externalDataIterator ) ); } - functionIndex = dataIndex = idx = num_term = 0; requestResourceRequest( data.size() * algorithms.size() ); stop(); } - + //! @brief Function realizing packages of data void packData(); - + //! @brief Function reconstituting packages of data void unpackData(); - + //! @brief Function which executes the algorithm void execute(); - + //! @brief Function realizing packages of the result void packResult(); - + //! @brief Function reconstituting packages of result void unpackResult(); - + //! @brief Function notifySendingData void notifySendingData(); - + //! @brief Function notifySendingAllResourceRequests void notifySendingAllResourceRequests(); - private: - + + //! @param AbstractAlgorithm* singularAlgorithm + //! @param std::vector< AbstractAlgorithm* > algorithms + //! @param AbstractAggregationAlgorithm* aggregationFunction + //! @param EntityType entityTypeInstance + //! @param std::vector< AbstractDataType* > data + //! @param unsigned idx + //! @param unsigned num_term + //! @param unsigned dataIndex + //! @param unsigned functionIndex template < typename Type > struct DataType; - struct AbstractDataType { - virtual ~AbstractDataType() { } - template < typename Type > operator Type& () { - return ( dynamic_cast< DataType< Type >& >( *this ) ).data; } }; template < typename Type > struct DataType : public AbstractDataType { - DataType( Type& externalData ) : data( externalData ) { } - Type& data; }; struct AbstractAlgorithm { - virtual ~AbstractAlgorithm() { } - virtual void operator()( AbstractDataType& dataTypeInstance ) {} }; template < typename AlgorithmType > struct Algorithm : public AbstractAlgorithm { - Algorithm( AlgorithmType& externalAlgorithm ) : algorithm( externalAlgorithm ) { } - void operator()( AbstractDataType& dataTypeInstance ) { algorithm( dataTypeInstance ); } - AlgorithmType& algorithm; }; - template < typename AlgorithmReturnType, typename AlgorithmDataType > struct FunctionAlgorithm : public AbstractAlgorithm { - FunctionAlgorithm( AlgorithmReturnType (*externalAlgorithm)( AlgorithmDataType& ) ) : algorithm( externalAlgorithm ) { } - void operator()( AbstractDataType& dataTypeInstance ) { algorithm( dataTypeInstance ); } - AlgorithmReturnType (*algorithm)( AlgorithmDataType& ); }; struct AbstractAggregationAlgorithm { - virtual ~AbstractAggregationAlgorithm() { } - virtual void operator()( AbstractDataType& dataTypeInstanceA, AbstractDataType& dataTypeInstanceB ) {}; }; template < typename AggregationAlgorithmType > struct AggregationAlgorithm : public AbstractAggregationAlgorithm { - AggregationAlgorithm( AggregationAlgorithmType& externalAggregationAlgorithm ) : aggregationAlgorithm( externalAggregationAlgorithm ) { } - void operator()( AbstractDataType& dataTypeInstanceA, AbstractDataType& dataTypeInstanceB ) { - aggregationAlgorithm( dataTypeInstanceA, dataTypeInstanceB ); } - AggregationAlgorithmType& aggregationAlgorithm; }; struct NoAggregationFunction : public AbstractAggregationAlgorithm { - void operator()( AbstractDataType& dataTypeInstanceA, AbstractDataType& dataTypeInstanceB ) { @@ -246,17 +230,11 @@ template < typename EntityType > class peoMultiStart : public Service } }; - - AbstractAlgorithm* singularAlgorithm; - std::vector< AbstractAlgorithm* > algorithms; AbstractAggregationAlgorithm* aggregationFunction; - - EntityType entityTypeInstance; std::vector< AbstractDataType* > data; - unsigned idx; unsigned num_term; unsigned dataIndex; diff --git a/trunk/paradiseo-peo/src/peoNoAggEvalFunc.h b/trunk/paradiseo-peo/src/peoNoAggEvalFunc.h index d6fa02152..ec3979dd8 100644 --- a/trunk/paradiseo-peo/src/peoNoAggEvalFunc.h +++ b/trunk/paradiseo-peo/src/peoNoAggEvalFunc.h @@ -1,9 +1,9 @@ /* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 +* (C) OPAC Team, LIFL, 2002-2008 * -* Sebastien Cahon, Alexandru-Adrian Tantar +* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -50,6 +50,8 @@ template< class EOT > class peoNoAggEvalFunc : public peoAggEvalFunc< EOT > public : //! Operator which sets as fitness the __fit value for the __sol individual + //! @param EOT& __sol + //! @param typename EOT :: Fitness& __fit void operator()( EOT& __sol, const typename EOT :: Fitness& __fit ); }; diff --git a/trunk/paradiseo-peo/src/peoPSOSelect.h b/trunk/paradiseo-peo/src/peoPSOSelect.h index 50f3f2862..6ab87fac9 100644 --- a/trunk/paradiseo-peo/src/peoPSOSelect.h +++ b/trunk/paradiseo-peo/src/peoPSOSelect.h @@ -39,21 +39,33 @@ #include #include +//! @class peoPSOSelect +//! @brief Specific class for a selection of a population of a PSO +//! @see eoSelectOne +//! @version 1.1 +//! @date october 2007 template class peoPSOSelect: public eoSelectOne { public: + //! @brief Constructor + //! @param eoTopology < POT > & _topology peoPSOSelect(eoTopology < POT > & _topology):topology(_topology) {} + //! @brief typedef : creation of Fitness typedef typename PO < POT >::Fitness Fitness; + //! @brief Virtual operator + //! @param eoPop& _pop + //! @return POT& virtual const POT& operator()(const eoPop& _pop) { return topology.globalBest(_pop); } private: + //! @param eoTopology < POT > & topology eoTopology < POT > & topology; }; diff --git a/trunk/paradiseo-peo/src/peoPopEval.h b/trunk/paradiseo-peo/src/peoPopEval.h index bcd391b90..f6440a885 100644 --- a/trunk/paradiseo-peo/src/peoPopEval.h +++ b/trunk/paradiseo-peo/src/peoPopEval.h @@ -1,9 +1,9 @@ /* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 +* (C) OPAC Team, LIFL, 2002-2008 * -* Sebastien Cahon, Alexandru-Adrian Tantar +* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -45,12 +45,11 @@ #include "peoAggEvalFunc.h" #include "peoNoAggEvalFunc.h" - -//! Parallel evaluation functor wrapper. - -//! The peoPopEval represents a wrapper for creating a functor capable of applying in parallel -//! an EO-derived evaluation functor. The class offers the possibility of chosing between a single-function evaluation -//! and an aggregate evaluation function, including several sub-evalution functions. +//! @class peoPopEval +//! @brief Parallel evaluation functor wrapper +//! @see Service eoPopEvalFunc +//! @version 1.2 +//! @date 2006 template< class EOT > class peoPopEval : public Service, public eoPopEvalFunc { @@ -72,6 +71,10 @@ template< class EOT > class peoPopEval : public Service, public eoPopEvalFunc& __pop - population to be evaluated by applying the evaluation functor specified in the constructor. void operator()(eoPop< EOT >& __pop); + + //! @brief Operator ()( eoPop< EOT >& __dummy, eoPop< EOT >& __pop ) + //! @param eoPop< EOT >& __dummy + //! @param eoPop< EOT >& __pop void operator()( eoPop< EOT >& __dummy, eoPop< EOT >& __pop ); //! Auxiliary function for transferring data between the process requesting an evaluation operation and the process that @@ -103,23 +106,25 @@ template< class EOT > class peoPopEval : public Service, public eoPopEvalFunc* >& funcs + //! @param std :: vector< eoEvalFunc < EOT >* > one_func + //! @param peoAggEvalFunc< EOT >& merge_eval + //! @param peoNoAggEvalFunc< EOT > no_merge_eval + //! @param std :: queue< EOT* >tasks + //! @param std :: map< EOT*, std :: pair< unsigned, unsigned > > progression + //! @param unsigned num_func + //! @param EOT sol + //! @param EOT *ad_sol + //! @param unsigned total const std :: vector< eoEvalFunc < EOT >* >& funcs; std :: vector< eoEvalFunc < EOT >* > one_func; - peoAggEvalFunc< EOT >& merge_eval; peoNoAggEvalFunc< EOT > no_merge_eval; - std :: queue< EOT* >tasks; - std :: map< EOT*, std :: pair< unsigned, unsigned > > progression; - unsigned num_func; - EOT sol; - EOT *ad_sol; - unsigned total; }; diff --git a/trunk/paradiseo-peo/src/peoSyncIslandMig.h b/trunk/paradiseo-peo/src/peoSyncIslandMig.h index 0f51809ab..7c12df50c 100644 --- a/trunk/paradiseo-peo/src/peoSyncIslandMig.h +++ b/trunk/paradiseo-peo/src/peoSyncIslandMig.h @@ -3,7 +3,7 @@ * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 * (C) OPAC Team, LIFL, 2002-2007 * -* Sebastien Cahon, Alexandru-Adrian Tantar +* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, @@ -63,103 +63,23 @@ #include "rmc/mpi/synchron.h" -//! Class providing the basis for the synchronous island migration model. - -//! The peoSyncIslandMig class offers the elementary basis for implementating a -//! synchronous island migration model - requires the specification of several basic -//! parameters, i.e. frequency of the migrations, selection and replacement strategies, -//! a topological model and the source and destination population for the migrating individuals. -//! The main difference as opposed to the asynchronous migration model is the synchronization step -//! performed after selecting and sending the emigrant individuals. -//! -//! The migration operator is called at the end of each generation of an evolutionary algorithms -//! as a checkpoint object - the following code exposes the structure of a classic evolutionary algorithm: -//! -//! -//! -//! -//! -//! -//! -//! -//!
do {    
         select( population, offsprings );   // select the offsprings from the current population
         transform( offsprings );   // crossover and mutation operators are applied on the selected offsprings
         evaluate( offsprings );   // evaluation step of the resulting offspring
         replace( population, offsprings );   // replace the individuals in the current population whith individuals from the offspring population, according to a specified replacement strategy
} while ( eaCheckpointContinue( population ) );   // checkpoint operators are applied on the current population, including the migration operator, if any specified
-//! -//! Constructing a synchronous island migration model requires having defined (1) a topological migration model, -//! (2) the control parameters of the migration process, (3) a checkpoint object associated with an evolutionary algorithm, -//! and (4) an owner object must be set. The owner object must be derived from the Runner class (for example -//! a peoEA object represents a possible owner). -//! A simple example is offered bellow: -//! -//!
    -//!
  1. topological model to be followed when performing migrations:
    -//!
    -//! -//! -//!
    RingTopology migTopology;   // a simple ring topological model - each island communicates with two other islands
    -//!
  2. -//! -//!
  3. the continuation criterion, selection and replacement strategy etc. are defined:
    -//!
    -//! -//! -//! -//! -//! -//! -//! -//! -//! -//!
    eoPop< EOT > population( POP_SIZE, popInitializer );   // population of individuals to be used for the evolutionary algorithm
       
    eoRandomSelect< EOT > migSelectStrategy;   // selection strategy - in this case a random selection is applied
    eoSelectNumber< EOT > migSelect( migSelectStrategy, MIG_SIZE );   // number of individuals to be selected using the specified strategy
    eoPlusReplacement< EOT > migReplace;   // immigration strategy - the worse individuals in the destination population are replaced by the immigrant individuals
       
    peoSyncIslandMig< EOT > syncMigration( -//!
             MIG_FREQ, migSelect, migReplace, migTopology, -//!
             population, population -//!
    );  
    // synchronous migration object - the emigrant individuals are selected from the same from population in which the immigrant individuals are being integrated
    -//!
  4. -//! -//!
  5. creation of a checkpoint object as part of the definition of an evolutionary algoritm (details of th EA not given as being out of scope):
    -//!
    -//! -//! -//! -//! -//! -//! -//! -//!
    ...    
    eoGenContinue< EOT > eaCont( NUM_GEN );   // the evolutionary algorithm will stop after NUM_GEN generations
    eoCheckPoint< EOT > eaCheckpointContinue( eaCont );   // number of individuals to be selected using the specified strategy
    ...    
    eaCheckpointContinue.add( syncMigration );   // adding the migration operator as checkpoint element
    ...    
    -//!
  6. -//! -//!
  7. definition of an owner evolutionary algorithm (an object inheriting the Runner class):
    -//!
    -//! -//! -//! -//! -//!
    peoEA< EOT > eaAlg( eaCheckpointContinue, eaPopEval, eaSelect, eaTransform, eaReplace);   // evolutionary algorithm having as checkpoint the eaCheckpointContinue object defined above
    syncMigration.setOwner( eaAlg );   // setting the evolutionary algorithm as owner of the migration object
    eaAlg( population );   // applying the evolutionary algorithm on a given population
    -//!
  8. -//!
-//! -//! The source and the destination population for the migration object were specified as being the same, in step no. 2, -//! as we are usually interested in selecting the emigrants and integrating the immigrant individuals from and in, respectively, one unique -//! population, iteratively evolved by an evolutionary algorithm. There is no restriction in having two distinct populations -//! as source and destination for the emigrant and immigrant individuals respectively. -//! -//! The above steps only create a synchronous migration object associated to an evolutionary algorithm. The creation of several -//! islands requires the reiteration of the steps 2 through 4 for creating distinct algorithms, with distinct populations and -//! the associated distinctly parametrized migration objects. The interconnecting element is the underlying topology, defined at step 1 -//! (the same C++ migTopology object has to be passed as parameter for all the migration objects, in order to interconnect them). +//! @class peoSyncIslandMig +//! @brief Specific class for a synchronous migration +//! @see Cooperative eoUpdater +//! @version 2.0 +//! @date january 2008 template< class EOT, class TYPE > class peoSyncIslandMig : public Cooperative, public eoUpdater { public: - //! Constructor for the peoSyncIslandMig class; the characteristics of the migration model are defined - //! through the specified parameters - out of the box objects provided in EO, etc., or custom, derived objects may be passed as parameters. - //! - //! @param unsigned __frequency - frequency of the migrations - the migrations occur periodically; - //! @param eoSelect< EOT >& __select - selection strategy to be applied for constructing a list of emigrant individuals out of the source population; - //! @param eoReplacement< EOT >& __replace - replacement strategy used for integrating the immigrant individuals in the destination population; - //! @param Topology& __topology - topological model to be followed when performing migrations; - //! @param eoPop< EOT >& __source - source population from which the emigrant individuals are selected; - //! @param eoPop< EOT >& __destination - destination population in which the immigrant population are integrated. + //! @brief Constructor + //! @param unsigned __frequency + //! @param selector & __select + //! @param replacement & __replace + //! @param Topology& __topology + //! @param peoData & __source + //! @param eoData & __destination peoSyncIslandMig( unsigned __frequency, selector & __select, @@ -169,32 +89,23 @@ template< class EOT, class TYPE > class peoSyncIslandMig : public Cooperative, peoData & __destination ); - //! Function operator to be called as checkpoint for performing the migration step. The emigrant individuals are selected - //! from the source population and sent to the next island (defined by the topology object) while the immigrant - //! individuals are integrated in the destination population. There is no need to explicitly call the function - the - //! wrapper checkpoint object (please refer to the above example) will perform the call when required. + //! @brief operator void operator()(); - - //! Auxiliary function dealing with sending the emigrant individuals. There is no need to explicitly call the function. + //! @brief Function realizing packages void pack(); - //! Auxiliary function dealing with receiving immigrant individuals. There is no need to explicitly call the function. + //! @brief Function reconstituting packages void unpack(); - //! Auxiliary function dealing with the packing of synchronization requests. There is no need to explicitly call the function. + //! @brief Function packSynchronizeReq void packSynchronizeReq(); - - //! Auxiliary function dealing with migration notifications. There is no need to explicitly call the function. + //! @brief Function notifySending void notifySending(); - - //! Auxiliary function dealing with migration notifications. There is no need to explicitly call the function. + //! @brief Function notifyReceiving void notifyReceiving(); - - //! Auxiliary function dealing with synchronizing runners for migrations. There is no need to explicitly call the function. + //! @brief notifySendingSyncReq void notifySendingSyncReq(); - - //! Auxiliary function for notifying the synchronization of the runners involved in migration. + //! @brief notifySynchronized void notifySynchronized(); - private: void emigrate(); @@ -202,22 +113,32 @@ template< class EOT, class TYPE > class peoSyncIslandMig : public Cooperative, private: - - eoSyncContinue cont; // continuator - selector & select; // the selection strategy - replacement & replace; // the replacement strategy - Topology& topology; // the neighboring topology + //! @param eoSyncContinue cont + //! @param selector & select + //! @param replacement & replace + //! @param Topology& topology + //! @param peoData & source + //! @param peoData & destination + //! @param std :: queue< TYPE > imm + //! @param std :: queue< TYPE > em + //! @param std :: queue< Cooperative* > coop_em + //! @param sem_t sync + //! @param bool explicitPassive + //! @param bool standbyMigration + //! @param std :: vector< Cooperative* > in, out, all + //! @param unsigned nbMigrations + eoSyncContinue cont; + selector & select; + replacement & replace; + Topology& topology; peoData & source; peoData & destination; std :: queue< TYPE > imm; std :: queue< TYPE > em; std :: queue< Cooperative* > coop_em; - sem_t sync; - bool explicitPassive; bool standbyMigration; - std :: vector< Cooperative* > in, out, all; unsigned nbMigrations; }; diff --git a/trunk/paradiseo-peo/src/peoTransform.h b/trunk/paradiseo-peo/src/peoTransform.h index a1035a780..7d5a3f4d4 100644 --- a/trunk/paradiseo-peo/src/peoTransform.h +++ b/trunk/paradiseo-peo/src/peoTransform.h @@ -45,49 +45,63 @@ extern int getNodeRank(); - +//! @class peoTransform +//! @brief Class for a parallel transform +//! @see Service eoTransform +//! @version 1.1 +//! @date january 2008 template< class EOT > class peoTransform : public Service, public eoTransform< EOT > { public: + //! @brief Constructor + //! @param eoQuadOp< EOT >& __cross + //! @param double __cross_rate + //! @param eoMonOp< EOT >& __mut + //! @param double __mut_rate peoTransform( - eoQuadOp< EOT >& __cross, double __cross_rate, eoMonOp< EOT >& __mut, double __mut_rate ); + //! @brief Operator + //! @param eoPop< EOT >& __pop void operator()( eoPop< EOT >& __pop ); - + //! @brief Function realizing packages of data void packData(); - + //! @brief Function reconstituting packages of data void unpackData(); - + //! @brief Function which executes the algorithm void execute(); - + //! @brief Function realizing packages of the result void packResult(); - + //! @brief Function reconstituting packages of result void unpackResult(); - + //! @brief Function notifySendingData void notifySendingData(); + //! @brief Function notifySendingAllResourceRequests void notifySendingAllResourceRequests(); private: - + //! @param eoQuadOp< EOT >& cross + //! @param double cross_rate + //! @param eoMonOp< EOT >& mut + //! @param double mut_rate + //! @param unsigned idx + //! @param eoPop< EOT >* pop + //! @param EOT father + //! @param mother + //! @param unsigned num_term eoQuadOp< EOT >& cross; double cross_rate; - eoMonOp< EOT >& mut; double mut_rate; - unsigned idx; - eoPop< EOT >* pop; - EOT father, mother; - unsigned num_term; }; diff --git a/trunk/paradiseo-peo/src/peoWorstPositionReplacement.h b/trunk/paradiseo-peo/src/peoWorstPositionReplacement.h index 7925a5ab7..8f37e025f 100644 --- a/trunk/paradiseo-peo/src/peoWorstPositionReplacement.h +++ b/trunk/paradiseo-peo/src/peoWorstPositionReplacement.h @@ -45,13 +45,21 @@ #include #include -template -class peoWorstPositionReplacement : public eoReplacement +//! @class peoWorstPositionReplacement +//! @brief Specific class for a replacement of a population of a PSO +//! @see eoReplacement +//! @version 1.1 +//! @date october 2007 +template class peoWorstPositionReplacement : public eoReplacement { public: + //! @brief constructor peoWorstPositionReplacement() {} + //! @brief operator + //! @param eoPop& _dest + //! @param eoPop& _source void operator()(eoPop& _dest, eoPop& _source) { unsigned ind=0; diff --git a/trunk/paradiseo-peo/src/peoWrapper.h b/trunk/paradiseo-peo/src/peoWrapper.h index e1d210328..bb2479830 100644 --- a/trunk/paradiseo-peo/src/peoWrapper.h +++ b/trunk/paradiseo-peo/src/peoWrapper.h @@ -1,7 +1,7 @@ /* * * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 -* (C) OPAC Team, LIFL, 2002-2007 +* (C) OPAC Team, LIFL, 2002-2008 * * Sebastien Cahon, Alexandru-Adrian Tantar * @@ -41,36 +41,49 @@ #include "core/runner.h" #include "core/peo_debug.h" - - - +//! @class peoWrapper +//! @brief Specific class for wrapping +//! @see Runner +//! @version 1.1 +//! @date december 2007 class peoWrapper : public Runner { public: + //! @brief constructor + //! @param AlgorithmType& externalAlgorithm template< typename AlgorithmType > peoWrapper( AlgorithmType& externalAlgorithm ) : algorithm( new Algorithm< AlgorithmType, void >( externalAlgorithm ) ) {} + //! @brief constructor + //! @param AlgorithmType& externalAlgorithm + //! @param AlgorithmDataType& externalData template< typename AlgorithmType, typename AlgorithmDataType > peoWrapper( AlgorithmType& externalAlgorithm, AlgorithmDataType& externalData ) : algorithm( new Algorithm< AlgorithmType, AlgorithmDataType >( externalAlgorithm, externalData ) ) {} + //! @brief constructor + //! @param AlgorithmReturnType& (*externalAlgorithm)() template< typename AlgorithmReturnType > peoWrapper( AlgorithmReturnType& (*externalAlgorithm)() ) : algorithm( new FunctionAlgorithm< AlgorithmReturnType, void >( externalAlgorithm ) ) {} + //! @brief constructor + //! @param AlgorithmReturnType& (*externalAlgorithm)( AlgorithmDataType& ) + //! @param AlgorithmDataType& externalData template< typename AlgorithmReturnType, typename AlgorithmDataType > peoWrapper( AlgorithmReturnType& (*externalAlgorithm)( AlgorithmDataType& ), AlgorithmDataType& externalData ) : algorithm( new FunctionAlgorithm< AlgorithmReturnType, AlgorithmDataType >( externalAlgorithm, externalData ) ) {} - + + //! @brief destructor ~peoWrapper() { - delete algorithm; } + //! @brief function run void run() { algorithm->operator()(); @@ -153,7 +166,7 @@ class peoWrapper : public Runner }; private: - + //! @param AbstractAlgorithm* algorithm AbstractAlgorithm* algorithm; };