New style for PEO
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@789 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
39709d3d12
commit
9c87b3b0c0
132 changed files with 3781 additions and 3396 deletions
|
|
@ -3,7 +3,7 @@
|
|||
* (c) OPAC Team, October 2007
|
||||
*
|
||||
* Clive Canape
|
||||
*
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
|
|
@ -29,96 +29,101 @@
|
|||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
* Contact: clive.canape@inria.fr
|
||||
*/
|
||||
|
||||
#ifndef __peoPSO_h
|
||||
#define __peoPSO_h
|
||||
|
||||
#include <eoContinue.h>
|
||||
#include <eoEvalFunc.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"
|
||||
#include "core/runner.h"
|
||||
#include "core/peo_debug.h"
|
||||
|
||||
//! Class providing an elementary ParadisEO evolutionary algorithm.
|
||||
|
||||
//! The peoPSO class offers an elementary Particle Swarm Optimization implementation. In addition, as compared
|
||||
//! with the algorithms provided by the EO framework, the peoPSO class has the underlying necessary structure
|
||||
//! for including, for example, parallel evaluation, etc.
|
||||
//! for including, for example, parallel evaluation, etc.
|
||||
|
||||
template < class POT > class peoPSO : public Runner {
|
||||
template < class POT > class peoPSO : public Runner
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
|
||||
//! Constructor for the Particle Swarm Optimization
|
||||
//! @param eoContinue< POT >& __cont - continuation criterion specifying whether the algorithm should continue or not;
|
||||
//! @param peoPopEval< POT >& __pop_eval - evaluation operator; it allows the specification of parallel evaluation operators, aggregate evaluation functions, etc.;
|
||||
//! @param eoVelocity< POT >& __velocity - velocity operator;
|
||||
//! @param eoFlight< POT >& __flight - flight operator;
|
||||
peoPSO(
|
||||
eoInitializerBase <POT> & _Init,
|
||||
eoContinue< POT >& __cont,
|
||||
peoPopEval< POT >& __pop_eval,
|
||||
eoVelocity < POT > &_velocity,
|
||||
eoFlight < POT > &_flight);
|
||||
//! Constructor for the Particle Swarm Optimization
|
||||
//! @param eoContinue< POT >& __cont - continuation criterion specifying whether the algorithm should continue or not;
|
||||
//! @param peoPopEval< POT >& __pop_eval - evaluation operator; it allows the specification of parallel evaluation operators, aggregate evaluation functions, etc.;
|
||||
//! @param eoVelocity< POT >& __velocity - velocity operator;
|
||||
//! @param eoFlight< POT >& __flight - flight operator;
|
||||
peoPSO(
|
||||
eoInitializerBase <POT> & _Init,
|
||||
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 );
|
||||
//! 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();
|
||||
|
||||
private:
|
||||
//! Function operator for specifying the population to be associated with the algorithm.
|
||||
void operator()( eoPop< POT >& __pop );
|
||||
|
||||
eoInitializerBase <POT> & Init;
|
||||
eoContinue< POT >& cont;
|
||||
peoPopEval< POT >& pop_eval;
|
||||
eoPop< POT >* pop;
|
||||
eoVelocity < POT > &velocity;
|
||||
eoFlight < POT > &flight;
|
||||
};
|
||||
private:
|
||||
|
||||
eoInitializerBase <POT> & Init;
|
||||
eoContinue< POT >& cont;
|
||||
peoPopEval< POT >& pop_eval;
|
||||
eoPop< POT >* pop;
|
||||
eoVelocity < POT > &velocity;
|
||||
eoFlight < POT > &flight;
|
||||
};
|
||||
|
||||
|
||||
template < class POT > peoPSO< POT > :: peoPSO(
|
||||
eoInitializerBase <POT> & _Init,
|
||||
eoContinue< POT >& __cont,
|
||||
peoPopEval< POT >& __pop_eval,
|
||||
eoVelocity < POT > &__velocity,
|
||||
eoFlight < POT > &__flight
|
||||
) : Init(_Init),cont( __cont ), pop_eval(__pop_eval ),velocity( __velocity),flight( __flight)
|
||||
template < class POT > peoPSO< POT > :: peoPSO(
|
||||
eoInitializerBase <POT> & _Init,
|
||||
eoContinue< POT >& __cont,
|
||||
peoPopEval< POT >& __pop_eval,
|
||||
eoVelocity < POT > &__velocity,
|
||||
eoFlight < POT > &__flight
|
||||
) : Init(_Init),cont( __cont ), pop_eval(__pop_eval ),velocity( __velocity),flight( __flight)
|
||||
{
|
||||
pop_eval.setOwner( *this );
|
||||
pop_eval.setOwner( *this );
|
||||
}
|
||||
|
||||
|
||||
template< class POT > void peoPSO< POT > :: operator ()( eoPop< POT >& __pop ) {
|
||||
template< class POT > void peoPSO< POT > :: operator ()( eoPop< POT >& __pop )
|
||||
{
|
||||
|
||||
pop = &__pop;
|
||||
pop = &__pop;
|
||||
}
|
||||
|
||||
|
||||
template< class POT > void peoPSO< POT > :: run() {
|
||||
template< class POT > void peoPSO< POT > :: run()
|
||||
{
|
||||
|
||||
printDebugMessage( "Performing the first evaluation of the population." );
|
||||
Init();
|
||||
velocity.getTopology().setup(*pop);
|
||||
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 ) );
|
||||
printDebugMessage( "Performing the first evaluation of the population." );
|
||||
Init();
|
||||
velocity.getTopology().setup(*pop);
|
||||
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 ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue