new style peo

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1021 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
canape 2008-02-29 14:08:59 +00:00
commit edb6d65a7b
34 changed files with 407 additions and 386 deletions

View file

@ -80,10 +80,10 @@ COMM_ID getKey (const Communicable * __comm)
} }
void Communicable :: lock () void Communicable :: lock ()
{ {
sem_wait (& sem_lock); sem_wait (& sem_lock);
} }
void Communicable :: unlock () void Communicable :: unlock ()
{ {

View file

@ -1,4 +1,4 @@
/* /*
* <complete_topo.cpp> * <complete_topo.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008 * (C) OPAC Team, LIFL, 2002-2008
@ -38,16 +38,19 @@
#include "complete_topo.h" #include "complete_topo.h"
void CompleteTopology :: setNeighbors (Cooperative * __mig, void CompleteTopology :: setNeighbors (Cooperative * __mig,
std :: vector <Cooperative *> & __from, std :: vector <Cooperative *> & __from,
std :: vector <Cooperative *> & __to) { std :: vector <Cooperative *> & __to)
{
__from.clear () ; __from.clear () ;
__to.clear () ; __to.clear () ;
for (unsigned i = 0; i < mig.size (); i ++) { for (unsigned i = 0; i < mig.size (); i ++)
if (mig [i] != __mig) { {
__from.push_back (mig [i]); if (mig [i] != __mig)
__to.push_back (mig [i]); {
} __from.push_back (mig [i]);
__to.push_back (mig [i]);
}
} }
} }

View file

@ -1,4 +1,4 @@
/* /*
* <complete_topo.h> * <complete_topo.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008 * (C) OPAC Team, LIFL, 2002-2008
@ -39,13 +39,14 @@
#include "topology.h" #include "topology.h"
class CompleteTopology : public Topology { class CompleteTopology : public Topology
{
public : public :
void setNeighbors (Cooperative * __mig, void setNeighbors (Cooperative * __mig,
std :: vector <Cooperative *> & __from, std :: vector <Cooperative *> & __from,
std :: vector <Cooperative *> & __to); std :: vector <Cooperative *> & __to);
}; };
#endif #endif

View file

@ -1,4 +1,4 @@
/* /*
* <random_topo.cpp> * <random_topo.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008 * (C) OPAC Team, LIFL, 2002-2008
@ -40,16 +40,19 @@
#include <utils/eoRNG.h> #include <utils/eoRNG.h>
void RandomTopology :: setNeighbors (Cooperative * __mig, void RandomTopology :: setNeighbors (Cooperative * __mig,
std :: vector <Cooperative *> & __from, std :: vector <Cooperative *> & __from,
std :: vector <Cooperative *> & __to) { std :: vector <Cooperative *> & __to)
{
__from.clear () ; __from.clear () ;
__to.clear () ; __to.clear () ;
for (unsigned i = 0; i < mig.size (); i ++) { for (unsigned i = 0; i < mig.size (); i ++)
if (mig [i] != __mig && rng.uniform() < 0.5 ) { {
__from.push_back (mig [i]); if (mig [i] != __mig && rng.uniform() < 0.5 )
__to.push_back (mig [i]); {
} __from.push_back (mig [i]);
__to.push_back (mig [i]);
}
} }
} }

View file

@ -1,4 +1,4 @@
/* /*
* <random_topo.h> * <random_topo.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008 * (C) OPAC Team, LIFL, 2002-2008
@ -39,13 +39,14 @@
#include "topology.h" #include "topology.h"
class RandomTopology : public Topology { class RandomTopology : public Topology
{
public : public :
void setNeighbors (Cooperative * __mig, void setNeighbors (Cooperative * __mig,
std :: vector <Cooperative *> & __from, std :: vector <Cooperative *> & __from,
std :: vector <Cooperative *> & __to); std :: vector <Cooperative *> & __to);
}; };
#endif #endif

View file

@ -1,4 +1,4 @@
/* /*
* <star_topo.cpp> * <star_topo.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008 * (C) OPAC Team, LIFL, 2002-2008
@ -40,30 +40,36 @@
StarTopology :: StarTopology () : center( NULL ) {} StarTopology :: StarTopology () : center( NULL ) {}
void StarTopology :: setNeighbors (Cooperative * __mig, void StarTopology :: setNeighbors (Cooperative * __mig,
std :: vector <Cooperative *> & __from, std :: vector <Cooperative *> & __from,
std :: vector <Cooperative *> & __to) { std :: vector <Cooperative *> & __to)
{
assert( center != NULL ); assert( center != NULL );
__from.clear () ; __from.clear () ;
__to.clear () ; __to.clear () ;
if ( __mig == center ) { if ( __mig == center )
{
for (unsigned i = 0; i < mig.size (); i ++) { for (unsigned i = 0; i < mig.size (); i ++)
if (mig [i] != center) { {
__from.push_back (mig [i]); if (mig [i] != center)
__to.push_back (mig [i]); {
} __from.push_back (mig [i]);
__to.push_back (mig [i]);
}
}
}
else
{
__from.push_back (center);
__to.push_back (center);
} }
}
else {
__from.push_back (center);
__to.push_back (center);
}
} }
void StarTopology :: setCenter (Cooperative& __center) { void StarTopology :: setCenter (Cooperative& __center)
{
center = &__center; center = &__center;
} }

View file

@ -1,4 +1,4 @@
/* /*
* <star_topo.h> * <star_topo.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008 * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008 * (C) OPAC Team, LIFL, 2002-2008
@ -39,21 +39,22 @@
#include "topology.h" #include "topology.h"
class StarTopology : public Topology { class StarTopology : public Topology
{
public : public :
StarTopology (); StarTopology ();
void setNeighbors (Cooperative * __mig, void setNeighbors (Cooperative * __mig,
std :: vector <Cooperative *> & __from, std :: vector <Cooperative *> & __from,
std :: vector <Cooperative *> & __to); std :: vector <Cooperative *> & __to);
void setCenter (Cooperative& __center); void setCenter (Cooperative& __center);
private : private :
Cooperative* center; Cooperative* center;
}; };
#endif #endif

View file

@ -43,10 +43,10 @@ Topology :: ~ Topology ()
} }
void Topology :: add (Cooperative & __mig) void Topology :: add (Cooperative & __mig)
{ {
mig.push_back (& __mig) ; mig.push_back (& __mig) ;
} }
Topology :: operator std :: vector <Cooperative *>& () Topology :: operator std :: vector <Cooperative *>& ()
{ {

View file

@ -57,7 +57,7 @@
//! @class peoAsyncIslandMig //! @class peoAsyncIslandMig
//! @brief Specific class for a asynchronous migration //! @brief Specific class for a asynchronous migration
//! @see Cooperative eoUpdater //! @see Cooperative eoUpdater
//! @version 2.0 //! @version 2.0
//! @date january 2008 //! @date january 2008
@ -67,18 +67,18 @@ template< class TYPESELECT, class TYPEREPLACE > class peoAsyncIslandMig : public
public: public:
//! @brief Constructor //! @brief Constructor
//! @param continuator & __cont //! @param continuator & __cont
//! @param selector <TYPE> & __select //! @param selector <TYPE> & __select
//! @param replacement <TYPE> & __replace //! @param replacement <TYPE> & __replace
//! @param Topology& __topology //! @param Topology& __topology
peoAsyncIslandMig( peoAsyncIslandMig(
continuator & __cont, continuator & __cont,
selector <TYPESELECT> & __select, selector <TYPESELECT> & __select,
replacement <TYPEREPLACE> & __replace, replacement <TYPEREPLACE> & __replace,
Topology& __topology Topology& __topology
); );
//! @brief operator //! @brief operator
void operator()(); void operator()();
//! @brief Function realizing packages //! @brief Function realizing packages
void pack(); void pack();
@ -88,23 +88,23 @@ template< class TYPESELECT, class TYPEREPLACE > class peoAsyncIslandMig : public
void packSynchronizeReq(); void packSynchronizeReq();
private: private:
//! @brief Function which sends some emigrants //! @brief Function which sends some emigrants
void emigrate(); void emigrate();
//! @brief Function which receives some immigrants //! @brief Function which receives some immigrants
void immigrate(); void immigrate();
private: private:
//! @param continuator & cont //! @param continuator & cont
//! @param selector <TYPESELECT> & select //! @param selector <TYPESELECT> & select
//! @param replacement <TYPEREPLACE> & replace //! @param replacement <TYPEREPLACE> & replace
//! @param Topology& topology //! @param Topology& topology
//! @param std :: queue< TYPEREPLACE > imm //! @param std :: queue< TYPEREPLACE > imm
//! @param std :: queue< TYPESELECT > em //! @param std :: queue< TYPESELECT > em
//! @param std :: queue< Cooperative* > coop_em //! @param std :: queue< Cooperative* > coop_em
continuator & cont; continuator & cont;
selector <TYPESELECT> & select; selector <TYPESELECT> & select;
replacement <TYPEREPLACE> & replace; replacement <TYPEREPLACE> & replace;
Topology& topology; Topology& topology;
std :: queue< TYPEREPLACE > imm; std :: queue< TYPEREPLACE > imm;
std :: queue< TYPESELECT > em; std :: queue< TYPESELECT > em;
std :: queue< Cooperative* > coop_em; std :: queue< Cooperative* > coop_em;
@ -189,8 +189,8 @@ template< class TYPESELECT , class TYPEREPLACE> void peoAsyncIslandMig< TYPESELE
if (! cont.check()) if (! cont.check())
{ {
emigrate(); emigrate();
immigrate(); immigrate();
} }
} }

View file

@ -51,9 +51,9 @@
class continuator class continuator
{ {
public: public:
//! @brief Virtual function of check //! @brief Virtual function of check
//! @return true if the algorithm must continue //! @return true if the algorithm must continue
virtual bool check()=0; virtual bool check()=0;
//! @brief Virtual destructor //! @brief Virtual destructor
virtual ~continuator(){} virtual ~continuator(){}
@ -69,22 +69,22 @@ template < class EOT> class eoContinuator : public continuator
{ {
public: public:
//! @brief Constructor //! @brief Constructor
//! @param eoContinue<EOT> & //! @param eoContinue<EOT> &
//! @param eoPop<EOT> & //! @param eoPop<EOT> &
eoContinuator(eoContinue<EOT> & _cont, const eoPop<EOT> & _pop): cont (_cont), pop(_pop) eoContinuator(eoContinue<EOT> & _cont, const eoPop<EOT> & _pop): cont (_cont), pop(_pop)
{} {}
//! @brief Virtual function of check //! @brief Virtual function of check
//! @return false if the algorithm must continue //! @return false if the algorithm must continue
virtual bool check() virtual bool check()
{ {
return cont(pop); return cont(pop);
} }
protected: protected:
//! @param eoContinue<EOT> & //! @param eoContinue<EOT> &
//! @param eoPop<EOT> & //! @param eoPop<EOT> &
eoContinue<EOT> & cont ; eoContinue<EOT> & cont ;
const eoPop<EOT> & pop; const eoPop<EOT> & pop;
}; };
@ -101,9 +101,9 @@ template < class EOT> class eoContinuator : public continuator
template < class TYPE> class selector template < class TYPE> class selector
{ {
public: public:
//! @brief Virtual operator on the template type //! @brief Virtual operator on the template type
//! @param TYPE & //! @param TYPE &
virtual void operator()(TYPE &)=0; virtual void operator()(TYPE &)=0;
//! @brief Virtual destructor //! @brief Virtual destructor
virtual ~selector(){} virtual ~selector(){}
@ -119,16 +119,16 @@ template < class EOT, class TYPE> class eoSelector : public selector< TYPE >
{ {
public: public:
//! @brief Constructor //! @brief Constructor
//! @param eoSelectOne<EOT> & //! @param eoSelectOne<EOT> &
//! @param unsigned _nb_select //! @param unsigned _nb_select
//! @param TYPE & _source (with TYPE which is the template type) //! @param TYPE & _source (with TYPE which is the template type)
eoSelector(eoSelectOne<EOT> & _select, unsigned _nb_select, const TYPE & _source): selector (_select), nb_select(_nb_select), source(_source) eoSelector(eoSelectOne<EOT> & _select, unsigned _nb_select, const TYPE & _source): selector (_select), nb_select(_nb_select), source(_source)
{} {}
//! @brief Virtual operator on the template type //! @brief Virtual operator on the template type
//! @param TYPE & _dest //! @param TYPE & _dest
virtual void operator()(TYPE & _dest) virtual void operator()(TYPE & _dest)
{ {
size_t target = static_cast<size_t>(nb_select); size_t target = static_cast<size_t>(nb_select);
_dest.resize(target); _dest.resize(target);
@ -137,9 +137,9 @@ template < class EOT, class TYPE> class eoSelector : public selector< TYPE >
} }
protected: protected:
//! @param eoSelectOne<EOT> & //! @param eoSelectOne<EOT> &
//! @param unsigned nb_select //! @param unsigned nb_select
//! @param TYPE & source //! @param TYPE & source
eoSelectOne<EOT> & selector ; eoSelectOne<EOT> & selector ;
unsigned nb_select; unsigned nb_select;
const TYPE & source; const TYPE & source;
@ -157,8 +157,8 @@ template < class EOT, class TYPE> class eoSelector : public selector< TYPE >
template < class TYPE> class replacement template < class TYPE> class replacement
{ {
public: public:
//! @brief Virtual operator on the template type //! @brief Virtual operator on the template type
//! @param TYPE & //! @param TYPE &
virtual void operator()(TYPE &)=0; virtual void operator()(TYPE &)=0;
//! @brief Virtual destructor //! @brief Virtual destructor
virtual ~replacement(){} virtual ~replacement(){}
@ -173,22 +173,22 @@ template < class TYPE> class replacement
template < class EOT, class TYPE> class eoReplace : public replacement< TYPE > template < class EOT, class TYPE> class eoReplace : public replacement< TYPE >
{ {
public: public:
//! @brief Constructor //! @brief Constructor
//! @param eoReplacement<EOT> & //! @param eoReplacement<EOT> &
//! @param TYPE & _destination (with TYPE which is the template type) //! @param TYPE & _destination (with TYPE which is the template type)
eoReplace(eoReplacement<EOT> & _replace, TYPE & _destination): replace(_replace), destination(_destination) eoReplace(eoReplacement<EOT> & _replace, TYPE & _destination): replace(_replace), destination(_destination)
{} {}
//! @brief Virtual operator on the template type //! @brief Virtual operator on the template type
//! @param TYPE & _source //! @param TYPE & _source
virtual void operator()(TYPE & _source) virtual void operator()(TYPE & _source)
{ {
replace(destination, _source); replace(destination, _source);
} }
protected: protected:
//! @param eoReplacement<EOT> & //! @param eoReplacement<EOT> &
//! @param TYPE & destination //! @param TYPE & destination
eoReplacement<EOT> & replace; eoReplacement<EOT> & replace;
TYPE & destination; TYPE & destination;
}; };
@ -207,14 +207,14 @@ class eoSyncContinue: public continuator
{ {
public: public:
//! @brief Constructor //! @brief Constructor
//! @param unsigned __period //! @param unsigned __period
//! @param unsigned __init_counter //! @param unsigned __init_counter
eoSyncContinue (unsigned __period, unsigned __init_counter = 0): period (__period),counter (__init_counter) eoSyncContinue (unsigned __period, unsigned __init_counter = 0): period (__period),counter (__init_counter)
{} {}
//! @brief Virtual function of check //! @brief Virtual function of check
//! @return true if the algorithm must continue //! @return true if the algorithm must continue
virtual bool check() virtual bool check()
{ {
return ((++ counter) % period) != 0 ; return ((++ counter) % period) != 0 ;
@ -222,8 +222,8 @@ class eoSyncContinue: public continuator
private: private:
//! @param unsigned period //! @param unsigned period
//! @param unsigned counter //! @param unsigned counter
unsigned period; unsigned period;
unsigned counter; unsigned counter;
}; };

View file

@ -50,21 +50,21 @@ template< class EOT, class FitT = typename EOT::Fitness, class FunctionArg = con
struct peoEvalFunc: public eoEvalFunc<EOT> struct peoEvalFunc: public eoEvalFunc<EOT>
{ {
//! @brief Constructor //! @brief Constructor
//! @param FitT (* _eval)( FunctionArg ) //! @param FitT (* _eval)( FunctionArg )
peoEvalFunc( FitT (* _eval)( FunctionArg ) ) peoEvalFunc( FitT (* _eval)( FunctionArg ) )
: eoEvalFunc<EOT>(), evalFunc( _eval ) : eoEvalFunc<EOT>(), evalFunc( _eval )
{}; {};
//! @brief Virtual operator //! @brief Virtual operator
//! @param EOT & _peo //! @param EOT & _peo
virtual void operator() ( EOT & _peo ) virtual void operator() ( EOT & _peo )
{ {
_peo.fitness((*evalFunc)( _peo )); _peo.fitness((*evalFunc)( _peo ));
}; };
private: private:
//! @param FitT (* evalFunc )( FunctionArg ) //! @param FitT (* evalFunc )( FunctionArg )
FitT (* evalFunc )( FunctionArg ); FitT (* evalFunc )( FunctionArg );
}; };

View file

@ -71,10 +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. //! @param eoPop< EOT >& __pop - population to be evaluated by applying the evaluation functor specified in the constructor.
void operator()(eoPop< EOT >& __pop); void operator()(eoPop< EOT >& __pop);
//! @brief Operator ()( eoPop< EOT >& __dummy, eoPop< EOT >& __pop ) //! @brief Operator ()( eoPop< EOT >& __dummy, eoPop< EOT >& __pop )
//! @param eoPop< EOT >& __dummy //! @param eoPop< EOT >& __dummy
//! @param eoPop< EOT >& __pop //! @param eoPop< EOT >& __pop
void operator()( eoPop< EOT >& __dummy, 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 //! Auxiliary function for transferring data between the process requesting an evaluation operation and the process that
@ -105,16 +105,16 @@ template< class EOT > class peoMoeoPopEval : public Service, public eoPopEvalFun
void notifySendingAllResourceRequests(); void notifySendingAllResourceRequests();
private: private:
//! @param std :: vector< eoEvalFunc < EOT >* >& funcs //! @param std :: vector< eoEvalFunc < EOT >* >& funcs
//! @param std :: vector< eoEvalFunc < EOT >* > one_func //! @param std :: vector< eoEvalFunc < EOT >* > one_func
//! @param peoAggEvalFunc< EOT >& merge_eval //! @param peoAggEvalFunc< EOT >& merge_eval
//! @param peoNoAggEvalFunc< EOT > no_merge_eval //! @param peoNoAggEvalFunc< EOT > no_merge_eval
//! @param std :: queue< EOT* >tasks //! @param std :: queue< EOT* >tasks
//! @param std :: map< EOT*, std :: pair< unsigned, unsigned > > progression //! @param std :: map< EOT*, std :: pair< unsigned, unsigned > > progression
//! @param unsigned num_func //! @param unsigned num_func
//! @param EOT sol //! @param EOT sol
//! @param EOT *ad_sol //! @param EOT *ad_sol
//! @param unsigned total //! @param unsigned total
const std :: vector< eoEvalFunc < EOT >* >& funcs; const std :: vector< eoEvalFunc < EOT >* >& funcs;
std :: vector< eoEvalFunc < EOT >* > one_func; std :: vector< eoEvalFunc < EOT >* > one_func;
peoAggEvalFunc< EOT >& merge_eval; peoAggEvalFunc< EOT >& merge_eval;

View file

@ -51,8 +51,8 @@ template < typename EntityType > class peoMultiStart : public Service
public: public:
//! @brief Constructor //! @brief Constructor
//! @param AlgorithmType& externalAlgorithm //! @param AlgorithmType& externalAlgorithm
template < typename AlgorithmType > peoMultiStart( AlgorithmType& externalAlgorithm ) template < typename AlgorithmType > peoMultiStart( AlgorithmType& externalAlgorithm )
{ {
singularAlgorithm = new Algorithm< AlgorithmType >( externalAlgorithm ); singularAlgorithm = new Algorithm< AlgorithmType >( externalAlgorithm );
@ -60,18 +60,18 @@ template < typename EntityType > class peoMultiStart : public Service
aggregationFunction = new NoAggregationFunction(); aggregationFunction = new NoAggregationFunction();
} }
//! @brief Constructor //! @brief Constructor
//! @param AlgorithmReturnType (*externalAlgorithm)( AlgorithmDataType& ) //! @param AlgorithmReturnType (*externalAlgorithm)( AlgorithmDataType& )
template < typename AlgorithmReturnType, typename AlgorithmDataType > peoMultiStart( AlgorithmReturnType (*externalAlgorithm)( AlgorithmDataType& ) ) template < typename AlgorithmReturnType, typename AlgorithmDataType > peoMultiStart( AlgorithmReturnType (*externalAlgorithm)( AlgorithmDataType& ) )
{ {
singularAlgorithm = new FunctionAlgorithm< AlgorithmReturnType, AlgorithmDataType >( externalAlgorithm ); singularAlgorithm = new FunctionAlgorithm< AlgorithmReturnType, AlgorithmDataType >( externalAlgorithm );
algorithms.push_back( singularAlgorithm ); algorithms.push_back( singularAlgorithm );
aggregationFunction = new NoAggregationFunction(); aggregationFunction = new NoAggregationFunction();
} }
//! @brief Constructor //! @brief Constructor
//! @param std::vector< AlgorithmType* >& externalAlgorithms //! @param std::vector< AlgorithmType* >& externalAlgorithms
//! @param AggregationFunctionType& externalAggregationFunction //! @param AggregationFunctionType& externalAggregationFunction
template < typename AlgorithmType, typename AggregationFunctionType > peoMultiStart( std::vector< AlgorithmType* >& externalAlgorithms, AggregationFunctionType& externalAggregationFunction ) template < typename AlgorithmType, typename AggregationFunctionType > peoMultiStart( std::vector< AlgorithmType* >& externalAlgorithms, AggregationFunctionType& externalAggregationFunction )
{ {
for ( unsigned int index = 0; index < externalAlgorithms.size(); index++ ) for ( unsigned int index = 0; index < externalAlgorithms.size(); index++ )
@ -81,9 +81,9 @@ template < typename EntityType > class peoMultiStart : public Service
aggregationFunction = new AggregationAlgorithm< AggregationFunctionType >( externalAggregationFunction ); aggregationFunction = new AggregationAlgorithm< AggregationFunctionType >( externalAggregationFunction );
} }
//! @brief Constructor //! @brief Constructor
//! @param std::vector< AlgorithmReturnType (*)( AlgorithmDataType& ) >& externalAlgorithms //! @param std::vector< AlgorithmReturnType (*)( AlgorithmDataType& ) >& externalAlgorithms
//! @param AggregationFunctionType& externalAggregationFunction //! @param AggregationFunctionType& externalAggregationFunction
template < typename AlgorithmReturnType, typename AlgorithmDataType, typename AggregationFunctionType > peoMultiStart( std::vector< AlgorithmReturnType (*)( AlgorithmDataType& ) >& externalAlgorithms, 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++ ) for ( unsigned int index = 0; index < externalAlgorithms.size(); index++ )
@ -93,16 +93,16 @@ template < typename EntityType > class peoMultiStart : public Service
aggregationFunction = new AggregationAlgorithm< AggregationFunctionType >( externalAggregationFunction ); aggregationFunction = new AggregationAlgorithm< AggregationFunctionType >( externalAggregationFunction );
} }
//! @brief Destructor //! @brief Destructor
~peoMultiStart() ~peoMultiStart()
{ {
for ( unsigned int index = 0; index < data.size(); index++ ) delete data[ index ]; for ( unsigned int index = 0; index < data.size(); index++ ) delete data[ index ];
for ( unsigned int index = 0; index < algorithms.size(); index++ ) delete algorithms[ index ]; for ( unsigned int index = 0; index < algorithms.size(); index++ ) delete algorithms[ index ];
delete aggregationFunction; delete aggregationFunction;
} }
//! @brief operator on the template type //! @brief operator on the template type
//! @param Type& externalData //! @param Type& externalData
template < typename Type > void operator()( Type& externalData ) template < typename Type > void operator()( Type& externalData )
{ {
for ( typename Type::iterator externalDataIterator = externalData.begin(); externalDataIterator != externalData.end(); externalDataIterator++ ) for ( typename Type::iterator externalDataIterator = externalData.begin(); externalDataIterator != externalData.end(); externalDataIterator++ )
@ -114,9 +114,9 @@ template < typename EntityType > class peoMultiStart : public Service
stop(); stop();
} }
//! @brief operator on the template type //! @brief operator on the template type
//! @param Type& externalDataBegin //! @param Type& externalDataBegin
//! @param Type& externalDataEnd //! @param Type& externalDataEnd
template < typename Type > void operator()( const Type& externalDataBegin, const Type& externalDataEnd ) template < typename Type > void operator()( const Type& externalDataBegin, const Type& externalDataEnd )
{ {
for ( Type externalDataIterator = externalDataBegin; externalDataIterator != externalDataEnd; externalDataIterator++ ) for ( Type externalDataIterator = externalDataBegin; externalDataIterator != externalDataEnd; externalDataIterator++ )
@ -128,32 +128,32 @@ template < typename EntityType > class peoMultiStart : public Service
stop(); stop();
} }
//! @brief Function realizing packages of data //! @brief Function realizing packages of data
void packData(); void packData();
//! @brief Function reconstituting packages of data //! @brief Function reconstituting packages of data
void unpackData(); void unpackData();
//! @brief Function which executes the algorithm //! @brief Function which executes the algorithm
void execute(); void execute();
//! @brief Function realizing packages of the result //! @brief Function realizing packages of the result
void packResult(); void packResult();
//! @brief Function reconstituting packages of result //! @brief Function reconstituting packages of result
void unpackResult(); void unpackResult();
//! @brief Function notifySendingData //! @brief Function notifySendingData
void notifySendingData(); void notifySendingData();
//! @brief Function notifySendingAllResourceRequests //! @brief Function notifySendingAllResourceRequests
void notifySendingAllResourceRequests(); void notifySendingAllResourceRequests();
private: private:
//! @param AbstractAlgorithm* singularAlgorithm //! @param AbstractAlgorithm* singularAlgorithm
//! @param std::vector< AbstractAlgorithm* > algorithms //! @param std::vector< AbstractAlgorithm* > algorithms
//! @param AbstractAggregationAlgorithm* aggregationFunction //! @param AbstractAggregationAlgorithm* aggregationFunction
//! @param EntityType entityTypeInstance //! @param EntityType entityTypeInstance
//! @param std::vector< AbstractDataType* > data //! @param std::vector< AbstractDataType* > data
//! @param unsigned idx //! @param unsigned idx
//! @param unsigned num_term //! @param unsigned num_term
//! @param unsigned dataIndex //! @param unsigned dataIndex
//! @param unsigned functionIndex //! @param unsigned functionIndex
template < typename Type > struct DataType; template < typename Type > struct DataType;
struct AbstractDataType struct AbstractDataType
{ {

View file

@ -55,27 +55,27 @@ template <class POT> class peoPSOSelect: public eoSelectOne<POT>
{ {
public: public:
//! @brief Constructor //! @brief Constructor
//! @param eoTopology < POT > & _topology //! @param eoTopology < POT > & _topology
peoPSOSelect(eoTopology < POT > & _topology):topology(_topology) peoPSOSelect(eoTopology < POT > & _topology):topology(_topology)
{} {}
//! @brief typedef : creation of Fitness //! @brief typedef : creation of Fitness
typedef typename PO < POT >::Fitness Fitness; typedef typename PO < POT >::Fitness Fitness;
//! @brief Virtual operator //! @brief Virtual operator
//! @param eoPop<POT>& _pop //! @param eoPop<POT>& _pop
//! @return POT& //! @return POT&
virtual const POT& operator()(const eoPop<POT>& _pop) virtual const POT& operator()(const eoPop<POT>& _pop)
{ {
return topology.globalBest(_pop); return topology.globalBest(_pop);
} }
private: private:
//! @param eoTopology < POT > & topology //! @param eoTopology < POT > & topology
eoTopology < POT > & topology; eoTopology < POT > & topology;
}; };
//! @class peoGlobalBestVelocity //! @class peoGlobalBestVelocity
//! @brief Specific class for a replacement thanks to the velocity migration of a population of a PSO //! @brief Specific class for a replacement thanks to the velocity migration of a population of a PSO
//! @see eoReplacement //! @see eoReplacement
@ -86,18 +86,18 @@ class peoGlobalBestVelocity : public eoReplacement<POT>
{ {
public: public:
//! @brief typedef : creation of VelocityType //! @brief typedef : creation of VelocityType
typedef typename POT::ParticleVelocityType VelocityType; typedef typename POT::ParticleVelocityType VelocityType;
//! @brief Constructor //! @brief Constructor
//! @param double & _c3 //! @param double & _c3
//! @param eoVelocity < POT > &_velocity //! @param eoVelocity < POT > &_velocity
peoGlobalBestVelocity( const double & _c3, eoVelocity < POT > &_velocity): c3 (_c3),velocity (_velocity) peoGlobalBestVelocity( const double & _c3, eoVelocity < POT > &_velocity): c3 (_c3),velocity (_velocity)
{} {}
//! @brief Virtual operator //! @brief Virtual operator
//! @param eoPop<POT>& _dest //! @param eoPop<POT>& _dest
//! @param eoPop<POT>& _source //! @param eoPop<POT>& _source
void operator()(eoPop<POT>& _dest, eoPop<POT>& _source) void operator()(eoPop<POT>& _dest, eoPop<POT>& _source)
{ {
@ -113,12 +113,12 @@ class peoGlobalBestVelocity : public eoReplacement<POT>
} }
protected: protected:
//! @param double & c3 //! @param double & c3
//! @param eoVelocity < POT > & velocity //! @param eoVelocity < POT > & velocity
const double & c3; const double & c3;
eoVelocity < POT > & velocity; eoVelocity < POT > & velocity;
}; };
//! @class peoWorstPositionReplacement //! @class peoWorstPositionReplacement
//! @brief Specific class for a replacement of a population of a PSO //! @brief Specific class for a replacement of a population of a PSO
//! @see eoReplacement //! @see eoReplacement
@ -127,13 +127,13 @@ class peoGlobalBestVelocity : public eoReplacement<POT>
template <class POT> class peoWorstPositionReplacement : public eoReplacement<POT> template <class POT> class peoWorstPositionReplacement : public eoReplacement<POT>
{ {
public: public:
//! @brief constructor //! @brief constructor
peoWorstPositionReplacement() peoWorstPositionReplacement()
{} {}
//! @brief operator //! @brief operator
//! @param eoPop<POT>& _dest //! @param eoPop<POT>& _dest
//! @param eoPop<POT>& _source //! @param eoPop<POT>& _source
void operator()(eoPop<POT>& _dest, eoPop<POT>& _source) void operator()(eoPop<POT>& _dest, eoPop<POT>& _source)
{ {
unsigned ind=0; unsigned ind=0;

View file

@ -71,10 +71,10 @@ template< class EOT > class peoPopEval : public Service, public eoPopEvalFunc<EO
//! //!
//! @param eoPop< EOT >& __pop - population to be evaluated by applying the evaluation functor specified in the constructor. //! @param eoPop< EOT >& __pop - population to be evaluated by applying the evaluation functor specified in the constructor.
void operator()(eoPop< EOT >& __pop); void operator()(eoPop< EOT >& __pop);
//! @brief Operator ()( eoPop< EOT >& __dummy, eoPop< EOT >& __pop ) //! @brief Operator ()( eoPop< EOT >& __dummy, eoPop< EOT >& __pop )
//! @param eoPop< EOT >& __dummy //! @param eoPop< EOT >& __dummy
//! @param eoPop< EOT >& __pop //! @param eoPop< EOT >& __pop
void operator()( eoPop< EOT >& __dummy, 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 //! Auxiliary function for transferring data between the process requesting an evaluation operation and the process that
@ -106,16 +106,16 @@ template< class EOT > class peoPopEval : public Service, public eoPopEvalFunc<EO
private: private:
//! @param std :: vector< eoEvalFunc < EOT >* >& funcs //! @param std :: vector< eoEvalFunc < EOT >* >& funcs
//! @param std :: vector< eoEvalFunc < EOT >* > one_func //! @param std :: vector< eoEvalFunc < EOT >* > one_func
//! @param peoAggEvalFunc< EOT >& merge_eval //! @param peoAggEvalFunc< EOT >& merge_eval
//! @param peoNoAggEvalFunc< EOT > no_merge_eval //! @param peoNoAggEvalFunc< EOT > no_merge_eval
//! @param std :: queue< EOT* >tasks //! @param std :: queue< EOT* >tasks
//! @param std :: map< EOT*, std :: pair< unsigned, unsigned > > progression //! @param std :: map< EOT*, std :: pair< unsigned, unsigned > > progression
//! @param unsigned num_func //! @param unsigned num_func
//! @param EOT sol //! @param EOT sol
//! @param EOT *ad_sol //! @param EOT *ad_sol
//! @param unsigned total //! @param unsigned total
const std :: vector< eoEvalFunc < EOT >* >& funcs; const std :: vector< eoEvalFunc < EOT >* >& funcs;
std :: vector< eoEvalFunc < EOT >* > one_func; std :: vector< eoEvalFunc < EOT >* > one_func;
peoAggEvalFunc< EOT >& merge_eval; peoAggEvalFunc< EOT >& merge_eval;
@ -153,23 +153,23 @@ template< class EOT > void peoPopEval< EOT >::operator()(eoPop< EOT >& __dummy,
template< class EOT > void peoPopEval< EOT >::operator()(eoPop< EOT >& __pop ) template< class EOT > void peoPopEval< EOT >::operator()(eoPop< EOT >& __pop )
{ {
if ( __pop.size() && (funcs.size() * __pop.size()) ) if ( __pop.size() && (funcs.size() * __pop.size()) )
{ {
for ( unsigned i = 0; i < __pop.size(); i++ ) for ( unsigned i = 0; i < __pop.size(); i++ )
{ {
__pop[ i ].fitness(typename EOT :: Fitness() ); __pop[ i ].fitness(typename EOT :: Fitness() );
progression[ &__pop[ i ] ].first = funcs.size() - 1; progression[ &__pop[ i ] ].first = funcs.size() - 1;
progression[ &__pop[ i ] ].second = funcs.size(); progression[ &__pop[ i ] ].second = funcs.size();
for ( unsigned j = 0; j < funcs.size(); j++ ) for ( unsigned j = 0; j < funcs.size(); j++ )
{ {
/* Queuing the 'invalid' solution and its associated owner */ /* Queuing the 'invalid' solution and its associated owner */
tasks.push( &__pop[ i ] ); tasks.push( &__pop[ i ] );
} }
} }
total = funcs.size() * __pop.size(); total = funcs.size() * __pop.size();
requestResourceRequest( funcs.size() * __pop.size() ); requestResourceRequest( funcs.size() * __pop.size() );
stop(); stop();
} }
} }

View file

@ -64,7 +64,7 @@
//! @class peoSyncIslandMig //! @class peoSyncIslandMig
//! @brief Specific class for a synchronous migration //! @brief Specific class for a synchronous migration
//! @see Cooperative eoUpdater //! @see Cooperative eoUpdater
//! @version 2.0 //! @version 2.0
//! @date january 2008 //! @date january 2008
@ -74,10 +74,10 @@ template< class TYPESELECT, class TYPEREPLACE > class peoSyncIslandMig : public
public: public:
//! @brief Constructor //! @brief Constructor
//! @param unsigned __frequency //! @param unsigned __frequency
//! @param selector <TYPESELECT> & __select //! @param selector <TYPESELECT> & __select
//! @param replacement <TYPEREPLACE> & __replace //! @param replacement <TYPEREPLACE> & __replace
//! @param Topology& __topology //! @param Topology& __topology
peoSyncIslandMig( peoSyncIslandMig(
unsigned __frequency, unsigned __frequency,
selector <TYPESELECT> & __select, selector <TYPESELECT> & __select,
@ -87,19 +87,19 @@ template< class TYPESELECT, class TYPEREPLACE > class peoSyncIslandMig : public
//! @brief operator //! @brief operator
void operator()(); void operator()();
//! @brief Function realizing packages //! @brief Function realizing packages
void pack(); void pack();
//! @brief Function reconstituting packages //! @brief Function reconstituting packages
void unpack(); void unpack();
//! @brief Function packSynchronizeReq //! @brief Function packSynchronizeReq
void packSynchronizeReq(); void packSynchronizeReq();
//! @brief Function notifySending //! @brief Function notifySending
void notifySending(); void notifySending();
//! @brief Function notifyReceiving //! @brief Function notifyReceiving
void notifyReceiving(); void notifyReceiving();
//! @brief notifySendingSyncReq //! @brief notifySendingSyncReq
void notifySendingSyncReq(); void notifySendingSyncReq();
//! @brief notifySynchronized //! @brief notifySynchronized
void notifySynchronized(); void notifySynchronized();
private: private:
@ -109,22 +109,22 @@ template< class TYPESELECT, class TYPEREPLACE > class peoSyncIslandMig : public
private: private:
//! @param eoSyncContinue cont //! @param eoSyncContinue cont
//! @param selector <TYPESELECT> & select //! @param selector <TYPESELECT> & select
//! @param replacement <TYPEREPLACE> & replace //! @param replacement <TYPEREPLACE> & replace
//! @param Topology& topology //! @param Topology& topology
//! @param std :: queue< TYPEREPLACE > imm //! @param std :: queue< TYPEREPLACE > imm
//! @param std :: queue< TYPESELECT > em //! @param std :: queue< TYPESELECT > em
//! @param std :: queue< Cooperative* > coop_em //! @param std :: queue< Cooperative* > coop_em
//! @param sem_t sync //! @param sem_t sync
//! @param bool explicitPassive //! @param bool explicitPassive
//! @param bool standbyMigration //! @param bool standbyMigration
//! @param std :: vector< Cooperative* > in, out, all //! @param std :: vector< Cooperative* > in, out, all
//! @param unsigned nbMigrations //! @param unsigned nbMigrations
eoSyncContinue cont; eoSyncContinue cont;
selector <TYPESELECT> & select; selector <TYPESELECT> & select;
replacement <TYPEREPLACE> & replace; replacement <TYPEREPLACE> & replace;
Topology& topology; Topology& topology;
std :: queue< TYPEREPLACE > imm; std :: queue< TYPEREPLACE > imm;
std :: queue< TYPESELECT > em; std :: queue< TYPESELECT > em;
std :: queue< Cooperative* > coop_em; std :: queue< Cooperative* > coop_em;

View file

@ -55,11 +55,11 @@ template< class EOT > class peoTransform : public Service, public eoTransform< E
public: public:
//! @brief Constructor //! @brief Constructor
//! @param eoQuadOp< EOT >& __cross //! @param eoQuadOp< EOT >& __cross
//! @param double __cross_rate //! @param double __cross_rate
//! @param eoMonOp< EOT >& __mut //! @param eoMonOp< EOT >& __mut
//! @param double __mut_rate //! @param double __mut_rate
peoTransform( peoTransform(
eoQuadOp< EOT >& __cross, eoQuadOp< EOT >& __cross,
double __cross_rate, double __cross_rate,
@ -67,34 +67,34 @@ template< class EOT > class peoTransform : public Service, public eoTransform< E
double __mut_rate double __mut_rate
); );
//! @brief Operator //! @brief Operator
//! @param eoPop< EOT >& __pop //! @param eoPop< EOT >& __pop
void operator()( eoPop< EOT >& __pop ); void operator()( eoPop< EOT >& __pop );
//! @brief Function realizing packages of data //! @brief Function realizing packages of data
void packData(); void packData();
//! @brief Function reconstituting packages of data //! @brief Function reconstituting packages of data
void unpackData(); void unpackData();
//! @brief Function which executes the algorithm //! @brief Function which executes the algorithm
void execute(); void execute();
//! @brief Function realizing packages of the result //! @brief Function realizing packages of the result
void packResult(); void packResult();
//! @brief Function reconstituting packages of result //! @brief Function reconstituting packages of result
void unpackResult(); void unpackResult();
//! @brief Function notifySendingData //! @brief Function notifySendingData
void notifySendingData(); void notifySendingData();
//! @brief Function notifySendingAllResourceRequests //! @brief Function notifySendingAllResourceRequests
void notifySendingAllResourceRequests(); void notifySendingAllResourceRequests();
private: private:
//! @param eoQuadOp< EOT >& cross //! @param eoQuadOp< EOT >& cross
//! @param double cross_rate //! @param double cross_rate
//! @param eoMonOp< EOT >& mut //! @param eoMonOp< EOT >& mut
//! @param double mut_rate //! @param double mut_rate
//! @param unsigned idx //! @param unsigned idx
//! @param eoPop< EOT >* pop //! @param eoPop< EOT >* pop
//! @param EOT father //! @param EOT father
//! @param mother //! @param mother
//! @param unsigned num_term //! @param unsigned num_term
eoQuadOp< EOT >& cross; eoQuadOp< EOT >& cross;
double cross_rate; double cross_rate;
eoMonOp< EOT >& mut; eoMonOp< EOT >& mut;

View file

@ -51,39 +51,39 @@ class peoWrapper : public Runner
public: public:
//! @brief constructor //! @brief constructor
//! @param AlgorithmType& externalAlgorithm //! @param AlgorithmType& externalAlgorithm
template< typename AlgorithmType > peoWrapper( AlgorithmType& externalAlgorithm ) template< typename AlgorithmType > peoWrapper( AlgorithmType& externalAlgorithm )
: algorithm( new Algorithm< AlgorithmType, void >( externalAlgorithm ) ) : algorithm( new Algorithm< AlgorithmType, void >( externalAlgorithm ) )
{} {}
//! @brief constructor //! @brief constructor
//! @param AlgorithmType& externalAlgorithm //! @param AlgorithmType& externalAlgorithm
//! @param AlgorithmDataType& externalData //! @param AlgorithmDataType& externalData
template< typename AlgorithmType, typename AlgorithmDataType > peoWrapper( AlgorithmType& externalAlgorithm, AlgorithmDataType& externalData ) template< typename AlgorithmType, typename AlgorithmDataType > peoWrapper( AlgorithmType& externalAlgorithm, AlgorithmDataType& externalData )
: algorithm( new Algorithm< AlgorithmType, AlgorithmDataType >( externalAlgorithm, externalData ) ) : algorithm( new Algorithm< AlgorithmType, AlgorithmDataType >( externalAlgorithm, externalData ) )
{} {}
//! @brief constructor //! @brief constructor
//! @param AlgorithmReturnType& (*externalAlgorithm)() //! @param AlgorithmReturnType& (*externalAlgorithm)()
template< typename AlgorithmReturnType > peoWrapper( AlgorithmReturnType& (*externalAlgorithm)() ) template< typename AlgorithmReturnType > peoWrapper( AlgorithmReturnType& (*externalAlgorithm)() )
: algorithm( new FunctionAlgorithm< AlgorithmReturnType, void >( externalAlgorithm ) ) : algorithm( new FunctionAlgorithm< AlgorithmReturnType, void >( externalAlgorithm ) )
{} {}
//! @brief constructor //! @brief constructor
//! @param AlgorithmReturnType& (*externalAlgorithm)( AlgorithmDataType& ) //! @param AlgorithmReturnType& (*externalAlgorithm)( AlgorithmDataType& )
//! @param AlgorithmDataType& externalData //! @param AlgorithmDataType& externalData
template< typename AlgorithmReturnType, typename AlgorithmDataType > peoWrapper( AlgorithmReturnType& (*externalAlgorithm)( AlgorithmDataType& ), AlgorithmDataType& externalData ) template< typename AlgorithmReturnType, typename AlgorithmDataType > peoWrapper( AlgorithmReturnType& (*externalAlgorithm)( AlgorithmDataType& ), AlgorithmDataType& externalData )
: algorithm( new FunctionAlgorithm< AlgorithmReturnType, AlgorithmDataType >( externalAlgorithm, externalData ) ) : algorithm( new FunctionAlgorithm< AlgorithmReturnType, AlgorithmDataType >( externalAlgorithm, externalData ) )
{} {}
//! @brief destructor //! @brief destructor
~peoWrapper() ~peoWrapper()
{ {
delete algorithm; delete algorithm;
} }
//! @brief function run //! @brief function run
void run() void run()
{ {
algorithm->operator()(); algorithm->operator()();
@ -166,7 +166,7 @@ class peoWrapper : public Runner
}; };
private: private:
//! @param AbstractAlgorithm* algorithm //! @param AbstractAlgorithm* algorithm
AbstractAlgorithm* algorithm; AbstractAlgorithm* algorithm;
}; };

