ITK  5.4.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 {
78 template <typename TInternalComputationValueType>
79 class ITK_TEMPLATE_EXPORT ExhaustiveOptimizerv4
80  : public ObjectToObjectOptimizerBaseTemplate<TInternalComputationValueType>
81 {
82 public:
83  ITK_DISALLOW_COPY_AND_MOVE(ExhaustiveOptimizerv4);
91 
93  itkNewMacro(Self);
94 
97 
100 
102  using typename Superclass::MeasureType;
103 
105  using typename Superclass::ParametersType;
106 
108  using typename Superclass::ScalesType;
109 
110  void
111  StartOptimization(bool doOnlyInitialization = false) override;
112 
114  void
115  StartWalking();
116 
118  void
119  ResumeWalking();
120 
122  void
123  StopWalking();
124 
125  itkSetMacro(StepLength, double);
126  itkSetMacro(NumberOfSteps, StepsType);
127  itkGetConstReferenceMacro(StepLength, double);
128  itkGetConstReferenceMacro(NumberOfSteps, StepsType);
129  itkGetConstReferenceMacro(CurrentValue, MeasureType);
130  itkGetConstReferenceMacro(MaximumMetricValue, MeasureType);
131  itkGetConstReferenceMacro(MinimumMetricValue, MeasureType);
132  itkGetConstReferenceMacro(MinimumMetricValuePosition, ParametersType);
133  itkGetConstReferenceMacro(MaximumMetricValuePosition, ParametersType);
134  itkGetConstReferenceMacro(CurrentIndex, ParametersType);
135 
137  const std::string
138  GetStopConditionDescription() const override;
139 
141  void
142  SetInitialPosition(const ParametersType & param);
143 
147  {
148  return m_InitialPosition;
149  }
150 
151 protected:
153  ~ExhaustiveOptimizerv4() override = default;
154  void
155  PrintSelf(std::ostream & os, Indent indent) const override;
156 
158  void
159  AdvanceOneStep();
160 
161  void
162  IncrementIndex(ParametersType & newPosition);
163 
164 protected:
165  ParametersType m_InitialPosition{};
166  MeasureType m_CurrentValue{ 0 };
167  StepsType m_NumberOfSteps{ 0 };
168  bool m_Stop{ false };
169  double m_StepLength{ 1.0 };
170  ParametersType m_CurrentIndex{ 0 };
171  MeasureType m_MaximumMetricValue{ 0.0 };
172  MeasureType m_MinimumMetricValue{ 0.0 };
173  ParametersType m_MinimumMetricValuePosition{};
174  ParametersType m_MaximumMetricValuePosition{};
175 
176 private:
177  std::ostringstream m_StopConditionDescription{ "" };
178 };
179 } // end namespace itk
180 
181 #ifndef ITK_MANUAL_INSTANTIATION
182 # include "itkExhaustiveOptimizerv4.hxx"
183 #endif
184 
185 #endif
itk::OptimizerParameters< TInternalComputationValueType >
itk::ExhaustiveOptimizerv4
Optimizer that fully samples a grid on the parametric space.
Definition: itkExhaustiveOptimizerv4.h:79
itk::ExhaustiveOptimizerv4::GetInitialPosition
ParametersType & GetInitialPosition()
Definition: itkExhaustiveOptimizerv4.h:146
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
itkOverrideGetNameOfClassMacro
itkOverrideGetNameOfClassMacro(AddImageFilter)
itkIntTypes.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
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