ITK  5.3.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 
101  void
102  StartOptimization() override;
103 
104  void
105  StartWalking();
106 
107  void
108  ResumeWalking();
109 
110  void
111  StopWalking();
112 
113  itkSetMacro(StepLength, double);
114  itkSetMacro(NumberOfSteps, StepsType);
115  itkGetConstReferenceMacro(StepLength, double);
116  itkGetConstReferenceMacro(NumberOfSteps, StepsType);
117  itkGetConstReferenceMacro(CurrentValue, MeasureType);
118  itkGetConstReferenceMacro(MaximumMetricValue, MeasureType);
119  itkGetConstReferenceMacro(MinimumMetricValue, MeasureType);
120  itkGetConstReferenceMacro(MinimumMetricValuePosition, ParametersType);
121  itkGetConstReferenceMacro(MaximumMetricValuePosition, ParametersType);
122  itkGetConstReferenceMacro(CurrentIndex, ParametersType);
123  itkGetConstReferenceMacro(MaximumNumberOfIterations, SizeValueType);
124 
126  const std::string
127  GetStopConditionDescription() const override;
128 
129 protected:
131  ~ExhaustiveOptimizer() override = default;
132  void
133  PrintSelf(std::ostream & os, Indent indent) const override;
134 
136  void
137  AdvanceOneStep();
138 
139  void
140  IncrementIndex(ParametersType & newPosition);
141 
142 protected:
143  MeasureType m_CurrentValue{ 0 };
144 
145  StepsType m_NumberOfSteps{};
146 
147  SizeValueType m_CurrentIteration{ 0 };
148 
149  bool m_Stop{ false };
150 
151  unsigned int m_CurrentParameter{ 0 };
152 
153  double m_StepLength{ 1.0 };
154 
155  ParametersType m_CurrentIndex{};
156 
157  SizeValueType m_MaximumNumberOfIterations{ 1 };
158 
159  MeasureType m_MaximumMetricValue{ itk::NumericTraits<MeasureType>::max() };
160 
161  MeasureType m_MinimumMetricValue{ itk::NumericTraits<MeasureType>::Zero };
162 
163  ParametersType m_MinimumMetricValuePosition{};
164 
165  ParametersType m_MaximumMetricValuePosition{};
166 
167 private:
168  std::ostringstream m_StopConditionDescription{};
169 };
170 } // end namespace itk
171 
172 #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:58
itk::NumericTraits::max
static constexpr T max(const T &)
Definition: itkNumericTraits.h:167
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