new style peo
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1021 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
ef8ef3f3b2
commit
edb6d65a7b
34 changed files with 407 additions and 386 deletions
|
|
@ -80,10 +80,10 @@ COMM_ID getKey (const Communicable * __comm)
|
|||
}
|
||||
|
||||
void Communicable :: lock ()
|
||||
{
|
||||
{
|
||||
|
||||
sem_wait (& sem_lock);
|
||||
}
|
||||
sem_wait (& sem_lock);
|
||||
}
|
||||
|
||||
void Communicable :: unlock ()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* <complete_topo.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
|
|
@ -38,16 +38,19 @@
|
|||
#include "complete_topo.h"
|
||||
|
||||
void CompleteTopology :: setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to) {
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to)
|
||||
{
|
||||
|
||||
__from.clear () ;
|
||||
__to.clear () ;
|
||||
|
||||
for (unsigned i = 0; i < mig.size (); i ++) {
|
||||
if (mig [i] != __mig) {
|
||||
__from.push_back (mig [i]);
|
||||
__to.push_back (mig [i]);
|
||||
}
|
||||
for (unsigned i = 0; i < mig.size (); i ++)
|
||||
{
|
||||
if (mig [i] != __mig)
|
||||
{
|
||||
__from.push_back (mig [i]);
|
||||
__to.push_back (mig [i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* <complete_topo.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
|
|
@ -39,13 +39,14 @@
|
|||
|
||||
#include "topology.h"
|
||||
|
||||
class CompleteTopology : public Topology {
|
||||
class CompleteTopology : public Topology
|
||||
{
|
||||
|
||||
public :
|
||||
public :
|
||||
|
||||
void setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to);
|
||||
};
|
||||
void setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* <random_topo.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
|
|
@ -40,16 +40,19 @@
|
|||
#include <utils/eoRNG.h>
|
||||
|
||||
void RandomTopology :: setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to) {
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to)
|
||||
{
|
||||
|
||||
__from.clear () ;
|
||||
__to.clear () ;
|
||||
|
||||
for (unsigned i = 0; i < mig.size (); i ++) {
|
||||
if (mig [i] != __mig && rng.uniform() < 0.5 ) {
|
||||
__from.push_back (mig [i]);
|
||||
__to.push_back (mig [i]);
|
||||
}
|
||||
for (unsigned i = 0; i < mig.size (); i ++)
|
||||
{
|
||||
if (mig [i] != __mig && rng.uniform() < 0.5 )
|
||||
{
|
||||
__from.push_back (mig [i]);
|
||||
__to.push_back (mig [i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* <random_topo.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
|
|
@ -39,13 +39,14 @@
|
|||
|
||||
#include "topology.h"
|
||||
|
||||
class RandomTopology : public Topology {
|
||||
class RandomTopology : public Topology
|
||||
{
|
||||
|
||||
public :
|
||||
public :
|
||||
|
||||
void setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to);
|
||||
};
|
||||
void setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* <star_topo.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
|
|
@ -40,30 +40,36 @@
|
|||
StarTopology :: StarTopology () : center( NULL ) {}
|
||||
|
||||
void StarTopology :: setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to) {
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to)
|
||||
{
|
||||
|
||||
assert( center != NULL );
|
||||
|
||||
__from.clear () ;
|
||||
__to.clear () ;
|
||||
|
||||
if ( __mig == center ) {
|
||||
if ( __mig == center )
|
||||
{
|
||||
|
||||
for (unsigned i = 0; i < mig.size (); i ++) {
|
||||
if (mig [i] != center) {
|
||||
__from.push_back (mig [i]);
|
||||
__to.push_back (mig [i]);
|
||||
}
|
||||
for (unsigned i = 0; i < mig.size (); i ++)
|
||||
{
|
||||
if (mig [i] != center)
|
||||
{
|
||||
__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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* <star_topo.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
|
|
@ -39,21 +39,22 @@
|
|||
|
||||
#include "topology.h"
|
||||
|
||||
class StarTopology : public Topology {
|
||||
class StarTopology : public Topology
|
||||
{
|
||||
|
||||
public :
|
||||
public :
|
||||
|
||||
StarTopology ();
|
||||
StarTopology ();
|
||||
|
||||
void setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to);
|
||||
void setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to);
|
||||
|
||||
void setCenter (Cooperative& __center);
|
||||
void setCenter (Cooperative& __center);
|
||||
|
||||
private :
|
||||
private :
|
||||
|
||||
Cooperative* center;
|
||||
};
|
||||
Cooperative* center;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -43,10 +43,10 @@ Topology :: ~ Topology ()
|
|||
}
|
||||
|
||||
void Topology :: add (Cooperative & __mig)
|
||||
{
|
||||
{
|
||||
|
||||
mig.push_back (& __mig) ;
|
||||
}
|
||||
mig.push_back (& __mig) ;
|
||||
}
|
||||
|
||||
Topology :: operator std :: vector <Cooperative *>& ()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
|
||||
|
||||
//! @class peoAsyncIslandMig
|
||||
//! @brief Specific class for a asynchronous migration
|
||||
//! @brief Specific class for a asynchronous migration
|
||||
//! @see Cooperative eoUpdater
|
||||
//! @version 2.0
|
||||
//! @date january 2008
|
||||
|
|
@ -67,18 +67,18 @@ template< class TYPESELECT, class TYPEREPLACE > class peoAsyncIslandMig : public
|
|||
public:
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param continuator & __cont
|
||||
//! @param selector <TYPE> & __select
|
||||
//! @param replacement <TYPE> & __replace
|
||||
//! @param Topology& __topology
|
||||
peoAsyncIslandMig(
|
||||
//! @param continuator & __cont
|
||||
//! @param selector <TYPE> & __select
|
||||
//! @param replacement <TYPE> & __replace
|
||||
//! @param Topology& __topology
|
||||
peoAsyncIslandMig(
|
||||
continuator & __cont,
|
||||
selector <TYPESELECT> & __select,
|
||||
replacement <TYPEREPLACE> & __replace,
|
||||
Topology& __topology
|
||||
);
|
||||
|
||||
//! @brief operator
|
||||
//! @brief operator
|
||||
void operator()();
|
||||
//! @brief Function realizing packages
|
||||
void pack();
|
||||
|
|
@ -88,23 +88,23 @@ template< class TYPESELECT, class TYPEREPLACE > class peoAsyncIslandMig : public
|
|||
void packSynchronizeReq();
|
||||
|
||||
private:
|
||||
//! @brief Function which sends some emigrants
|
||||
//! @brief Function which sends some emigrants
|
||||
void emigrate();
|
||||
//! @brief Function which receives some immigrants
|
||||
void immigrate();
|
||||
|
||||
private:
|
||||
//! @param continuator & cont
|
||||
//! @param selector <TYPESELECT> & select
|
||||
//! @param replacement <TYPEREPLACE> & replace
|
||||
//! @param Topology& topology
|
||||
//! @param std :: queue< TYPEREPLACE > imm
|
||||
//! @param std :: queue< TYPESELECT > em
|
||||
//! @param std :: queue< Cooperative* > coop_em
|
||||
continuator & cont;
|
||||
selector <TYPESELECT> & select;
|
||||
replacement <TYPEREPLACE> & replace;
|
||||
Topology& topology;
|
||||
//! @param continuator & cont
|
||||
//! @param selector <TYPESELECT> & select
|
||||
//! @param replacement <TYPEREPLACE> & replace
|
||||
//! @param Topology& topology
|
||||
//! @param std :: queue< TYPEREPLACE > imm
|
||||
//! @param std :: queue< TYPESELECT > em
|
||||
//! @param std :: queue< Cooperative* > coop_em
|
||||
continuator & cont;
|
||||
selector <TYPESELECT> & select;
|
||||
replacement <TYPEREPLACE> & replace;
|
||||
Topology& topology;
|
||||
std :: queue< TYPEREPLACE > imm;
|
||||
std :: queue< TYPESELECT > em;
|
||||
std :: queue< Cooperative* > coop_em;
|
||||
|
|
@ -189,8 +189,8 @@ template< class TYPESELECT , class TYPEREPLACE> void peoAsyncIslandMig< TYPESELE
|
|||
if (! cont.check())
|
||||
{
|
||||
|
||||
emigrate();
|
||||
immigrate();
|
||||
emigrate();
|
||||
immigrate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@
|
|||
class continuator
|
||||
{
|
||||
public:
|
||||
|
||||
//! @brief Virtual function of check
|
||||
//! @return true if the algorithm must continue
|
||||
|
||||
//! @brief Virtual function of check
|
||||
//! @return true if the algorithm must continue
|
||||
virtual bool check()=0;
|
||||
//! @brief Virtual destructor
|
||||
virtual ~continuator(){}
|
||||
|
|
@ -69,22 +69,22 @@ template < class EOT> class eoContinuator : public continuator
|
|||
{
|
||||
public:
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param eoContinue<EOT> &
|
||||
//! @param eoPop<EOT> &
|
||||
//! @brief Constructor
|
||||
//! @param eoContinue<EOT> &
|
||||
//! @param eoPop<EOT> &
|
||||
eoContinuator(eoContinue<EOT> & _cont, const eoPop<EOT> & _pop): cont (_cont), pop(_pop)
|
||||
{}
|
||||
|
||||
//! @brief Virtual function of check
|
||||
//! @return false if the algorithm must continue
|
||||
//! @brief Virtual function of check
|
||||
//! @return false if the algorithm must continue
|
||||
virtual bool check()
|
||||
{
|
||||
return cont(pop);
|
||||
}
|
||||
|
||||
protected:
|
||||
//! @param eoContinue<EOT> &
|
||||
//! @param eoPop<EOT> &
|
||||
//! @param eoContinue<EOT> &
|
||||
//! @param eoPop<EOT> &
|
||||
eoContinue<EOT> & cont ;
|
||||
const eoPop<EOT> & pop;
|
||||
};
|
||||
|
|
@ -101,9 +101,9 @@ template < class EOT> class eoContinuator : public continuator
|
|||
template < class TYPE> class selector
|
||||
{
|
||||
public:
|
||||
|
||||
//! @brief Virtual operator on the template type
|
||||
//! @param TYPE &
|
||||
|
||||
//! @brief Virtual operator on the template type
|
||||
//! @param TYPE &
|
||||
virtual void operator()(TYPE &)=0;
|
||||
//! @brief Virtual destructor
|
||||
virtual ~selector(){}
|
||||
|
|
@ -119,16 +119,16 @@ template < class EOT, class TYPE> class eoSelector : public selector< TYPE >
|
|||
{
|
||||
public:
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param eoSelectOne<EOT> &
|
||||
//! @param unsigned _nb_select
|
||||
//! @param TYPE & _source (with TYPE which is the template type)
|
||||
//! @brief Constructor
|
||||
//! @param eoSelectOne<EOT> &
|
||||
//! @param unsigned _nb_select
|
||||
//! @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)
|
||||
{}
|
||||
|
||||
//! @brief Virtual operator on the template type
|
||||
//! @param TYPE & _dest
|
||||
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<size_t>(nb_select);
|
||||
_dest.resize(target);
|
||||
|
|
@ -137,9 +137,9 @@ template < class EOT, class TYPE> class eoSelector : public selector< TYPE >
|
|||
}
|
||||
|
||||
protected:
|
||||
//! @param eoSelectOne<EOT> &
|
||||
//! @param unsigned nb_select
|
||||
//! @param TYPE & source
|
||||
//! @param eoSelectOne<EOT> &
|
||||
//! @param unsigned nb_select
|
||||
//! @param TYPE & source
|
||||
eoSelectOne<EOT> & selector ;
|
||||
unsigned nb_select;
|
||||
const TYPE & source;
|
||||
|
|
@ -157,8 +157,8 @@ template < class EOT, class TYPE> class eoSelector : public selector< TYPE >
|
|||
template < class TYPE> class replacement
|
||||
{
|
||||
public:
|
||||
//! @brief Virtual operator on the template type
|
||||
//! @param TYPE &
|
||||
//! @brief Virtual operator on the template type
|
||||
//! @param TYPE &
|
||||
virtual void operator()(TYPE &)=0;
|
||||
//! @brief Virtual destructor
|
||||
virtual ~replacement(){}
|
||||
|
|
@ -173,22 +173,22 @@ template < class TYPE> class replacement
|
|||
template < class EOT, class TYPE> class eoReplace : public replacement< TYPE >
|
||||
{
|
||||
public:
|
||||
//! @brief Constructor
|
||||
//! @param eoReplacement<EOT> &
|
||||
//! @param TYPE & _destination (with TYPE which is the template type)
|
||||
//! @brief Constructor
|
||||
//! @param eoReplacement<EOT> &
|
||||
//! @param TYPE & _destination (with TYPE which is the template type)
|
||||
eoReplace(eoReplacement<EOT> & _replace, TYPE & _destination): replace(_replace), destination(_destination)
|
||||
{}
|
||||
|
||||
//! @brief Virtual operator on the template type
|
||||
//! @param TYPE & _source
|
||||
//! @brief Virtual operator on the template type
|
||||
//! @param TYPE & _source
|
||||
virtual void operator()(TYPE & _source)
|
||||
{
|
||||
replace(destination, _source);
|
||||
}
|
||||
|
||||
protected:
|
||||
//! @param eoReplacement<EOT> &
|
||||
//! @param TYPE & destination
|
||||
//! @param eoReplacement<EOT> &
|
||||
//! @param TYPE & destination
|
||||
eoReplacement<EOT> & replace;
|
||||
TYPE & destination;
|
||||
};
|
||||
|
|
@ -207,14 +207,14 @@ class eoSyncContinue: public continuator
|
|||
{
|
||||
|
||||
public:
|
||||
//! @brief Constructor
|
||||
//! @param unsigned __period
|
||||
//! @param unsigned __init_counter
|
||||
//! @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
|
||||
//! @brief Virtual function of check
|
||||
//! @return true if the algorithm must continue
|
||||
virtual bool check()
|
||||
{
|
||||
return ((++ counter) % period) != 0 ;
|
||||
|
|
@ -222,8 +222,8 @@ class eoSyncContinue: public continuator
|
|||
|
||||
|
||||
private:
|
||||
//! @param unsigned period
|
||||
//! @param unsigned counter
|
||||
//! @param unsigned period
|
||||
//! @param unsigned counter
|
||||
unsigned period;
|
||||
unsigned counter;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -50,21 +50,21 @@ template< class EOT, class FitT = typename EOT::Fitness, class FunctionArg = con
|
|||
struct peoEvalFunc: public eoEvalFunc<EOT>
|
||||
{
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param FitT (* _eval)( FunctionArg )
|
||||
//! @brief Constructor
|
||||
//! @param FitT (* _eval)( FunctionArg )
|
||||
peoEvalFunc( FitT (* _eval)( FunctionArg ) )
|
||||
: eoEvalFunc<EOT>(), evalFunc( _eval )
|
||||
{};
|
||||
|
||||
//! @brief Virtual operator
|
||||
//! @param EOT & _peo
|
||||
//! @brief Virtual operator
|
||||
//! @param EOT & _peo
|
||||
virtual void operator() ( EOT & _peo )
|
||||
{
|
||||
_peo.fitness((*evalFunc)( _peo ));
|
||||
};
|
||||
|
||||
private:
|
||||
//! @param FitT (* evalFunc )( FunctionArg )
|
||||
//! @param FitT (* evalFunc )( FunctionArg )
|
||||
FitT (* evalFunc )( FunctionArg );
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
void operator()(eoPop< EOT >& __pop);
|
||||
|
||||
|
||||
//! @brief Operator ()( eoPop< EOT >& __dummy, eoPop< EOT >& __pop )
|
||||
//! @param eoPop< EOT >& __dummy
|
||||
//! @param 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
|
||||
|
|
@ -105,16 +105,16 @@ 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
|
||||
//! @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;
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ template < typename EntityType > class peoMultiStart : public Service
|
|||
|
||||
public:
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param AlgorithmType& externalAlgorithm
|
||||
//! @brief Constructor
|
||||
//! @param AlgorithmType& externalAlgorithm
|
||||
template < typename AlgorithmType > peoMultiStart( AlgorithmType& externalAlgorithm )
|
||||
{
|
||||
singularAlgorithm = new Algorithm< AlgorithmType >( externalAlgorithm );
|
||||
|
|
@ -60,18 +60,18 @@ template < typename EntityType > class peoMultiStart : public Service
|
|||
aggregationFunction = new NoAggregationFunction();
|
||||
}
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param AlgorithmReturnType (*externalAlgorithm)( AlgorithmDataType& )
|
||||
//! @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
|
||||
|
||||
//! @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++ )
|
||||
|
|
@ -81,9 +81,9 @@ template < typename EntityType > class peoMultiStart : public Service
|
|||
aggregationFunction = new AggregationAlgorithm< AggregationFunctionType >( externalAggregationFunction );
|
||||
}
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param std::vector< AlgorithmReturnType (*)( AlgorithmDataType& ) >& externalAlgorithms
|
||||
//! @param 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++ )
|
||||
|
|
@ -93,16 +93,16 @@ template < typename EntityType > class peoMultiStart : public Service
|
|||
aggregationFunction = new AggregationAlgorithm< AggregationFunctionType >( externalAggregationFunction );
|
||||
}
|
||||
|
||||
//! @brief Destructor
|
||||
//! @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
|
||||
//! @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++ )
|
||||
|
|
@ -114,9 +114,9 @@ template < typename EntityType > class peoMultiStart : public Service
|
|||
stop();
|
||||
}
|
||||
|
||||
//! @brief operator on the template type
|
||||
//! @param Type& externalDataBegin
|
||||
//! @param Type& externalDataEnd
|
||||
//! @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++ )
|
||||
|
|
@ -128,32 +128,32 @@ template < typename EntityType > class peoMultiStart : public Service
|
|||
stop();
|
||||
}
|
||||
|
||||
//! @brief Function realizing packages of data
|
||||
//! @brief Function realizing packages of data
|
||||
void packData();
|
||||
//! @brief Function reconstituting packages of data
|
||||
void unpackData();
|
||||
//! @brief Function which executes the algorithm
|
||||
//! @brief Function which executes the algorithm
|
||||
void execute();
|
||||
//! @brief Function realizing packages of the result
|
||||
//! @brief Function realizing packages of the result
|
||||
void packResult();
|
||||
//! @brief Function reconstituting packages of result
|
||||
//! @brief Function reconstituting packages of result
|
||||
void unpackResult();
|
||||
//! @brief Function notifySendingData
|
||||
//! @brief Function notifySendingData
|
||||
void notifySendingData();
|
||||
//! @brief Function notifySendingAllResourceRequests
|
||||
//! @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
|
||||
|
||||
//! @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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -55,27 +55,27 @@ template <class POT> class peoPSOSelect: public eoSelectOne<POT>
|
|||
{
|
||||
public:
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param eoTopology < POT > & _topology
|
||||
//! @brief Constructor
|
||||
//! @param eoTopology < POT > & _topology
|
||||
peoPSOSelect(eoTopology < POT > & _topology):topology(_topology)
|
||||
{}
|
||||
|
||||
//! @brief typedef : creation of Fitness
|
||||
//! @brief typedef : creation of Fitness
|
||||
typedef typename PO < POT >::Fitness Fitness;
|
||||
|
||||
//! @brief Virtual operator
|
||||
//! @param eoPop<POT>& _pop
|
||||
//! @return POT&
|
||||
//! @brief Virtual operator
|
||||
//! @param eoPop<POT>& _pop
|
||||
//! @return POT&
|
||||
virtual const POT& operator()(const eoPop<POT>& _pop)
|
||||
{
|
||||
return topology.globalBest(_pop);
|
||||
}
|
||||
|
||||
private:
|
||||
//! @param eoTopology < POT > & topology
|
||||
//! @param eoTopology < POT > & topology
|
||||
eoTopology < POT > & topology;
|
||||
};
|
||||
|
||||
|
||||
//! @class peoGlobalBestVelocity
|
||||
//! @brief Specific class for a replacement thanks to the velocity migration of a population of a PSO
|
||||
//! @see eoReplacement
|
||||
|
|
@ -86,18 +86,18 @@ class peoGlobalBestVelocity : public eoReplacement<POT>
|
|||
{
|
||||
public:
|
||||
|
||||
//! @brief typedef : creation of VelocityType
|
||||
//! @brief typedef : creation of VelocityType
|
||||
typedef typename POT::ParticleVelocityType VelocityType;
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param double & _c3
|
||||
//! @param eoVelocity < POT > &_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<POT>& _dest
|
||||
//! @param eoPop<POT>& _source
|
||||
//! @brief Virtual operator
|
||||
//! @param eoPop<POT>& _dest
|
||||
//! @param eoPop<POT>& _source
|
||||
void operator()(eoPop<POT>& _dest, eoPop<POT>& _source)
|
||||
{
|
||||
|
||||
|
|
@ -113,12 +113,12 @@ class peoGlobalBestVelocity : public eoReplacement<POT>
|
|||
}
|
||||
|
||||
protected:
|
||||
//! @param double & c3
|
||||
//! @param eoVelocity < POT > & velocity
|
||||
//! @param double & c3
|
||||
//! @param eoVelocity < POT > & velocity
|
||||
const double & c3;
|
||||
eoVelocity < POT > & velocity;
|
||||
};
|
||||
|
||||
|
||||
//! @class peoWorstPositionReplacement
|
||||
//! @brief Specific class for a replacement of a population of a PSO
|
||||
//! @see eoReplacement
|
||||
|
|
@ -127,13 +127,13 @@ class peoGlobalBestVelocity : public eoReplacement<POT>
|
|||
template <class POT> class peoWorstPositionReplacement : public eoReplacement<POT>
|
||||
{
|
||||
public:
|
||||
//! @brief constructor
|
||||
//! @brief constructor
|
||||
peoWorstPositionReplacement()
|
||||
{}
|
||||
|
||||
//! @brief operator
|
||||
//! @param eoPop<POT>& _dest
|
||||
//! @param eoPop<POT>& _source
|
||||
//! @brief operator
|
||||
//! @param eoPop<POT>& _dest
|
||||
//! @param eoPop<POT>& _source
|
||||
void operator()(eoPop<POT>& _dest, eoPop<POT>& _source)
|
||||
{
|
||||
unsigned ind=0;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
void operator()(eoPop< EOT >& __pop);
|
||||
|
||||
|
||||
//! @brief Operator ()( eoPop< EOT >& __dummy, eoPop< EOT >& __pop )
|
||||
//! @param eoPop< EOT >& __dummy
|
||||
//! @param 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
|
||||
|
|
@ -106,16 +106,16 @@ template< class EOT > class peoPopEval : public Service, public eoPopEvalFunc<EO
|
|||
|
||||
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
|
||||
//! @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;
|
||||
|
|
@ -153,23 +153,23 @@ template< class EOT > void peoPopEval< EOT >::operator()(eoPop< EOT >& __dummy,
|
|||
|
||||
template< class EOT > void peoPopEval< EOT >::operator()(eoPop< EOT >& __pop )
|
||||
{
|
||||
if ( __pop.size() && (funcs.size() * __pop.size()) )
|
||||
{
|
||||
for ( unsigned i = 0; i < __pop.size(); i++ )
|
||||
{
|
||||
__pop[ i ].fitness(typename EOT :: Fitness() );
|
||||
progression[ &__pop[ i ] ].first = funcs.size() - 1;
|
||||
progression[ &__pop[ i ] ].second = funcs.size();
|
||||
for ( unsigned j = 0; j < funcs.size(); j++ )
|
||||
{
|
||||
/* Queuing the 'invalid' solution and its associated owner */
|
||||
tasks.push( &__pop[ i ] );
|
||||
}
|
||||
}
|
||||
total = funcs.size() * __pop.size();
|
||||
requestResourceRequest( funcs.size() * __pop.size() );
|
||||
stop();
|
||||
}
|
||||
if ( __pop.size() && (funcs.size() * __pop.size()) )
|
||||
{
|
||||
for ( unsigned i = 0; i < __pop.size(); i++ )
|
||||
{
|
||||
__pop[ i ].fitness(typename EOT :: Fitness() );
|
||||
progression[ &__pop[ i ] ].first = funcs.size() - 1;
|
||||
progression[ &__pop[ i ] ].second = funcs.size();
|
||||
for ( unsigned j = 0; j < funcs.size(); j++ )
|
||||
{
|
||||
/* Queuing the 'invalid' solution and its associated owner */
|
||||
tasks.push( &__pop[ i ] );
|
||||
}
|
||||
}
|
||||
total = funcs.size() * __pop.size();
|
||||
requestResourceRequest( funcs.size() * __pop.size() );
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
|
||||
//! @class peoSyncIslandMig
|
||||
//! @brief Specific class for a synchronous migration
|
||||
//! @brief Specific class for a synchronous migration
|
||||
//! @see Cooperative eoUpdater
|
||||
//! @version 2.0
|
||||
//! @date january 2008
|
||||
|
|
@ -74,10 +74,10 @@ template< class TYPESELECT, class TYPEREPLACE > class peoSyncIslandMig : public
|
|||
public:
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param unsigned __frequency
|
||||
//! @param selector <TYPESELECT> & __select
|
||||
//! @param replacement <TYPEREPLACE> & __replace
|
||||
//! @param Topology& __topology
|
||||
//! @param unsigned __frequency
|
||||
//! @param selector <TYPESELECT> & __select
|
||||
//! @param replacement <TYPEREPLACE> & __replace
|
||||
//! @param Topology& __topology
|
||||
peoSyncIslandMig(
|
||||
unsigned __frequency,
|
||||
selector <TYPESELECT> & __select,
|
||||
|
|
@ -87,19 +87,19 @@ template< class TYPESELECT, class TYPEREPLACE > class peoSyncIslandMig : public
|
|||
|
||||
//! @brief operator
|
||||
void operator()();
|
||||
//! @brief Function realizing packages
|
||||
//! @brief Function realizing packages
|
||||
void pack();
|
||||
//! @brief Function reconstituting packages
|
||||
void unpack();
|
||||
//! @brief Function packSynchronizeReq
|
||||
void packSynchronizeReq();
|
||||
//! @brief Function notifySending
|
||||
//! @brief Function notifySending
|
||||
void notifySending();
|
||||
//! @brief Function notifyReceiving
|
||||
//! @brief Function notifyReceiving
|
||||
void notifyReceiving();
|
||||
//! @brief notifySendingSyncReq
|
||||
//! @brief notifySendingSyncReq
|
||||
void notifySendingSyncReq();
|
||||
//! @brief notifySynchronized
|
||||
//! @brief notifySynchronized
|
||||
void notifySynchronized();
|
||||
|
||||
private:
|
||||
|
|
@ -109,22 +109,22 @@ template< class TYPESELECT, class TYPEREPLACE > class peoSyncIslandMig : public
|
|||
|
||||
|
||||
private:
|
||||
//! @param eoSyncContinue cont
|
||||
//! @param selector <TYPESELECT> & select
|
||||
//! @param replacement <TYPEREPLACE> & replace
|
||||
//! @param Topology& topology
|
||||
//! @param std :: queue< TYPEREPLACE > imm
|
||||
//! @param std :: queue< TYPESELECT > 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 <TYPESELECT> & select;
|
||||
replacement <TYPEREPLACE> & replace;
|
||||
Topology& topology;
|
||||
//! @param eoSyncContinue cont
|
||||
//! @param selector <TYPESELECT> & select
|
||||
//! @param replacement <TYPEREPLACE> & replace
|
||||
//! @param Topology& topology
|
||||
//! @param std :: queue< TYPEREPLACE > imm
|
||||
//! @param std :: queue< TYPESELECT > 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 <TYPESELECT> & select;
|
||||
replacement <TYPEREPLACE> & replace;
|
||||
Topology& topology;
|
||||
std :: queue< TYPEREPLACE > imm;
|
||||
std :: queue< TYPESELECT > em;
|
||||
std :: queue< Cooperative* > coop_em;
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ template< class EOT > class peoTransform : public Service, public eoTransform< E
|
|||
|
||||
public:
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param eoQuadOp< EOT >& __cross
|
||||
//! @param double __cross_rate
|
||||
//! @param eoMonOp< EOT >& __mut
|
||||
//! @param double __mut_rate
|
||||
//! @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,
|
||||
|
|
@ -67,34 +67,34 @@ template< class EOT > class peoTransform : public Service, public eoTransform< E
|
|||
double __mut_rate
|
||||
);
|
||||
|
||||
//! @brief Operator
|
||||
//! @param eoPop< EOT >& __pop
|
||||
//! @brief Operator
|
||||
//! @param eoPop< EOT >& __pop
|
||||
void operator()( eoPop< EOT >& __pop );
|
||||
//! @brief Function realizing packages of data
|
||||
//! @brief Function realizing packages of data
|
||||
void packData();
|
||||
//! @brief Function reconstituting packages of data
|
||||
//! @brief Function reconstituting packages of data
|
||||
void unpackData();
|
||||
//! @brief Function which executes the algorithm
|
||||
//! @brief Function which executes the algorithm
|
||||
void execute();
|
||||
//! @brief Function realizing packages of the result
|
||||
//! @brief Function realizing packages of the result
|
||||
void packResult();
|
||||
//! @brief Function reconstituting packages of result
|
||||
//! @brief Function reconstituting packages of result
|
||||
void unpackResult();
|
||||
//! @brief Function notifySendingData
|
||||
//! @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
|
||||
//! @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;
|
||||
|
|
|
|||
|
|
@ -51,39 +51,39 @@ class peoWrapper : public Runner
|
|||
|
||||
public:
|
||||
|
||||
//! @brief constructor
|
||||
//! @param AlgorithmType& externalAlgorithm
|
||||
//! @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
|
||||
//! @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)()
|
||||
//! @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
|
||||
//! @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
|
||||
|
||||
//! @brief destructor
|
||||
~peoWrapper()
|
||||
{
|
||||
delete algorithm;
|
||||
}
|
||||
|
||||
//! @brief function run
|
||||
//! @brief function run
|
||||
void run()
|
||||
{
|
||||
algorithm->operator()();
|
||||
|
|
@ -166,7 +166,7 @@ class peoWrapper : public Runner
|
|||
};
|
||||
|
||||
private:
|
||||
//! @param AbstractAlgorithm* algorithm
|
||||
//! @param AbstractAlgorithm* algorithm
|
||||
AbstractAlgorithm* algorithm;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -65,10 +65,14 @@ struct SyncCompare
|
|||
std::vector< SyncEntry >::const_iterator itA = syncA.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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ int main (int __argc, char *__argv[])
|
|||
{
|
||||
peo :: init( __argc, __argv );
|
||||
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);
|
||||
RingTopology topology;
|
||||
eoGenContinue < Indi > genContPara (10);
|
||||
|
|
@ -63,7 +63,8 @@ int main (int __argc, char *__argv[])
|
|||
eoSegmentCrossover<Indi> crossover;
|
||||
eoUniformMutation<Indi> mutation(0.01);
|
||||
peoTransform<Indi> transform(crossover,0.8,mutation,0.3);
|
||||
/*p*/eoPop < Indi > pop;
|
||||
/*p*/
|
||||
eoPop < Indi > pop;
|
||||
pop.append (10, random);
|
||||
eoPlusReplacement<Indi> replace;
|
||||
eoRandomSelect<Indi> mig_select_one;
|
||||
|
|
@ -90,7 +91,8 @@ int main (int __argc, char *__argv[])
|
|||
eoSegmentCrossover<Indi> crossover2;
|
||||
eoUniformMutation<Indi> mutation2(0.01);
|
||||
peoTransform<Indi> transform2(crossover2,0.8,mutation2,0.3);
|
||||
/*p*/eoPop < Indi > pop2;
|
||||
/*p*/
|
||||
eoPop < Indi > pop2;
|
||||
pop2.append (10, random2);
|
||||
eoPlusReplacement<Indi> replace2;
|
||||
eoRandomSelect<Indi> mig_select_one2;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ int main (int __argc, char *__argv[])
|
|||
{
|
||||
peo :: init( __argc, __argv );
|
||||
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);
|
||||
RingTopology topology;
|
||||
eoGenContinue < Indi > genContPara (10);
|
||||
|
|
|
|||
|
|
@ -39,5 +39,5 @@
|
|||
|
||||
int main (int __argc, char *__argv[])
|
||||
{
|
||||
system("mpdallexit");
|
||||
system("mpdallexit");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,5 +39,5 @@
|
|||
|
||||
int main (int __argc, char *__argv[])
|
||||
{
|
||||
system("mpdboot");
|
||||
system("mpdboot");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,29 +39,29 @@
|
|||
|
||||
#include <peo>
|
||||
|
||||
struct Algorithm
|
||||
{
|
||||
void operator()(double & _d)
|
||||
{
|
||||
_d = _d * _d;
|
||||
}
|
||||
};
|
||||
struct Algorithm
|
||||
{
|
||||
void operator()(double & _d)
|
||||
{
|
||||
_d = _d * _d;
|
||||
}
|
||||
};
|
||||
|
||||
int main (int __argc, char * * __argv)
|
||||
{
|
||||
|
||||
peo :: init (__argc, __argv);
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n\nTest : multistart\n\n";
|
||||
std::cout<<"\n\nTest : multistart\n\n";
|
||||
std::vector < double > v;
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n\nBefore :";
|
||||
for(unsigned i = 0; i< 10; i++)
|
||||
{
|
||||
v.push_back(i);
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n"<<v[i];
|
||||
}
|
||||
std::cout<<"\n\nBefore :";
|
||||
for (unsigned i = 0; i< 10; i++)
|
||||
{
|
||||
v.push_back(i);
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n"<<v[i];
|
||||
}
|
||||
Algorithm algo;
|
||||
peoMultiStart < double > initParallel (algo);
|
||||
peoWrapper parallelAlgo (initParallel, v);
|
||||
|
|
@ -69,9 +69,9 @@ int main (int __argc, char * * __argv)
|
|||
peo :: run( );
|
||||
peo :: finalize( );
|
||||
if (getNodeRank()==1)
|
||||
{
|
||||
std::cout<<"\n\nAfter :\n";
|
||||
for(unsigned i = 0; i< 10; i++)
|
||||
std::cout<<v[i]<<"\n";
|
||||
}
|
||||
{
|
||||
std::cout<<"\n\nAfter :\n";
|
||||
for (unsigned i = 0; i< 10; i++)
|
||||
std::cout<<v[i]<<"\n";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ int main (int __argc, char *__argv[])
|
|||
{
|
||||
peo :: init( __argc, __argv );
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n\nTest : PSO Global Best\n\n";
|
||||
std::cout<<"\n\nTest : PSO Global Best\n\n";
|
||||
rng.reseed (10);
|
||||
RingTopology topologyMig;
|
||||
eoGenContinue < Indi > genContPara (10);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ int main (int __argc, char *__argv[])
|
|||
{
|
||||
peo :: init( __argc, __argv );
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n\nTest : PSO Worst Position\n\n";
|
||||
std::cout<<"\n\nTest : PSO Worst Position\n\n";
|
||||
rng.reseed (10);
|
||||
RingTopology topologyMig;
|
||||
eoGenContinue < Indi > genContPara (10);
|
||||
|
|
|
|||
|
|
@ -44,22 +44,22 @@ double f (const Indi & _indi)
|
|||
double sum=_indi[0]+_indi[1];
|
||||
return (-sum);
|
||||
}
|
||||
struct Algorithm
|
||||
{
|
||||
Algorithm( peoPopEval < Indi > & _eval): eval( _eval ){}
|
||||
void operator()(eoPop < Indi > & _pop)
|
||||
{
|
||||
eoPop < Indi > empty_pop;
|
||||
eval(empty_pop, _pop);
|
||||
}
|
||||
peoPopEval < Indi > & eval;
|
||||
};
|
||||
struct Algorithm
|
||||
{
|
||||
Algorithm( peoPopEval < Indi > & _eval): eval( _eval ){}
|
||||
void operator()(eoPop < Indi > & _pop)
|
||||
{
|
||||
eoPop < Indi > empty_pop;
|
||||
eval(empty_pop, _pop);
|
||||
}
|
||||
peoPopEval < Indi > & eval;
|
||||
};
|
||||
|
||||
int main (int __argc, char *__argv[])
|
||||
{
|
||||
peo :: init( __argc, __argv );
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n\nTest : parallel evaluation\n\n";
|
||||
std::cout<<"\n\nTest : parallel evaluation\n\n";
|
||||
rng.reseed (10);
|
||||
peoEvalFunc<Indi, double, const Indi& > plainEval(f);
|
||||
peoPopEval< Indi > eval(plainEval);
|
||||
|
|
@ -72,8 +72,8 @@ int main (int __argc, char *__argv[])
|
|||
peo :: run();
|
||||
peo :: finalize();
|
||||
if (getNodeRank()==1)
|
||||
{
|
||||
{
|
||||
pop.sort();
|
||||
std::cout<<pop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,35 +44,35 @@ double f (const Indi & _indi)
|
|||
double sum=_indi[0]+_indi[1];
|
||||
return (-sum);
|
||||
}
|
||||
struct Algorithm
|
||||
{
|
||||
Algorithm( eoEvalFunc < Indi > & _eval, eoSelect < Indi > & _select, peoTransform < Indi > & _transform):
|
||||
loopEval(_eval),
|
||||
struct Algorithm
|
||||
{
|
||||
Algorithm( eoEvalFunc < Indi > & _eval, eoSelect < Indi > & _select, peoTransform < Indi > & _transform):
|
||||
loopEval(_eval),
|
||||
eval(loopEval),
|
||||
selectTransform( _select, _transform),
|
||||
breed(selectTransform) {}
|
||||
|
||||
void operator()(eoPop < Indi > & _pop)
|
||||
{
|
||||
eoPop < Indi > offspring, empty_pop;
|
||||
eval(empty_pop, _pop);
|
||||
eval(empty_pop, offspring);
|
||||
std::cout<<"\n\nBefore :\n"<<offspring;
|
||||
breed(_pop, offspring);
|
||||
eval(empty_pop, offspring);
|
||||
std::cout<<"\n\nAfter :\n"<<offspring;
|
||||
}
|
||||
eoPopLoopEval < Indi > loopEval;
|
||||
selectTransform( _select, _transform),
|
||||
breed(selectTransform) {}
|
||||
|
||||
void operator()(eoPop < Indi > & _pop)
|
||||
{
|
||||
eoPop < Indi > offspring, empty_pop;
|
||||
eval(empty_pop, _pop);
|
||||
eval(empty_pop, offspring);
|
||||
std::cout<<"\n\nBefore :\n"<<offspring;
|
||||
breed(_pop, offspring);
|
||||
eval(empty_pop, offspring);
|
||||
std::cout<<"\n\nAfter :\n"<<offspring;
|
||||
}
|
||||
eoPopLoopEval < Indi > loopEval;
|
||||
eoPopEvalFunc < Indi > & eval;
|
||||
eoSelectTransform < Indi > selectTransform;
|
||||
eoSelectTransform < Indi > selectTransform;
|
||||
eoBreed < Indi > & breed;
|
||||
};
|
||||
};
|
||||
|
||||
int main (int __argc, char *__argv[])
|
||||
{
|
||||
peo :: init( __argc, __argv );
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n\nTest : parallel transform\n\n";
|
||||
std::cout<<"\n\nTest : parallel transform\n\n";
|
||||
rng.reseed (10);
|
||||
eoEvalFuncPtr < Indi > plainEval(f);
|
||||
eoEvalFuncCounter < Indi > eval(plainEval);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ int main (int __argc, char *__argv[])
|
|||
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 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_MAX = parser.createParam(2.0, "pMax", "Init position max",'X',"Param").value();
|
||||
rng.reseed (time(0));
|
||||
|
|
@ -88,7 +88,7 @@ int main (int __argc, char *__argv[])
|
|||
eoSelectNumber<Indi> select(selectionStrategy,POP_SIZE);
|
||||
|
||||
// Transformation
|
||||
eoSegmentCrossover<Indi> crossover;
|
||||
eoSegmentCrossover<Indi> crossover;
|
||||
eoUniformMutation<Indi> mutation(EPSILON);
|
||||
eoSGATransform<Indi> transform(crossover,CROSS_RATE,mutation,MUT_RATE);
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ int main (int __argc, char *__argv[])
|
|||
eoParser parser(__argc, __argv);
|
||||
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 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_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();
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ int main (int __argc, char *__argv[])
|
|||
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 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_MAX = parser.createParam(2.0, "pMax", "Init position max",'X',"Param").value();
|
||||
rng.reseed (time(0));
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ int main (int __argc, char *__argv[])
|
|||
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 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_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();
|
||||
|
|
@ -85,9 +85,9 @@ int main (int __argc, char *__argv[])
|
|||
peoTransform<Indi> transform(crossover,CROSS_RATE,mutation,MUT_RATE);
|
||||
eoPop < Indi > pop;
|
||||
pop.append (POP_SIZE, random);
|
||||
|
||||
|
||||
// Define a synchronous island
|
||||
|
||||
|
||||
// Seclection
|
||||
eoRandomSelect<Indi> mig_select_one;
|
||||
eoSelector <Indi, eoPop<Indi> > mig_select (mig_select_one,MIG_SIZE,pop);
|
||||
|
|
@ -97,7 +97,7 @@ int main (int __argc, char *__argv[])
|
|||
// Island
|
||||
peoSyncIslandMig<eoPop<Indi>, eoPop<Indi> > mig(MIG_FREQ,mig_select,mig_replace,topology);
|
||||
checkpoint.add(mig);
|
||||
|
||||
|
||||
eoEasyEA< Indi > eaAlg( checkpoint, eval, select, transform, replace );
|
||||
peoWrapper parallelEA( eaAlg, pop);
|
||||
eval.setOwner(parallelEA);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ int main (int __argc, char *__argv[])
|
|||
eoParser parser(__argc, __argv);
|
||||
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 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_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();
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
{
|
||||
|
||||
std :: set <unsigned> & neigh = __map [__vertex] ;
|
||||
std :: set <unsigned> & neigh = __map [__vertex] ;
|
||||
|
||||
for (std :: set <unsigned> :: iterator it = neigh.begin () ;
|
||||
it != neigh.end () ;
|
||||
it ++)
|
||||
__map [* it].erase (__vertex) ;
|
||||
for (std :: set <unsigned> :: iterator it = neigh.begin () ;
|
||||
it != neigh.end () ;
|
||||
it ++)
|
||||
__map [* it].erase (__vertex) ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void EdgeXover :: add_vertex (unsigned __vertex, Route & __child)
|
||||
{
|
||||
|
|
@ -104,24 +104,24 @@ void EdgeXover :: cross (const Route & __par1, const Route & __par2, Route & __c
|
|||
std :: set <unsigned> & neigh = _map [cur_vertex] ;
|
||||
|
||||
for (std :: set <unsigned> :: iterator it = neigh.begin () ;
|
||||
it != neigh.end () ;
|
||||
it ++)
|
||||
{
|
||||
unsigned l = _map [* it].size () ;
|
||||
if (len_min_entry > l)
|
||||
len_min_entry = l ;
|
||||
}
|
||||
it != neigh.end () ;
|
||||
it ++)
|
||||
{
|
||||
unsigned l = _map [* it].size () ;
|
||||
if (len_min_entry > l)
|
||||
len_min_entry = l ;
|
||||
}
|
||||
|
||||
std :: vector <unsigned> cand ; /* Candidates */
|
||||
|
||||
for (std :: set <unsigned> :: iterator it = neigh.begin () ;
|
||||
it != neigh.end () ;
|
||||
it ++)
|
||||
{
|
||||
unsigned l = _map [* it].size () ;
|
||||
if (len_min_entry == l)
|
||||
cand.push_back (* it) ;
|
||||
}
|
||||
it != neigh.end () ;
|
||||
it ++)
|
||||
{
|
||||
unsigned l = _map [* it].size () ;
|
||||
if (len_min_entry == l)
|
||||
cand.push_back (* it) ;
|
||||
}
|
||||
|
||||
if (! cand.size ())
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue