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 {
88 class ITKOptimizers_EXPORT ExhaustiveOptimizer : public SingleValuedNonLinearOptimizer
89 {
90 public:
91  ITK_DISALLOW_COPY_AND_MOVE(ExhaustiveOptimizer);
92 
98 
101  itkNewMacro(Self);
102 
104  itkOverrideGetNameOfClassMacro(ExhaustiveOptimizer);
105 
107  void
108  StartOptimization() override;
109 
110  void
111  StartWalking();
112 
114  void
115  ResumeWalking();
116 
118  void
119  StopWalking();
120 
121  itkSetMacro(StepLength, double);
122  itkSetMacro(NumberOfSteps, StepsType);
123  itkGetConstReferenceMacro(StepLength, double);
124  itkGetConstReferenceMacro(NumberOfSteps, StepsType);
125  itkGetConstReferenceMacro(CurrentValue, MeasureType);
126  itkGetConstReferenceMacro(MaximumMetricValue, MeasureType);
127  itkGetConstReferenceMacro(MinimumMetricValue, MeasureType);
128  itkGetConstReferenceMacro(MinimumMetricValuePosition, ParametersType);
129  itkGetConstReferenceMacro(MaximumMetricValuePosition, ParametersType);
130  itkGetConstReferenceMacro(CurrentIndex, ParametersType);
131  itkGetConstReferenceMacro(MaximumNumberOfIterations, SizeValueType);
132 
134  const std::string
135  GetStopConditionDescription() const override;
136 
137 protected:
139  ~ExhaustiveOptimizer() override = default;
140  void
141  PrintSelf(std::ostream & os, Indent indent) const override;
142 
144  void
145  AdvanceOneStep();
146 
147  void
148  IncrementIndex(ParametersType & newPosition);
149 
150 protected:
151  MeasureType m_CurrentValue{ 0 };
152 
153  StepsType m_NumberOfSteps{};
154 
155  SizeValueType m_CurrentIteration{ 0 };
156 
157  bool m_Stop{ false };
158 
159  unsigned int m_CurrentParameter{ 0 };
160 
161  double m_StepLength{ 1.0 };
162 
163  ParametersType m_CurrentIndex{};
164 
165  SizeValueType m_MaximumNumberOfIterations{ 1 };
166 
167  MeasureType m_MaximumMetricValue{ itk::NumericTraits<MeasureType>::max() };
168 
169  MeasureType m_MinimumMetricValue{ itk::NumericTraits<MeasureType>::Zero };
170 
171  ParametersType m_MinimumMetricValuePosition{};
172 
173  ParametersType m_MaximumMetricValuePosition{};
174 
175 private:
176  std::ostringstream m_StopConditionDescription{};
177 };
178 } // end namespace itk
179 
180 #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:88
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