Parallel initialization for PSO
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@763 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
28223f9ab0
commit
5eb6eb9a09
4 changed files with 139 additions and 7 deletions
|
|
@ -340,6 +340,7 @@
|
|||
#include "peoSyncMultiStart.h"
|
||||
|
||||
/* Parallel PSO */
|
||||
#include "peoInitializer.h"
|
||||
#include "peoPSO.h"
|
||||
#include "peoEvalFuncPSO.h"
|
||||
#include "peoPSOSelect.h"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,40 @@
|
|||
/* "peoEvalFuncPSO.h"
|
||||
/*
|
||||
* <peoEvalFuncPSO.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, INRIA, 2007
|
||||
*
|
||||
*
|
||||
* (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
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: clive.canape@inria.fr
|
||||
*
|
||||
* Contact: clive.canape@inria.fr
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PEOEVALFUNCPSO_H
|
||||
#define PEOEVALFUNCPSO_H
|
||||
|
||||
|
|
|
|||
98
trunk/paradiseo-peo/src/peoInitializer.h
Normal file
98
trunk/paradiseo-peo/src/peoInitializer.h
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* <peoInitializer.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, INRIA, 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
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: clive.canape@inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _peoInitializer_H
|
||||
#define _peoInitializer_H
|
||||
|
||||
/**
|
||||
Base (name) class for parallel initialization of algorithm PSO
|
||||
|
||||
@see eoInitializerBase
|
||||
*/
|
||||
|
||||
template <class POT> class peoInitializer : public eoInitializerBase <POT>
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
//! Constructor
|
||||
//! @param _proc Evaluation function
|
||||
//! @param _initVelo Initialization of the velocity
|
||||
//! @param _initBest Initialization of the best
|
||||
//! @param _pop Population
|
||||
peoInitializer(
|
||||
peoPopEval< POT >& _proc,
|
||||
eoVelocityInit < POT > &_initVelo,
|
||||
eoParticleBestInit <POT> &_initBest,
|
||||
eoPop < POT > &_pop
|
||||
) : proc(_proc), initVelo(_initVelo), initBest(_initBest)
|
||||
{
|
||||
pop = &_pop;
|
||||
}
|
||||
|
||||
//! Give the name of the class
|
||||
//! @return The name of the class
|
||||
virtual std::string className (void) const
|
||||
{
|
||||
return "peoInitializer";
|
||||
}
|
||||
|
||||
//! void operator ()
|
||||
//! Parallel initialization of the population
|
||||
virtual void operator()()
|
||||
{
|
||||
proc(*pop);
|
||||
apply < POT > (initVelo, *pop);
|
||||
apply < POT > (initBest, *pop);
|
||||
}
|
||||
|
||||
private :
|
||||
|
||||
/*
|
||||
@param proc First evaluation
|
||||
@param initVelo Initialization of the velocity
|
||||
@param initBest Initialization of the best
|
||||
@param pop Population
|
||||
*/
|
||||
peoPopEval< POT >& proc;
|
||||
eoVelocityInit < POT > & initVelo;
|
||||
eoParticleBestInit <POT> & initBest;
|
||||
eoPop <POT> * pop;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
@ -63,6 +63,7 @@ public:
|
|||
//! @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,
|
||||
|
|
@ -77,6 +78,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
eoInitializerBase <POT> & Init;
|
||||
eoContinue< POT >& cont;
|
||||
peoPopEval< POT >& pop_eval;
|
||||
eoPop< POT >* pop;
|
||||
|
|
@ -86,12 +88,12 @@ private:
|
|||
|
||||
|
||||
template < class POT > peoPSO< POT > :: peoPSO(
|
||||
|
||||
eoInitializerBase <POT> & _Init,
|
||||
eoContinue< POT >& __cont,
|
||||
peoPopEval< POT >& __pop_eval,
|
||||
eoVelocity < POT > &__velocity,
|
||||
eoFlight < POT > &__flight
|
||||
) : cont( __cont ), pop_eval(__pop_eval ),velocity( __velocity),flight( __flight)
|
||||
) : Init(_Init),cont( __cont ), pop_eval(__pop_eval ),velocity( __velocity),flight( __flight)
|
||||
{
|
||||
pop_eval.setOwner( *this );
|
||||
}
|
||||
|
|
@ -106,8 +108,10 @@ template< class POT > void peoPSO< POT > :: operator ()( eoPop< POT >& __pop ) {
|
|||
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." );
|
||||
printDebugMessage( "Performing the velocity evaluation." );
|
||||
velocity.apply ( *pop );
|
||||
printDebugMessage( "Performing the flight." );
|
||||
flight.apply ( *pop );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue