ITK  5.2.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  * http://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);
85 
91 
93  itkNewMacro(Self);
94 
96  itkTypeMacro(ExhaustiveOptimizerv4, Superclass);
97 
100 
103 
105  using ParametersType = typename Superclass::ParametersType;
106 
108  using ScalesType = 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:
168  bool m_Stop{ false };
169  double m_StepLength{ 1.0 };
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::ExhaustiveOptimizerv4::m_NumberOfSteps
StepsType m_NumberOfSteps
Definition: itkExhaustiveOptimizerv4.h:167
itk::ExhaustiveOptimizerv4::m_MaximumMetricValue
MeasureType m_MaximumMetricValue
Definition: itkExhaustiveOptimizerv4.h:171
itk::ExhaustiveOptimizerv4
Optimizer that fully samples a grid on the parametric space.
Definition: itkExhaustiveOptimizerv4.h:79
itk::ExhaustiveOptimizerv4::MeasureType
typename Superclass::MeasureType MeasureType
Definition: itkExhaustiveOptimizerv4.h:102
itk::ExhaustiveOptimizerv4::GetInitialPosition
ParametersType & GetInitialPosition()
Definition: itkExhaustiveOptimizerv4.h:146
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ExhaustiveOptimizerv4::ParametersType
typename Superclass::ParametersType ParametersType
Definition: itkExhaustiveOptimizerv4.h:105
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::ExhaustiveOptimizerv4::m_StopConditionDescription
std::ostringstream m_StopConditionDescription
Definition: itkExhaustiveOptimizerv4.h:177
itk::ExhaustiveOptimizerv4::m_CurrentIndex
ParametersType m_CurrentIndex
Definition: itkExhaustiveOptimizerv4.h:170
itk::ExhaustiveOptimizerv4::m_MinimumMetricValuePosition
ParametersType m_MinimumMetricValuePosition
Definition: itkExhaustiveOptimizerv4.h:173
itk::ExhaustiveOptimizerv4::m_CurrentValue
MeasureType m_CurrentValue
Definition: itkExhaustiveOptimizerv4.h:166
itkIntTypes.h
itk::ExhaustiveOptimizerv4::m_MaximumMetricValuePosition
ParametersType m_MaximumMetricValuePosition
Definition: itkExhaustiveOptimizerv4.h:174
itk::ExhaustiveOptimizerv4::m_InitialPosition
ParametersType m_InitialPosition
Definition: itkExhaustiveOptimizerv4.h:165
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ExhaustiveOptimizerv4::m_MinimumMetricValue
MeasureType m_MinimumMetricValue
Definition: itkExhaustiveOptimizerv4.h:172
itkObjectToObjectOptimizerBase.h
itk::ExhaustiveOptimizerv4::ScalesType
typename Superclass::ScalesType ScalesType
Definition: itkExhaustiveOptimizerv4.h:108
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