ITK  5.4.0
Insight Toolkit
itkExhaustiveOptimizer.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 itkExhaustiveOptimizer_h
19 #define itkExhaustiveOptimizer_h
20 
21 #include "itkIntTypes.h"
23 #include "ITKOptimizersExport.h"
24 
25 namespace itk
26 {
83 class ITKOptimizers_EXPORT ExhaustiveOptimizer : public SingleValuedNonLinearOptimizer
84 {
85 public:
86  ITK_DISALLOW_COPY_AND_MOVE(ExhaustiveOptimizer);
87 
93 
96  itkNewMacro(Self);
97 
100 
102  void
103  StartOptimization() override;
104 
105  void
106  StartWalking();
107 
109  void
110  ResumeWalking();
111 
113  void
114  StopWalking();
115 
116  itkSetMacro(StepLength, double);
117  itkSetMacro(NumberOfSteps, StepsType);
118  itkGetConstReferenceMacro(StepLength, double);
119  itkGetConstReferenceMacro(NumberOfSteps, StepsType);
120  itkGetConstReferenceMacro(CurrentValue, MeasureType);
121  itkGetConstReferenceMacro(MaximumMetricValue, MeasureType);
122  itkGetConstReferenceMacro(MinimumMetricValue, MeasureType);
123  itkGetConstReferenceMacro(MinimumMetricValuePosition, ParametersType);
124  itkGetConstReferenceMacro(MaximumMetricValuePosition, ParametersType);
125  itkGetConstReferenceMacro(CurrentIndex, ParametersType);
126  itkGetConstReferenceMacro(MaximumNumberOfIterations, SizeValueType);
127 
129  const std::string
130  GetStopConditionDescription() const override;
131 
132 protected:
134  ~ExhaustiveOptimizer() override = default;
135  void
136  PrintSelf(std::ostream & os, Indent indent) const override;
137 
139  void
140  AdvanceOneStep();
141 
142  void
143  IncrementIndex(ParametersType & newPosition);
144 
145 protected:
146  MeasureType m_CurrentValue{ 0 };
147 
148  StepsType m_NumberOfSteps{};
149 
150  SizeValueType m_CurrentIteration{ 0 };
151 
152  bool m_Stop{ false };
153 
154  unsigned int m_CurrentParameter{ 0 };
155 
156  double m_StepLength{ 1.0 };
157 
158  ParametersType m_CurrentIndex{};
159 
160  SizeValueType m_MaximumNumberOfIterations{ 1 };
161 
162  MeasureType m_MaximumMetricValue{ itk::NumericTraits<MeasureType>::max() };
163 
164  MeasureType m_MinimumMetricValue{ itk::NumericTraits<MeasureType>::Zero };
165 
166  ParametersType m_MinimumMetricValuePosition{};
167 
168  ParametersType m_MaximumMetricValuePosition{};
169 
170 private:
171  std::ostringstream m_StopConditionDescription{};
172 };
173 } // end namespace itk
174 
175 #endif
itk::SingleValuedNonLinearOptimizer
This class is a base for the Optimization methods that optimize a single valued function.
Definition: itkSingleValuedNonLinearOptimizer.h:35
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::ExhaustiveOptimizer
Optimizer that fully samples a grid on the parametric space.
Definition: itkExhaustiveOptimizer.h:83
itkIntTypes.h
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:59
itk::NumericTraits::max
static constexpr T max(const T &)
Definition: itkNumericTraits.h:168
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Array< SizeValueType >
itkSingleValuedNonLinearOptimizer.h
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83