don't need parallel PSO
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@693 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
84dfebabc1
commit
3e04ef220b
2 changed files with 0 additions and 125 deletions
|
|
@ -1,40 +0,0 @@
|
|||
// "peoEvalFuncPSO.h"
|
||||
|
||||
// (c) OPAC Team, October 2007
|
||||
|
||||
/*
|
||||
Contact: clive.canape@inria.fr
|
||||
*/
|
||||
|
||||
#ifndef PEOEVALFUNCPSO_H
|
||||
#define PEOEVALFUNCPSO_H
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
/** peoEvalFuncPSO: This class
|
||||
* takes an existing function pointer and converts it into a evaluation
|
||||
* function class.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
template< class POT, class FitT = POT::Fitness, class FunctionArg = const POT& >
|
||||
#else
|
||||
template< class POT, class FitT = typename POT::Fitness, class FunctionArg = const POT& >
|
||||
#endif
|
||||
struct peoEvalFuncPSO: public eoEvalFunc<POT> {
|
||||
|
||||
peoEvalFuncPSO( FitT (* _eval)( FunctionArg ) )
|
||||
: eoEvalFunc<POT>(), evalFunc( _eval ) {};
|
||||
|
||||
//Applies the evaluation function to a PEO
|
||||
virtual void operator() ( POT & _peo )
|
||||
{
|
||||
_peo.fitness((*evalFunc)( _peo ));
|
||||
};
|
||||
|
||||
private:
|
||||
FitT (* evalFunc )( FunctionArg );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
// "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:
|
||||
|
||||
|
||||
// Constructor for the Particle Swarm Optimization
|
||||
peoPSO(
|
||||
eoContinue< POT >& __cont,
|
||||
peoPopEval< POT >& __pop_eval,
|
||||
eoVelocity < POT > &_velocity,
|
||||
eoFlight < POT > &_flight);
|
||||
|
||||
// Particle Swarm Optimization function - a side effect of the fact that the class is derived from the Runner class
|
||||
// thus requiring the existence of a run function, the algorithm being executed on a distinct thread.
|
||||
void run();
|
||||
|
||||
// Function operator for specifying the population to be associated with the algorithm.
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue