Unfit  3.1.1
Data fitting and optimization software
ParticleSwarm.hpp
1 // Unfit: Data fitting and optimization software
2 //
3 // Copyright (C) 2012- Dr Martin Buist & Dr Alberto Corrias
4 // Contacts: martin.buist _at_ nus.edu.sg; alberto _at_ nus.edu.sg
5 //
6 // See the 'Contributors' file for a list of those who have contributed
7 // to this work.
8 //
9 // This program is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 //
22 #ifndef UNFIT_INCLUDE_PARTICLESWARM_HPP_
23 #define UNFIT_INCLUDE_PARTICLESWARM_HPP_
24 
25 #include <vector>
26 #include "GenericCostFunction.hpp"
27 #include "GenericOptimizer.hpp"
28 
29 namespace Unfit
30 {
52 {
54  friend class TestParticleSwarm;
55  public:
65  ParticleSwarm();
66 
72  virtual ~ParticleSwarm();
73 
114  int FindMin(GenericCostFunction &CostFunction, std::vector<double>
115  &coordinates) override;
116 
122  void Reset() override;
123 
124  private:
144  int ProcessFindMin(GenericCostFunction &CostFunction);
145 
167  void ChaosEnhancement(unsigned enhancement_strategy);
168 
185  std::vector<double> GenerateTrialParticle(std::size_t member);
186 
198  void UpdatePopulationMember(GenericCostFunction &CostFunction,
199  std::size_t member);
200 
202  std::vector<double> best_particle_;
204  std::size_t dimensions_;
206  std::size_t cost_;
207 };
208 
209 } // namespace Unfit
210 
211 #endif
212 
void UpdatePopulationMember(GenericCostFunction &CostFunction, std::size_t member)
Definition: ParticleSwarm.cpp:336
Definition: GenericOptimizer.hpp:41
Definition: Bounds.hpp:27
std::vector< double > best_particle_
Definition: ParticleSwarm.hpp:202
int FindMin(GenericCostFunction &CostFunction, std::vector< double > &coordinates) override
A method to find the minimum of a model/function using a Particle Swarm approach. ...
Definition: ParticleSwarm.cpp:54
A class to implement the Particle Swarm optimization method.
Definition: ParticleSwarm.hpp:51
void ChaosEnhancement(unsigned enhancement_strategy)
Definition: ParticleSwarm.cpp:171
Definition: GenericCostFunction.hpp:36
void Reset() override
Definition: ParticleSwarm.cpp:43
ParticleSwarm()
Definition: ParticleSwarm.cpp:31
int ProcessFindMin(GenericCostFunction &CostFunction)
Definition: ParticleSwarm.cpp:119
std::size_t dimensions_
Definition: ParticleSwarm.hpp:204
Definition: TestParticleSwarm.cpp:38
virtual ~ParticleSwarm()
std::vector< double > GenerateTrialParticle(std::size_t member)
Definition: ParticleSwarm.cpp:319
std::size_t cost_
Definition: ParticleSwarm.hpp:206