ITK  6.0.0
Insight Toolkit
itkExhaustiveOptimizerv4.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 itkExhaustiveOptimizerv4_h
19 #define itkExhaustiveOptimizerv4_h
20 
21 #include "itkIntTypes.h"
23 
24 namespace itk
25 {
83 template <typename TInternalComputationValueType>
84 class ITK_TEMPLATE_EXPORT ExhaustiveOptimizerv4
85  : public ObjectToObjectOptimizerBaseTemplate<TInternalComputationValueType>
86 {
87 public:
88  ITK_DISALLOW_COPY_AND_MOVE(ExhaustiveOptimizerv4);
96 
98  itkNewMacro(Self);
99 
101  itkOverrideGetNameOfClassMacro(ExhaustiveOptimizerv4);
102 
105 
107  using typename Superclass::MeasureType;
108 
110  using typename Superclass::ParametersType;
111 
113  using typename Superclass::ScalesType;
114 
115  void
116  StartOptimization(bool doOnlyInitialization = false) override;
117 
119  void
120  StartWalking();
121 
123  void
124  ResumeWalking();
125 
127  void
128  StopWalking();
129 
130  itkSetMacro(StepLength, double);
131  itkSetMacro(NumberOfSteps, StepsType);
132  itkGetConstReferenceMacro(StepLength, double);
133  itkGetConstReferenceMacro(NumberOfSteps, StepsType);
134  itkGetConstReferenceMacro(CurrentValue, MeasureType);
135  itkGetConstReferenceMacro(MaximumMetricValue, MeasureType);
136  itkGetConstReferenceMacro(MinimumMetricValue, MeasureType);
137  itkGetConstReferenceMacro(MinimumMetricValuePosition, ParametersType);
138  itkGetConstReferenceMacro(MaximumMetricValuePosition, ParametersType);
139  itkGetConstReferenceMacro(CurrentIndex, ParametersType);
140 
142  std::string
143  GetStopConditionDescription() const override;
144 
146  void
147  SetInitialPosition(const ParametersType & param);
148 
152  {
153  return m_InitialPosition;
154  }
155 
156 protected:
158  ~ExhaustiveOptimizerv4() override = default;
159  void
160  PrintSelf(std::ostream & os, Indent indent) const override;
161 
163  void
164  AdvanceOneStep();
165 
166  void
167  IncrementIndex(ParametersType & newPosition);
168 
169 protected:
170  ParametersType m_InitialPosition{};
171  MeasureType m_CurrentValue{ 0 };
172  StepsType m_NumberOfSteps{ 0 };
173  bool m_Stop{ false };
174  double m_StepLength{ 1.0 };
175  ParametersType m_CurrentIndex{ 0 };
176  MeasureType m_MaximumMetricValue{ 0.0 };
177  MeasureType m_MinimumMetricValue{ 0.0 };
178  ParametersType m_MinimumMetricValuePosition{};
179  ParametersType m_MaximumMetricValuePosition{};
180 
181 private:
182  std::ostringstream m_StopConditionDescription{ "" };
183 };
184 } // end namespace itk
185 
186 #ifndef ITK_MANUAL_INSTANTIATION
187 # include "itkExhaustiveOptimizerv4.hxx"
188 #endif
189 
190 #endif
itk::OptimizerParameters< TInternalComputationValueType >
itk::ExhaustiveOptimizerv4
Optimizer that fully samples a grid on the parametric space.
Definition: itkExhaustiveOptimizerv4.h:84
itk::ExhaustiveOptimizerv4::GetInitialPosition
ParametersType & GetInitialPosition()
Definition: itkExhaustiveOptimizerv4.h:151
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
itkIntTypes.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itkObjectToObjectOptimizerBase.h
itk::ObjectToObjectOptimizerBaseTemplate
Abstract base for object-to-object optimizers.
Definition: itkObjectToObjectOptimizerBase.h:113
itk::Array< SizeValueType >
itk::ObjectToObjectOptimizerBaseTemplate::MeasureType
typename MetricType::MeasureType MeasureType
Definition: itkObjectToObjectOptimizerBase.h:145