View file

@ -65,10 +65,14 @@ struct SyncCompare
std::vector< SyncEntry >::const_iterator itA = syncA.begin(); std::vector< SyncEntry >::const_iterator itA = syncA.begin();
std::vector< SyncEntry >::const_iterator itB = syncB.begin(); std::vector< SyncEntry >::const_iterator itB = syncB.begin();
while ( itA != syncA.end() && (*itA).runner == (*itB).runner ) { itA++; itB++; } while ( itA != syncA.end() && (*itA).runner == (*itB).runner )
{
itA++;
itB++;
}
return ( (itA == syncA.end()) ) ? false : ( (*itA).runner < (*itB).runner ); return ( (itA == syncA.end()) ) ? false : ( (*itA).runner < (*itB).runner );
} }
return syncA.size() < syncB.size(); return syncA.size() < syncB.size();
} }

View file

@ -48,7 +48,7 @@ int main (int __argc, char *__argv[])
{ {
peo :: init( __argc, __argv ); peo :: init( __argc, __argv );
if (getNodeRank()==1) if (getNodeRank()==1)
std::cout<<"\n\nTest : Asynchronous island with EA\n\n"; std::cout<<"\n\nTest : Asynchronous island with EA\n\n";
rng.reseed (10); rng.reseed (10);
RingTopology topology; RingTopology topology;
eoGenContinue < Indi > genContPara (10); eoGenContinue < Indi > genContPara (10);
@ -63,7 +63,8 @@ int main (int __argc, char *__argv[])
eoSegmentCrossover<Indi> crossover; eoSegmentCrossover<Indi> crossover;
eoUniformMutation<Indi> mutation(0.01); eoUniformMutation<Indi> mutation(0.01);
peoTransform<Indi> transform(crossover,0.8,mutation,0.3); peoTransform<Indi> transform(crossover,0.8,mutation,0.3);
/*p*/eoPop < Indi > pop; /*p*/
eoPop < Indi > pop;
pop.append (10, random); pop.append (10, random);
eoPlusReplacement<Indi> replace; eoPlusReplacement<Indi> replace;
eoRandomSelect<Indi> mig_select_one; eoRandomSelect<Indi> mig_select_one;
@ -90,7 +91,8 @@ int main (int __argc, char *__argv[])
eoSegmentCrossover<Indi> crossover2; eoSegmentCrossover<Indi> crossover2;
eoUniformMutation<Indi> mutation2(0.01); eoUniformMutation<Indi> mutation2(0.01);
peoTransform<Indi> transform2(crossover2,0.8,mutation2,0.3); peoTransform<Indi> transform2(crossover2,0.8,mutation2,0.3);
/*p*/eoPop < Indi > pop2; /*p*/
eoPop < Indi > pop2;
pop2.append (10, random2); pop2.append (10, random2);
eoPlusReplacement<Indi> replace2; eoPlusReplacement<Indi> replace2;
eoRandomSelect<Indi> mig_select_one2; eoRandomSelect<Indi> mig_select_one2;

View file

@ -49,7 +49,7 @@ int main (int __argc, char *__argv[])
{ {
peo :: init( __argc, __argv ); peo :: init( __argc, __argv );
if (getNodeRank()==1) if (getNodeRank()==1)
std::cout<<"\n\nTest : Synchronous island with EA\n\n"; std::cout<<"\n\nTest : Synchronous island with EA\n\n";
rng.reseed (10); rng.reseed (10);
RingTopology topology; RingTopology topology;
eoGenContinue < Indi > genContPara (10); eoGenContinue < Indi > genContPara (10);

View file

@ -39,5 +39,5 @@
int main (int __argc, char *__argv[]) int main (int __argc, char *__argv[])
{ {
system("mpdallexit"); system("mpdallexit");
} }

View file

@ -39,5 +39,5 @@
int main (int __argc, char *__argv[]) int main (int __argc, char *__argv[])
{ {
system("mpdboot"); system("mpdboot");
} }

View file

@ -39,29 +39,29 @@
#include <peo> #include <peo>
struct Algorithm struct Algorithm
{ {
void operator()(double & _d) void operator()(double & _d)
{ {
_d = _d * _d; _d = _d * _d;
} }
}; };
int main (int __argc, char * * __argv) int main (int __argc, char * * __argv)
{ {
peo :: init (__argc, __argv); peo :: init (__argc, __argv);
if (getNodeRank()==1) if (getNodeRank()==1)
std::cout<<"\n\nTest : multistart\n\n"; std::cout<<"\n\nTest : multistart\n\n";
std::vector < double > v; std::vector < double > v;
if (getNodeRank()==1) if (getNodeRank()==1)
std::cout<<"\n\nBefore :"; std::cout<<"\n\nBefore :";
for(unsigned i = 0; i< 10; i++) for (unsigned i = 0; i< 10; i++)
{ {
v.push_back(i); v.push_back(i);
if (getNodeRank()==1) if (getNodeRank()==1)
std::cout<<"\n"<<v[i]; std::cout<<"\n"<<v[i];
} }
Algorithm algo; Algorithm algo;
peoMultiStart < double > initParallel (algo); peoMultiStart < double > initParallel (algo);
peoWrapper parallelAlgo (initParallel, v); peoWrapper parallelAlgo (initParallel, v);
@ -69,9 +69,9 @@ int main (int __argc, char * * __argv)
peo :: run( ); peo :: run( );
peo :: finalize( ); peo :: finalize( );
if (getNodeRank()==1) if (getNodeRank()==1)
{ {
std::cout<<"\n\nAfter :\n"; std::cout<<"\n\nAfter :\n";
for(unsigned i = 0; i< 10; i++) for (unsigned i = 0; i< 10; i++)
std::cout<<v[i]<<"\n"; std::cout<<v[i]<<"\n";
} }
} }

View file

@ -47,7 +47,7 @@ int main (int __argc, char *__argv[])
{ {
peo :: init( __argc, __argv ); peo :: init( __argc, __argv );
if (getNodeRank()==1) if (getNodeRank()==1)
std::cout<<"\n\nTest : PSO Global Best\n\n"; std::cout<<"\n\nTest : PSO Global Best\n\n";
rng.reseed (10); rng.reseed (10);
RingTopology topologyMig; RingTopology topologyMig;
eoGenContinue < Indi > genContPara (10); eoGenContinue < Indi > genContPara (10);

View file

@ -47,7 +47,7 @@ int main (int __argc, char *__argv[])
{ {
peo :: init( __argc, __argv ); peo :: init( __argc, __argv );
if (getNodeRank()==1) if (getNodeRank()==1)
std::cout<<"\n\nTest : PSO Worst Position\n\n"; std::cout<<"\n\nTest : PSO Worst Position\n\n";
rng.reseed (10); rng.reseed (10);
RingTopology topologyMig; RingTopology topologyMig;
eoGenContinue < Indi > genContPara (10); eoGenContinue < Indi > genContPara (10);

View file

@ -44,22 +44,22 @@ double f (const Indi & _indi)
double sum=_indi[0]+_indi[1]; double sum=_indi[0]+_indi[1];
return (-sum); return (-sum);
} }
struct Algorithm struct Algorithm
{ {
Algorithm( peoPopEval < Indi > & _eval): eval( _eval ){} Algorithm( peoPopEval < Indi > & _eval): eval( _eval ){}
void operator()(eoPop < Indi > & _pop) void operator()(eoPop < Indi > & _pop)
{ {
eoPop < Indi > empty_pop; eoPop < Indi > empty_pop;
eval(empty_pop, _pop); eval(empty_pop, _pop);
} }
peoPopEval < Indi > & eval; peoPopEval < Indi > & eval;
}; };
int main (int __argc, char *__argv[]) int main (int __argc, char *__argv[])
{ {
peo :: init( __argc, __argv ); peo :: init( __argc, __argv );
if (getNodeRank()==1) if (getNodeRank()==1)
std::cout<<"\n\nTest : parallel evaluation\n\n"; std::cout<<"\n\nTest : parallel evaluation\n\n";
rng.reseed (10); rng.reseed (10);
peoEvalFunc<Indi, double, const Indi& > plainEval(f); peoEvalFunc<Indi, double, const Indi& > plainEval(f);
peoPopEval< Indi > eval(plainEval); peoPopEval< Indi > eval(plainEval);
@ -72,8 +72,8 @@ int main (int __argc, char *__argv[])
peo :: run(); peo :: run();
peo :: finalize(); peo :: finalize();
if (getNodeRank()==1) if (getNodeRank()==1)
{ {
pop.sort(); pop.sort();
std::cout<<pop; std::cout<<pop;
} }
} }

View file

@ -44,35 +44,35 @@ double f (const Indi & _indi)
double sum=_indi[0]+_indi[1]; double sum=_indi[0]+_indi[1];
return (-sum); return (-sum);
} }
struct Algorithm struct Algorithm
{ {
Algorithm( eoEvalFunc < Indi > & _eval, eoSelect < Indi > & _select, peoTransform < Indi > & _transform): Algorithm( eoEvalFunc < Indi > & _eval, eoSelect < Indi > & _select, peoTransform < Indi > & _transform):
loopEval(_eval), loopEval(_eval),
eval(loopEval), eval(loopEval),
selectTransform( _select, _transform), selectTransform( _select, _transform),
breed(selectTransform) {} breed(selectTransform) {}
void operator()(eoPop < Indi > & _pop) void operator()(eoPop < Indi > & _pop)
{ {
eoPop < Indi > offspring, empty_pop; eoPop < Indi > offspring, empty_pop;
eval(empty_pop, _pop); eval(empty_pop, _pop);
eval(empty_pop, offspring); eval(empty_pop, offspring);
std::cout<<"\n\nBefore :\n"<<offspring; std::cout<<"\n\nBefore :\n"<<offspring;
breed(_pop, offspring); breed(_pop, offspring);
eval(empty_pop, offspring); eval(empty_pop, offspring);
std::cout<<"\n\nAfter :\n"<<offspring; std::cout<<"\n\nAfter :\n"<<offspring;
} }
eoPopLoopEval < Indi > loopEval; eoPopLoopEval < Indi > loopEval;
eoPopEvalFunc < Indi > & eval; eoPopEvalFunc < Indi > & eval;
eoSelectTransform < Indi > selectTransform; eoSelectTransform < Indi > selectTransform;
eoBreed < Indi > & breed; eoBreed < Indi > & breed;
}; };
int main (int __argc, char *__argv[]) int main (int __argc, char *__argv[])
{ {
peo :: init( __argc, __argv ); peo :: init( __argc, __argv );
if (getNodeRank()==1) if (getNodeRank()==1)
std::cout<<"\n\nTest : parallel transform\n\n"; std::cout<<"\n\nTest : parallel transform\n\n";
rng.reseed (10); rng.reseed (10);
eoEvalFuncPtr < Indi > plainEval(f); eoEvalFuncPtr < Indi > plainEval(f);
eoEvalFuncCounter < Indi > eval(plainEval); eoEvalFuncCounter < Indi > eval(plainEval);

View file

@ -65,7 +65,7 @@ int main (int __argc, char *__argv[])
double EPSILON = parser.createParam(0.01, "mutEpsilon", "epsilon for mutation",'e',"Param").value(); double EPSILON = parser.createParam(0.01, "mutEpsilon", "epsilon for mutation",'e',"Param").value();
double CROSS_RATE = parser.createParam(0.25, "pCross", "Crossover probability",'C',"Param").value(); double CROSS_RATE = parser.createParam(0.25, "pCross", "Crossover probability",'C',"Param").value();
double MUT_RATE = parser.createParam(0.35, "pMut", "Mutation probability",'M',"Param").value(); double MUT_RATE = parser.createParam(0.35, "pMut", "Mutation probability",'M',"Param").value();
unsigned int VEC_SIZE = parser.createParam((unsigned int)(2), "vecSize", "Vector size",'V',"Param").value(); unsigned int VEC_SIZE = parser.createParam((unsigned int)(2), "vecSize", "Vector size",'V',"Param").value();
double INIT_POSITION_MIN = parser.createParam(-2.0, "pMin", "Init position min",'N',"Param").value(); double INIT_POSITION_MIN = parser.createParam(-2.0, "pMin", "Init position min",'N',"Param").value();
double INIT_POSITION_MAX = parser.createParam(2.0, "pMax", "Init position max",'X',"Param").value(); double INIT_POSITION_MAX = parser.createParam(2.0, "pMax", "Init position max",'X',"Param").value();
rng.reseed (time(0)); rng.reseed (time(0));
@ -88,7 +88,7 @@ int main (int __argc, char *__argv[])
eoSelectNumber<Indi> select(selectionStrategy,POP_SIZE); eoSelectNumber<Indi> select(selectionStrategy,POP_SIZE);
// Transformation // Transformation
eoSegmentCrossover<Indi> crossover; eoSegmentCrossover<Indi> crossover;
eoUniformMutation<Indi> mutation(EPSILON); eoUniformMutation<Indi> mutation(EPSILON);
eoSGATransform<Indi> transform(crossover,CROSS_RATE,mutation,MUT_RATE); eoSGATransform<Indi> transform(crossover,CROSS_RATE,mutation,MUT_RATE);

View file

@ -61,7 +61,7 @@ int main (int __argc, char *__argv[])
eoParser parser(__argc, __argv); eoParser parser(__argc, __argv);
unsigned int POP_SIZE = parser.createParam((unsigned int)(20), "popSize", "Population size",'P',"Param").value(); unsigned int POP_SIZE = parser.createParam((unsigned int)(20), "popSize", "Population size",'P',"Param").value();
unsigned int MAX_GEN = parser.createParam((unsigned int)(100), "maxGen", "Maximum number of generations",'G',"Param").value(); unsigned int MAX_GEN = parser.createParam((unsigned int)(100), "maxGen", "Maximum number of generations",'G',"Param").value();
unsigned int VEC_SIZE = parser.createParam((unsigned int)(2), "vecSize", "Vector size",'V',"Param").value(); unsigned int VEC_SIZE = parser.createParam((unsigned int)(2), "vecSize", "Vector size",'V',"Param").value();
double INIT_POSITION_MIN = parser.createParam(-2.0, "pMin", "Init position min",'N',"Param").value(); double INIT_POSITION_MIN = parser.createParam(-2.0, "pMin", "Init position min",'N',"Param").value();
double INIT_POSITION_MAX = parser.createParam(2.0, "pMax", "Init position max",'X',"Param").value(); double INIT_POSITION_MAX = parser.createParam(2.0, "pMax", "Init position max",'X',"Param").value();
double INIT_VELOCITY_MIN = parser.createParam(-1.0, "vMin", "Init velocity min",'n',"Param").value(); double INIT_VELOCITY_MIN = parser.createParam(-1.0, "vMin", "Init velocity min",'n',"Param").value();

View file

@ -58,7 +58,7 @@ int main (int __argc, char *__argv[])
double EPSILON = parser.createParam(0.01, "mutEpsilon", "epsilon for mutation",'e',"Param").value(); double EPSILON = parser.createParam(0.01, "mutEpsilon", "epsilon for mutation",'e',"Param").value();
double CROSS_RATE = parser.createParam(0.25, "pCross", "Crossover probability",'C',"Param").value(); double CROSS_RATE = parser.createParam(0.25, "pCross", "Crossover probability",'C',"Param").value();
double MUT_RATE = parser.createParam(0.35, "pMut", "Mutation probability",'M',"Param").value(); double MUT_RATE = parser.createParam(0.35, "pMut", "Mutation probability",'M',"Param").value();
unsigned int VEC_SIZE = parser.createParam((unsigned int)(2), "vecSize", "Vector size",'V',"Param").value(); unsigned int VEC_SIZE = parser.createParam((unsigned int)(2), "vecSize", "Vector size",'V',"Param").value();
double INIT_POSITION_MIN = parser.createParam(-2.0, "pMin", "Init position min",'N',"Param").value(); double INIT_POSITION_MIN = parser.createParam(-2.0, "pMin", "Init position min",'N',"Param").value();
double INIT_POSITION_MAX = parser.createParam(2.0, "pMax", "Init position max",'X',"Param").value(); double INIT_POSITION_MAX = parser.createParam(2.0, "pMax", "Init position max",'X',"Param").value();
rng.reseed (time(0)); rng.reseed (time(0));

View file

@ -58,7 +58,7 @@ int main (int __argc, char *__argv[])
double EPSILON = parser.createParam(0.01, "mutEpsilon", "epsilon for mutation",'e',"Param").value(); double EPSILON = parser.createParam(0.01, "mutEpsilon", "epsilon for mutation",'e',"Param").value();
double CROSS_RATE = parser.createParam(0.25, "pCross", "Crossover probability",'C',"Param").value(); double CROSS_RATE = parser.createParam(0.25, "pCross", "Crossover probability",'C',"Param").value();
double MUT_RATE = parser.createParam(0.35, "pMut", "Mutation probability",'M',"Param").value(); double MUT_RATE = parser.createParam(0.35, "pMut", "Mutation probability",'M',"Param").value();
unsigned int VEC_SIZE = parser.createParam((unsigned int)(2), "vecSize", "Vector size",'V',"Param").value(); unsigned int VEC_SIZE = parser.createParam((unsigned int)(2), "vecSize", "Vector size",'V',"Param").value();
double INIT_POSITION_MIN = parser.createParam(-2.0, "pMin", "Init position min",'N',"Param").value(); double INIT_POSITION_MIN = parser.createParam(-2.0, "pMin", "Init position min",'N',"Param").value();
double INIT_POSITION_MAX = parser.createParam(2.0, "pMax", "Init position max",'X',"Param").value(); double INIT_POSITION_MAX = parser.createParam(2.0, "pMax", "Init position max",'X',"Param").value();
unsigned int MIG_FREQ = parser.createParam((unsigned int)(10), "migFreq", "Migration frequency",'F',"Param").value(); unsigned int MIG_FREQ = parser.createParam((unsigned int)(10), "migFreq", "Migration frequency",'F',"Param").value();
@ -85,9 +85,9 @@ int main (int __argc, char *__argv[])
peoTransform<Indi> transform(crossover,CROSS_RATE,mutation,MUT_RATE); peoTransform<Indi> transform(crossover,CROSS_RATE,mutation,MUT_RATE);
eoPop < Indi > pop; eoPop < Indi > pop;
pop.append (POP_SIZE, random); pop.append (POP_SIZE, random);
// Define a synchronous island // Define a synchronous island
// Seclection // Seclection
eoRandomSelect<Indi> mig_select_one; eoRandomSelect<Indi> mig_select_one;
eoSelector <Indi, eoPop<Indi> > mig_select (mig_select_one,MIG_SIZE,pop); eoSelector <Indi, eoPop<Indi> > mig_select (mig_select_one,MIG_SIZE,pop);
@ -97,7 +97,7 @@ int main (int __argc, char *__argv[])
// Island // Island
peoSyncIslandMig<eoPop<Indi>, eoPop<Indi> > mig(MIG_FREQ,mig_select,mig_replace,topology); peoSyncIslandMig<eoPop<Indi>, eoPop<Indi> > mig(MIG_FREQ,mig_select,mig_replace,topology);
checkpoint.add(mig); checkpoint.add(mig);
eoEasyEA< Indi > eaAlg( checkpoint, eval, select, transform, replace ); eoEasyEA< Indi > eaAlg( checkpoint, eval, select, transform, replace );
peoWrapper parallelEA( eaAlg, pop); peoWrapper parallelEA( eaAlg, pop);
eval.setOwner(parallelEA); eval.setOwner(parallelEA);

View file

@ -53,7 +53,7 @@ int main (int __argc, char *__argv[])
eoParser parser(__argc, __argv); eoParser parser(__argc, __argv);
unsigned int POP_SIZE = parser.createParam((unsigned int)(20), "popSize", "Population size",'P',"Param").value(); unsigned int POP_SIZE = parser.createParam((unsigned int)(20), "popSize", "Population size",'P',"Param").value();
unsigned int MAX_GEN = parser.createParam((unsigned int)(100), "maxGen", "Maximum number of generations",'G',"Param").value(); unsigned int MAX_GEN = parser.createParam((unsigned int)(100), "maxGen", "Maximum number of generations",'G',"Param").value();
unsigned int VEC_SIZE = parser.createParam((unsigned int)(2), "vecSize", "Vector size",'V',"Param").value(); unsigned int VEC_SIZE = parser.createParam((unsigned int)(2), "vecSize", "Vector size",'V',"Param").value();
double INIT_POSITION_MIN = parser.createParam(-2.0, "pMin", "Init position min",'N',"Param").value(); double INIT_POSITION_MIN = parser.createParam(-2.0, "pMin", "Init position min",'N',"Param").value();
double INIT_POSITION_MAX = parser.createParam(2.0, "pMax", "Init position max",'X',"Param").value(); double INIT_POSITION_MAX = parser.createParam(2.0, "pMax", "Init position max",'X',"Param").value();
double INIT_VELOCITY_MIN = parser.createParam(-1.0, "vMin", "Init velocity min",'n',"Param").value(); double INIT_VELOCITY_MIN = parser.createParam(-1.0, "vMin", "Init velocity min",'n',"Param").value();

View file

@ -63,16 +63,16 @@ void EdgeXover :: build_map (const Route & __par1, const Route & __par2)
} }
void EdgeXover :: remove_entry (unsigned __vertex, std :: vector <std :: set <unsigned> > & __map) void EdgeXover :: remove_entry (unsigned __vertex, std :: vector <std :: set <unsigned> > & __map)
{ {
std :: set <unsigned> & neigh = __map [__vertex] ; std :: set <unsigned> & neigh = __map [__vertex] ;
for (std :: set <unsigned> :: iterator it = neigh.begin () ; for (std :: set <unsigned> :: iterator it = neigh.begin () ;
it != neigh.end () ; it != neigh.end () ;
it ++) it ++)
__map [* it].erase (__vertex) ; __map [* it].erase (__vertex) ;
} }
void EdgeXover :: add_vertex (unsigned __vertex, Route & __child) void EdgeXover :: add_vertex (unsigned __vertex, Route & __child)
{ {
@ -104,24 +104,24 @@ void EdgeXover :: cross (const Route & __par1, const Route & __par2, Route & __c
std :: set <unsigned> & neigh = _map [cur_vertex] ; std :: set <unsigned> & neigh = _map [cur_vertex] ;
for (std :: set <unsigned> :: iterator it = neigh.begin () ; for (std :: set <unsigned> :: iterator it = neigh.begin () ;
it != neigh.end () ; it != neigh.end () ;
it ++) it ++)
{ {
unsigned l = _map [* it].size () ; unsigned l = _map [* it].size () ;
if (len_min_entry > l) if (len_min_entry > l)
len_min_entry = l ; len_min_entry = l ;
} }
std :: vector <unsigned> cand ; /* Candidates */ std :: vector <unsigned> cand ; /* Candidates */
for (std :: set <unsigned> :: iterator it = neigh.begin () ; for (std :: set <unsigned> :: iterator it = neigh.begin () ;
it != neigh.end () ; it != neigh.end () ;
it ++) it ++)
{ {
unsigned l = _map [* it].size () ; unsigned l = _map [* it].size () ;
if (len_min_entry == l) if (len_min_entry == l)
cand.push_back (* it) ; cand.push_back (* it) ;
} }
if (! cand.size ()) if (! cand.size ())
{ {