For the wrapper ...
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@831 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
0fb60a67ca
commit
4116f0a7ac
7 changed files with 49 additions and 20 deletions
|
|
@ -80,8 +80,15 @@ template <class F, class T> void unpack (eoVector <F, T> & __v) {
|
|||
|
||||
template <class F, class T, class V> void pack (const eoVectorParticle <F, T, V> & __v) {
|
||||
|
||||
pack (__v.fitness ()) ;
|
||||
pack (__v.best());
|
||||
if (__v.invalid()) {
|
||||
pack((unsigned)0);
|
||||
}
|
||||
else {
|
||||
pack((unsigned)1);
|
||||
pack (__v.fitness ());
|
||||
pack (__v.best());
|
||||
}
|
||||
|
||||
unsigned len = __v.size ();
|
||||
pack (len);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
|
|
@ -94,11 +101,19 @@ template <class F, class T, class V> void pack (const eoVectorParticle <F, T, V>
|
|||
|
||||
template <class F, class T, class V> void unpack (eoVectorParticle <F, T, V> & __v) {
|
||||
|
||||
F fit;
|
||||
unpack(fit);
|
||||
__v.fitness (fit);
|
||||
unpack(fit);
|
||||
unsigned valid; unpack(valid);
|
||||
|
||||
if (! valid) {
|
||||
__v.invalidate();
|
||||
}
|
||||
else {
|
||||
F fit;
|
||||
unpack (fit);
|
||||
__v.fitness (fit);
|
||||
unpack(fit);
|
||||
__v.best(fit);
|
||||
|
||||
}
|
||||
unsigned len;
|
||||
unpack (len);
|
||||
__v.resize (len);
|
||||
|
|
|
|||
|
|
@ -150,8 +150,9 @@ template< class EOT > void peoEA< EOT > :: operator ()( eoPop< EOT >& __pop )
|
|||
template< class EOT > void peoEA< EOT > :: run()
|
||||
{
|
||||
|
||||
eoPop< EOT > dummy;
|
||||
printDebugMessage( "peoEA: performing the first evaluation of the population." );
|
||||
pop_eval( *pop );
|
||||
pop_eval(dummy, *pop );
|
||||
|
||||
do
|
||||
{
|
||||
|
|
@ -164,7 +165,7 @@ template< class EOT > void peoEA< EOT > :: run()
|
|||
|
||||
printDebugMessage( "peoEA: performing the evaluation of the population." );
|
||||
|
||||
pop_eval( off );
|
||||
pop_eval(dummy, off );
|
||||
|
||||
printDebugMessage( "peoEA: performing the replacement of the population." );
|
||||
replace( *pop, off );
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ template <class POT> class peoInitializer : public eoInitializerBase <POT>
|
|||
//! Parallel initialization of the population
|
||||
virtual void operator()()
|
||||
{
|
||||
proc(*pop);
|
||||
proc(dummyPop,*pop);
|
||||
apply < POT > (initVelo, *pop);
|
||||
apply < POT > (initBest, *pop);
|
||||
}
|
||||
|
|
@ -91,6 +91,7 @@ template <class POT> class peoInitializer : public eoInitializerBase <POT>
|
|||
eoVelocityInit < POT > & initVelo;
|
||||
eoParticleBestInit <POT> & initBest;
|
||||
eoPop <POT> * pop;
|
||||
eoPop< POT > dummyPop;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ template< class POT > void peoPSO< POT > :: operator ()( eoPop< POT >& __pop )
|
|||
|
||||
template< class POT > void peoPSO< POT > :: run()
|
||||
{
|
||||
|
||||
eoPop< POT > dummy;
|
||||
printDebugMessage( "Performing the first evaluation of the population." );
|
||||
Init();
|
||||
velocity.getTopology().setup(*pop);
|
||||
|
|
@ -120,7 +120,7 @@ template< class POT > void peoPSO< POT > :: run()
|
|||
printDebugMessage( "Performing the flight." );
|
||||
flight.apply ( *pop );
|
||||
printDebugMessage( "Performing the evaluation." );
|
||||
pop_eval(*pop);
|
||||
pop_eval(dummy,*pop);
|
||||
velocity.updateNeighborhood( *pop );
|
||||
}
|
||||
while ( cont( *pop ) );
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@ template< class EOT > class peoParaPopEval : public peoPopEval< EOT >
|
|||
//! Operator for applying the evaluation functor (direct or aggregate) for each individual of the specified population.
|
||||
//!
|
||||
//! @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);
|
||||
void operator()( eoPop< EOT >& __dummy, eoPop< EOT >& __pop );
|
||||
|
||||
//! Auxiliary function for transferring data between the process requesting an evaluation operation and the process that
|
||||
//! performs the actual evaluation phase. There is no need to explicitly call the function.
|
||||
|
|
@ -145,8 +146,12 @@ template< class EOT > peoParaPopEval< EOT > :: peoParaPopEval(
|
|||
) : funcs( __funcs ), merge_eval( __merge_eval )
|
||||
{}
|
||||
|
||||
template< class EOT > void peoParaPopEval< EOT >::operator()(eoPop< EOT >& __dummy, eoPop< EOT >& __pop )
|
||||
{
|
||||
this->operator()(__pop);
|
||||
}
|
||||
|
||||
template< class EOT > void peoParaPopEval< EOT >::operator()( eoPop< EOT >& __pop )
|
||||
template< class EOT > void peoParaPopEval< EOT >::operator()(eoPop< EOT >& __pop )
|
||||
{
|
||||
for ( unsigned i = 0; i < __pop.size(); i++ )
|
||||
{
|
||||
|
|
@ -166,7 +171,7 @@ template< class EOT > void peoParaPopEval< EOT >::operator()( eoPop< EOT >& __po
|
|||
|
||||
|
||||
template< class EOT > void peoParaPopEval< EOT > :: packData()
|
||||
{
|
||||
{
|
||||
// printDebugMessage ("debut pakc data");
|
||||
pack( progression[ tasks.front() ].first-- );
|
||||
|
||||
|
|
@ -180,7 +185,7 @@ template< class EOT > void peoParaPopEval< EOT > :: packData()
|
|||
|
||||
|
||||
template< class EOT > void peoParaPopEval< EOT > :: unpackData()
|
||||
{
|
||||
{
|
||||
unpack( num_func );
|
||||
/* Unpacking the solution */
|
||||
unpack( sol );
|
||||
|
|
@ -191,13 +196,14 @@ template< class EOT > void peoParaPopEval< EOT > :: unpackData()
|
|||
|
||||
template< class EOT > void peoParaPopEval< EOT > :: execute()
|
||||
{
|
||||
|
||||
/* Computing the fitness of the solution */
|
||||
funcs[ num_func ]->operator()( sol );
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoParaPopEval< EOT > :: packResult()
|
||||
{
|
||||
{
|
||||
/* Packing the fitness of the solution */
|
||||
pack( sol.fitness() );
|
||||
/* Packing the @ of the individual */
|
||||
|
|
@ -206,7 +212,7 @@ template< class EOT > void peoParaPopEval< EOT > :: packResult()
|
|||
|
||||
|
||||
template< class EOT > void peoParaPopEval< EOT > :: unpackResult()
|
||||
{
|
||||
{
|
||||
typename EOT :: Fitness fit;
|
||||
|
||||
/* Unpacking the computed fitness */
|
||||
|
|
@ -243,7 +249,7 @@ template< class EOT > void peoParaPopEval< EOT > :: notifySendingData()
|
|||
|
||||
|
||||
template< class EOT > void peoParaPopEval< EOT > :: notifySendingAllResourceRequests()
|
||||
{
|
||||
{
|
||||
getOwner()->setPassive();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,13 +44,14 @@
|
|||
//! The <b>peoPopEval</b> class provides the interface for constructing ParadisEO specific evaluation functors.
|
||||
//! The derived classes may be used as wrappers for <b>EO</b>-derived evaluation functors. In order to have an example,
|
||||
//! please refer to the implementation of the <b>peoSeqPopEval</b> and <b>peoParaPopEval</b> classes.
|
||||
template< class EOT > class peoPopEval : public Service
|
||||
template< class EOT > class peoPopEval : public Service, public eoPopEvalFunc<EOT>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Interface function providing the signature for constructing an evaluation functor.
|
||||
virtual void operator()( eoPop< EOT >& __pop ) = 0;
|
||||
virtual void operator()( eoPop< EOT >& __tmp, eoPop< EOT >& __pop )=0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ template< class EOT > class peoSeqPopEval : public peoPopEval< EOT >
|
|||
//!
|
||||
//! @param eoPop< EOT >& __pop - population to be evaluated.
|
||||
void operator()( eoPop< EOT >& __pop );
|
||||
void operator()( eoPop< EOT > &__dummy,eoPop< EOT >&__pop);
|
||||
|
||||
private:
|
||||
|
||||
|
|
@ -70,6 +71,10 @@ template< class EOT > class peoSeqPopEval : public peoPopEval< EOT >
|
|||
template< class EOT > peoSeqPopEval< EOT > :: peoSeqPopEval( eoEvalFunc< EOT >& __eval ) : eval( __eval )
|
||||
{}
|
||||
|
||||
template< class EOT > void peoSeqPopEval< EOT > :: operator()( eoPop< EOT >& __dummy,eoPop< EOT >& __pop )
|
||||
{
|
||||
this->operator()(__pop);
|
||||
}
|
||||
|
||||
template< class EOT > void peoSeqPopEval< EOT > :: operator()( eoPop< EOT >& __pop )
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue