Addition of the function PSO : Parallel evaluation

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@650 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
canape 2007-10-08 08:06:19 +00:00
commit 43fbde1096
9 changed files with 161 additions and 23 deletions

View file

@ -0,0 +1,82 @@
// "peoPSO.h"
// (c) OPAC Team, October 2007
/*
Contact: clive.canape@inria.fr
*/
#ifndef __peoPSO_h
#define __peoPSO_h
#include <eoContinue.h>
#include <eoEvalFunc.h>
#include <eoPopEvalFunc.h>
#include <eoPSO.h>
#include <eoVelocity.h>
#include <eoFlight.h>
#include "peoPopEval.h"
#include "core/runner.h"
#include "core/peo_debug.h"
template < class POT > class peoPSO : public Runner {
public:
peoPSO(
eoContinue< POT >& __cont,
peoPopEval< POT >& __pop_eval,
eoVelocity < POT > &_velocity,
eoFlight < POT > &_flight);
void run();
void operator()( eoPop< POT >& __pop );
private:
eoContinue< POT >& cont;
peoPopEval< POT >& pop_eval;
eoPop< POT >* pop;
eoVelocity < POT > &velocity;
eoFlight < POT > &flight;
};
template < class POT > peoPSO< POT > :: peoPSO(
eoContinue< POT >& __cont,
peoPopEval< POT >& __pop_eval,
eoVelocity < POT > &__velocity,
eoFlight < POT > &__flight
) : cont( __cont ), pop_eval(__pop_eval ),velocity( __velocity),flight( __flight)
{
pop_eval.setOwner( *this );
}
template< class POT > void peoPSO< POT > :: operator ()( eoPop< POT >& __pop ) {
pop = &__pop;
}
template< class POT > void peoPSO< POT > :: run() {
printDebugMessage( "Performing the first evaluation of the population." );
do {
printDebugMessage( "Performing the velocity evaluation." );
velocity.apply ( *pop );
printDebugMessage( "Performing the flight." );
flight.apply ( *pop );
printDebugMessage( "Performing the evaluation." );
pop_eval(*pop);
velocity.updateNeighborhood( *pop );
} while ( cont( *pop ) );
}
#endif