ITK  6.0.0
Insight Toolkit
itkParticleSwarmOptimizerBase.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18
19#ifndef itkParticleSwarmOptimizerBase_h
20#define itkParticleSwarmOptimizerBase_h
21
24#include "ITKOptimizersExport.h"
25
26namespace itk
27{
57{
58public:
59 ITK_DISALLOW_COPY_AND_MOVE(ParticleSwarmOptimizerBase);
60
66
68 itkOverrideGetNameOfClassMacro(ParticleSwarmOptimizerBase);
69
70 using ParameterBoundsType = std::vector<std::pair<ParametersType::ValueType, ParametersType::ValueType>>;
71
73 {
79 };
80
81 using SwarmType = std::vector<ParticleData>;
82 using NumberOfIterationsType = unsigned int;
83 using NumberOfParticlesType = unsigned int;
84 using NumberOfGenerationsType = unsigned int;
88
94 itkSetMacro(InitializeNormalDistribution, bool);
95 itkGetMacro(InitializeNormalDistribution, bool);
96 itkBooleanMacro(InitializeNormalDistribution);
104 void
105 SetInitialSwarm(const SwarmType & initialSwarm);
106 void
115 itkSetMacro(PrintSwarm, bool);
116 itkGetMacro(PrintSwarm, bool);
117 itkBooleanMacro(PrintSwarm);
121 void
123
124
127 void
129 itkGetMacro(NumberOfParticles, NumberOfParticlesType);
134 itkSetMacro(MaximalNumberOfIterations, NumberOfIterationsType);
135 itkGetMacro(MaximalNumberOfIterations, NumberOfIterationsType);
142 itkSetMacro(NumberOfGenerationsWithMinimalImprovement, NumberOfGenerationsType);
143 itkGetMacro(NumberOfGenerationsWithMinimalImprovement, NumberOfGenerationsType);
149 virtual void
151 void
152 SetParameterBounds(std::pair<ParametersType::ValueType, ParametersType::ValueType> & bounds, unsigned int n);
157
172 itkSetMacro(FunctionConvergenceTolerance, MeasureType);
173 itkGetMacro(FunctionConvergenceTolerance, MeasureType);
174
177 void
178 SetParametersConvergenceTolerance(ValueType convergenceTolerance, unsigned int sz);
179 itkSetMacro(ParametersConvergenceTolerance, ParametersType);
180 itkGetMacro(ParametersConvergenceTolerance, ParametersType);
181 itkGetMacro(PercentageParticlesConverged, double);
182 itkSetMacro(PercentageParticlesConverged, double);
195 itkSetMacro(UseSeed, bool);
196 itkGetMacro(UseSeed, bool);
197 itkBooleanMacro(UseSeed);
204 GetValue() const;
205
207 const std::string
209
214 void
215 PrintSwarm(std::ostream & os, Indent indent) const;
216
217protected:
220 void
221 PrintSelf(std::ostream & os, Indent indent) const override;
222 void
223 PrintParamtersType(const ParametersType & x, std::ostream & os) const;
224
227 virtual void
229
230 virtual void
232
236 virtual void
238
239 void
241 void
243
244 bool m_PrintSwarm{};
245 std::ostringstream m_StopConditionDescription{};
246 bool m_InitializeNormalDistribution{};
247 NumberOfParticlesType m_NumberOfParticles{};
248 NumberOfIterationsType m_MaximalNumberOfIterations{};
249 NumberOfGenerationsType m_NumberOfGenerationsWithMinimalImprovement{};
250 ParameterBoundsType m_ParameterBounds{};
251 ParametersType m_ParametersConvergenceTolerance{};
252 double m_PercentageParticlesConverged{};
253 CostFunctionType::MeasureType m_FunctionConvergenceTolerance{};
254 std::vector<ParticleData> m_Particles{};
255 CostFunctionType::MeasureType m_FunctionBestValue{ 0 };
256 std::vector<MeasureType> m_FunctionBestValueMemory{};
257 ParametersType m_ParametersBestValue{};
258 NumberOfIterationsType m_IterationIndex{ 0 };
260 bool m_UseSeed{};
261};
262} // end namespace itk
263
264#endif
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Abstract implementation of a Particle Swarm Optimization (PSO) algorithm.
ParameterBoundsType GetParameterBounds() const
void SetParameterBounds(std::pair< ParametersType::ValueType, ParametersType::ValueType > &bounds, unsigned int n)
MeasureType GetValue() const
void SetInitialSwarm(const SwarmType &initialSwarm)
void PrintSelf(std::ostream &os, Indent indent) const override
CostFunctionType::MeasureType MeasureType
const std::string GetStopConditionDescription() const override
void PrintSwarm(std::ostream &os, Indent indent) const
void PrintParamtersType(const ParametersType &x, std::ostream &os) const
void SetParametersConvergenceTolerance(ValueType convergenceTolerance, unsigned int sz)
void SetNumberOfParticles(NumberOfParticlesType n)
std::vector< std::pair< ParametersType::ValueType, ParametersType::ValueType > > ParameterBoundsType
virtual void SetParameterBounds(ParameterBoundsType &bounds)
This class is a base for the Optimization methods that optimize a single valued function.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....