From f532a3f109b241744f3bb2cbecdf1acf80646aa5 Mon Sep 17 00:00:00 2001 From: tlegrand Date: Wed, 5 Mar 2008 09:41:24 +0000 Subject: [PATCH] deleted old customized LL/SS PSO algorithms --- eo/src/eo | 4 +- eo/src/eoLSPSO.h | 184 ----------------------------------------------- eo/src/eoSSPSO.h | 168 ------------------------------------------- 3 files changed, 1 insertion(+), 355 deletions(-) delete mode 100644 eo/src/eoLSPSO.h delete mode 100644 eo/src/eoSSPSO.h diff --git a/eo/src/eo b/eo/src/eo index 4ed64f9b4..0d79e6f13 100644 --- a/eo/src/eo +++ b/eo/src/eo @@ -185,9 +185,7 @@ // PS algorithms #include -#include -#include -#include +#include #include // utils diff --git a/eo/src/eoLSPSO.h b/eo/src/eoLSPSO.h deleted file mode 100644 index adfe11122..000000000 --- a/eo/src/eoLSPSO.h +++ /dev/null @@ -1,184 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// eoLSPSO.h -// (c) OPAC 2007 -/* - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Contact: thomas.legrand@lifl.fr - */ -//----------------------------------------------------------------------------- - -#ifndef _EOLSPSO_H -#define _EOLSPSO_H - -//----------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include -#include -//----------------------------------------------------------------------------- - -/** - * A Linear ("L"inear topology) Standard ("S"tandard velocity) PSO. - * You can use it with or without bounds on the velocity. - * No bound for the flight (no bounds for the positions). - * - */ -template < class POT > class eoLSPSO:public eoPSO < POT > -{ -public: - - - typedef typename POT::ParticleVelocityType VelocityType; - - /** Full constructor - * @param _continuator - An eoContinue that manages the stopping criterion and the checkpointing system - * @param _eval - An eoEvalFunc: the evaluation performer - * @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType - * @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType - * @param _neighborhoodSize - The size of each neighborhood of the linear topology - * @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities. - * If the velocities are not real, they won't be bounded by default. Should have a eoBounds ? - * @param _boundsModifier - An eoRealBoundModifier used to modify the bounds (for real bounds only) - */ - eoLSPSO ( - eoContinue < POT > &_continuator, - eoEvalFunc < POT > &_eval, - const VelocityType & _c1, - const VelocityType & _c2 , - const unsigned _neighborhoodSize, - eoRealVectorBounds & _bounds, - eoRealBoundModifier & _bndsModifier): - continuator (_continuator), - eval (_eval), - topology(eoLinearTopology(_neighborhoodSize)), - velocity(eoStandardVelocity(topology,_c1,_c2,_bounds,_bndsModifier)), - neighborhoodSize(_neighborhoodSize), - bounds(_bounds), - boundsModifier(_bndsModifier) - {} - - /** Constructor without bound modifier. - * @param _continuator - An eoContinue that manages the stopping criterion and the checkpointing system - * @param _eval - An eoEvalFunc: the evaluation performer - * @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType - * @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType - * @param _neighborhoodSize - The size of each neighborhood of the linear topology - * @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities. - * If the velocities are not real, they won't be bounded by default. Should have a eoBounds ? - */ - eoLSPSO ( - eoContinue < POT > &_continuator, - eoEvalFunc < POT > &_eval, - const VelocityType & _c1, - const VelocityType & _c2 , - const unsigned _neighborhoodSize, - eoRealVectorBounds & _bounds): - continuator (_continuator), - eval (_eval), - topology(eoLinearTopology(_neighborhoodSize)), - velocity(eoStandardVelocity(topology,_c1,_c2,_bounds)), - neighborhoodSize(_neighborhoodSize), - bounds(_bounds), - boundsModifier(dummyModifier) - {} - - - /** Constructor without bounds nor bound modifier. - * @param _continuator - An eoContinue that manages the stopping criterion and the checkpointing system - * @param _eval - An eoEvalFunc: the evaluation performer - * @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType - * @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType - * @param _neighborhoodSize - The size of each neighborhood of the linear topology - * If the velocities are not real, they won't be bounded by default. Should have a eoBounds ? - */ - eoLSPSO ( - eoContinue < POT > &_continuator, - eoEvalFunc < POT > &_eval, - const VelocityType & _c1, - const VelocityType & _c2, - const unsigned _neighborhoodSize): - continuator (_continuator), - eval (_eval), - topology(eoLinearTopology(_neighborhoodSize)), - velocity(eoStandardVelocity(topology,_c1,_c2)), - neighborhoodSize(_neighborhoodSize), - bounds(*(new eoRealVectorNoBounds(0))), - boundsModifier(dummyModifier) - {} - - - /// Apply a few iteration of flight to the population (=swarm). - virtual void operator () (eoPop < POT > &_pop) - { - try - { - // setup the topology (done once) - topology.setup(_pop); - - do - { - // loop over all the particles for the current iteration - for (unsigned idx = 0; idx < _pop.size (); idx++) - { - // perform velocity evaluation - velocity (_pop[idx],idx); - - // apply the flight - flight (_pop[idx]); - - // evaluate the position - eval (_pop[idx]); - - // update the topology (particle and the global bests) - velocity.updateNeighborhood(_pop[idx],idx); - } - - } while (continuator (_pop)); - - }catch (std::exception & e) - { - std::string s = e.what (); - s.append (" in eoLSPSO"); - throw std::runtime_error (s); - } - - } - -protected: - eoContinue < POT > &continuator; - eoEvalFunc < POT > &eval; - - eoStandardVelocity < POT > velocity; - eoStandardFlight < POT > flight; - - const unsigned neighborhoodSize; - eoLinearTopology topology; - - eoRealVectorBounds bounds; // REAL bounds even if the velocity could be of another type. - eoRealBoundModifier & boundsModifier; - - // If the bound modifier doesn't need to be used, use the dummy instance - eoDummyRealBoundModifier dummyModifier; - -}; - - -#endif /*_EOLSPSO_H*/ diff --git a/eo/src/eoSSPSO.h b/eo/src/eoSSPSO.h deleted file mode 100644 index 028bfa108..000000000 --- a/eo/src/eoSSPSO.h +++ /dev/null @@ -1,168 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// eoSSPSO.h -// (c) OPAC 2007 -/* - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Contact: thomas.legrand@lifl.fr - */ -//----------------------------------------------------------------------------- - -#ifndef _EOSSPSO_H -#define _EOSSPSO_H - -//----------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include -#include -//----------------------------------------------------------------------------- - -/** - * A Star ("S"tar topology) Standard ("S"tandard velocity) PSO. - * You can use it with or without bounds on the velocity. - * No bound for the flight (no bounds for the positions). - * - */ -template < class POT > class eoSSPSO:public eoPSO < POT > -{ -public: - - - typedef typename POT::ParticleVelocityType VelocityType; - - /** Full constructor - * @param _continuator - An eoContinue that manages the stopping criterion and the checkpointing system - * @param _eval - An eoEvalFunc: the evaluation performer - * @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType - * @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType - * @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities. - * If the velocities are not real, they won't be bounded by default. Should have a eoBounds ? - * @param _boundsModifier - An eoRealBoundModifier used to modify the bounds (for real bounds only) - */ - eoSSPSO ( - eoContinue < POT > &_continuator, - eoEvalFunc < POT > &_eval, - const VelocityType & _c1, - const VelocityType & _c2 , - eoRealVectorBounds & _bounds, - eoRealBoundModifier & _bndsModifier): - continuator (_continuator), - eval (_eval), - velocity(eoStandardVelocity(topology,_c1,_c2,_bounds,_bndsModifier)), - bounds(_bounds), - boundsModifier(_bndsModifier) - {} - - /** Constructor without bound modifier. - * @param _continuator - An eoContinue that manages the stopping criterion and the checkpointing system - * @param _eval - An eoEvalFunc: the evaluation performer - * @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType - * @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType - * @param _bounds - An eoRealBaseVectorBounds: real bounds for real velocities. - * If the velocities are not real, they won't be bounded by default. Should have a eoBounds ? - */ - eoSSPSO ( - eoContinue < POT > &_continuator, - eoEvalFunc < POT > &_eval, - const VelocityType & _c1, - const VelocityType & _c2 , - eoRealVectorBounds & _bounds): - continuator (_continuator), - eval (_eval), - velocity(eoStandardVelocity(topology,_c1,_c2,_bounds)), - bounds(_bounds), - boundsModifier(dummyModifier) - {} - - - /** Constructor without bounds nor bound modifier. - * @param _continuator - An eoContinue that manages the stopping criterion and the checkpointing system - * @param _eval - An eoEvalFunc: the evaluation performer - * @param _c1 - The first learning factor used for the particle's best. Type must be POT::ParticleVelocityType - * @param _c2 - The second learning factor used for the local/global best(s). Type must be POT::ParticleVelocityType - * If the velocities are not real, they won't be bounded by default. Should have a eoBounds ? - */ - eoSSPSO ( - eoContinue < POT > &_continuator, - eoEvalFunc < POT > &_eval, - const VelocityType & _c1, - const VelocityType & _c2): - continuator (_continuator), - eval (_eval), - velocity(eoStandardVelocity(topology,_c1,_c2)), - bounds(*(new eoRealVectorNoBounds(0))), - boundsModifier(dummyModifier) - {} - - - /// Apply a few iteration of flight to the population (=swarm). - virtual void operator () (eoPop < POT > &_pop) - { - try - { - // setup the topology (done once) - topology.setup(_pop); - - do - { - // loop over all the particles for the current iteration - for (unsigned idx = 0; idx < _pop.size (); idx++) - { - // perform velocity evaluation - velocity (_pop[idx],idx); - - // apply the flight - flight (_pop[idx]); - - // evaluate the position - eval (_pop[idx]); - - // update the topology (particle and the global bests) - velocity.updateNeighborhood(_pop[idx],idx); - } - } while (continuator (_pop)); - - }catch (std::exception & e) - { - std::string s = e.what (); - s.append (" in eoSSPSO"); - throw std::runtime_error (s); - } - } - -protected: - eoContinue < POT > &continuator; - eoEvalFunc < POT > &eval; - - eoStandardVelocity < POT > velocity; - eoStandardFlight < POT > flight; - eoStarTopology topology; - - eoRealVectorBounds bounds; // REAL bounds even if the velocity could be of another type. - eoRealBoundModifier & boundsModifier; - - // If the bound modifier doesn't need to be used, use the dummy instance - eoDummyRealBoundModifier dummyModifier; - -}; - - -#endif /*_EOSSPSO_H*/