ITK  6.0.0
Insight Toolkit
itkAmoebaOptimizer.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 #ifndef itkAmoebaOptimizer_h
19 #define itkAmoebaOptimizer_h
20 
22 #include "vnl/algo/vnl_amoeba.h"
23 #include "ITKOptimizersExport.h"
24 #include <memory> // For unique_ptr.
25 
26 namespace itk
27 {
67 class ITKOptimizers_EXPORT AmoebaOptimizer : public SingleValuedNonLinearVnlOptimizer
68 {
69 public:
70  ITK_DISALLOW_COPY_AND_MOVE(AmoebaOptimizer);
71 
77  using NumberOfIterationsType = unsigned int;
78 
80  itkNewMacro(Self);
81 
83  itkOverrideGetNameOfClassMacro(AmoebaOptimizer);
84 
87  using ParametersType = Superclass::ParametersType;
88 
90  using InternalParametersType = vnl_vector<double>;
91 
93  void
94  StartOptimization() override;
95 
97  void
98  SetCostFunction(SingleValuedCostFunction * costFunction) override;
99 
103  itkSetMacro(MaximumNumberOfIterations, NumberOfIterationsType);
104  itkGetConstMacro(MaximumNumberOfIterations, NumberOfIterationsType);
115  itkSetMacro(AutomaticInitialSimplex, bool);
116  itkBooleanMacro(AutomaticInitialSimplex);
117  itkGetConstMacro(AutomaticInitialSimplex, bool);
126  itkSetMacro(OptimizeWithRestarts, bool);
127  itkBooleanMacro(OptimizeWithRestarts);
128  itkGetConstMacro(OptimizeWithRestarts, bool);
133  void
134  SetInitialSimplexDelta(ParametersType initialSimplexDelta, bool automaticInitialSimplex = false);
135  itkGetConstMacro(InitialSimplexDelta, ParametersType);
142  itkSetMacro(ParametersConvergenceTolerance, double);
143  itkGetConstMacro(ParametersConvergenceTolerance, double);
150  itkSetMacro(FunctionConvergenceTolerance, double);
151  itkGetConstMacro(FunctionConvergenceTolerance, double);
155  std::string
156  GetStopConditionDescription() const override;
157 
160  GetValue() const;
161 
163  vnl_amoeba *
164  GetOptimizer() const;
165 
166 protected:
167  AmoebaOptimizer();
168  ~AmoebaOptimizer() override;
169  void
170  PrintSelf(std::ostream & os, Indent indent) const override;
171 
172  using CostFunctionAdaptorType = Superclass::CostFunctionAdaptorType;
173 
174 private:
176  void
177  ValidateSettings();
178 
179  NumberOfIterationsType m_MaximumNumberOfIterations{};
180  ParametersType::ValueType m_ParametersConvergenceTolerance{};
181  CostFunctionType::MeasureType m_FunctionConvergenceTolerance{};
182  bool m_AutomaticInitialSimplex{};
183  ParametersType m_InitialSimplexDelta{};
184  bool m_OptimizeWithRestarts{};
185  std::unique_ptr<vnl_amoeba> m_VnlOptimizer;
186 
187  std::ostringstream m_StopConditionDescription{};
188 };
189 } // end namespace itk
190 
191 #endif
itk::SingleValuedCostFunction::MeasureType
double MeasureType
Definition: itkSingleValuedCostFunction.h:50
itk::AmoebaOptimizer::m_VnlOptimizer
std::unique_ptr< vnl_amoeba > m_VnlOptimizer
Definition: itkAmoebaOptimizer.h:185
itk::AmoebaOptimizer::CostFunctionAdaptorType
Superclass::CostFunctionAdaptorType CostFunctionAdaptorType
Definition: itkAmoebaOptimizer.h:172
itk::AmoebaOptimizer::ParametersType
Superclass::ParametersType ParametersType
Definition: itkAmoebaOptimizer.h:87
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::AmoebaOptimizer::NumberOfIterationsType
unsigned int NumberOfIterationsType
Definition: itkAmoebaOptimizer.h:77
itk::SingleValuedCostFunction
This class is a base for the CostFunctions returning a single value.
Definition: itkSingleValuedCostFunction.h:34
itk::AmoebaOptimizer::InternalParametersType
vnl_vector< double > InternalParametersType
Definition: itkAmoebaOptimizer.h:90
itkSingleValuedNonLinearVnlOptimizer.h
itk::AmoebaOptimizer
Wrap of the vnl_amoeba algorithm.
Definition: itkAmoebaOptimizer.h:67
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::SingleValuedNonLinearOptimizer::MeasureType
CostFunctionType::MeasureType MeasureType
Definition: itkSingleValuedNonLinearOptimizer.h:62
itk::SingleValuedNonLinearVnlOptimizer
This class is a base for the Optimization methods that optimize a single valued function.
Definition: itkSingleValuedNonLinearVnlOptimizer.h:39