ITK  5.4.0
Insight Toolkit
itkMultiStartOptimizerv4.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 itkMultiStartOptimizerv4_h
19#define itkMultiStartOptimizerv4_h
20
23
24namespace itk
25{
26
41template <typename TInternalComputationValueType>
42class ITK_TEMPLATE_EXPORT MultiStartOptimizerv4Template
43 : public ObjectToObjectOptimizerBaseTemplate<TInternalComputationValueType>
44{
45public:
46 ITK_DISALLOW_COPY_AND_MOVE(MultiStartOptimizerv4Template);
47
53
55 itkOverrideGetNameOfClassMacro(MultiStartOptimizerv4Template);
56
58 itkNewMacro(Self);
59
60 using typename Superclass::ParametersType;
61 using ParametersListType = std::vector<ParametersType>;
62 using ParameterListSizeType = typename ParametersListType::size_type;
63
68
70#if !defined(ITK_LEGACY_REMOVE)
71 // We need to expose the enum values at the class level
72 // for backwards compatibility
73 static constexpr itk::StopConditionObjectToObjectOptimizerEnum MAXIMUM_NUMBER_OF_ITERATIONS =
75 static constexpr itk::StopConditionObjectToObjectOptimizerEnum COSTFUNCTION_ERROR =
77 static constexpr itk::StopConditionObjectToObjectOptimizerEnum UPDATE_PARAMETERS_ERROR =
79 static constexpr itk::StopConditionObjectToObjectOptimizerEnum STEP_TOO_SMALL =
81 static constexpr itk::StopConditionObjectToObjectOptimizerEnum CONVERGENCE_CHECKER_PASSED =
83 static constexpr itk::StopConditionObjectToObjectOptimizerEnum OTHER_ERROR =
85#endif
86
88 using typename Superclass::StopConditionReturnStringType;
89
91 using typename Superclass::StopConditionDescriptionType;
92
96 using InternalComputationValueType = TInternalComputationValueType;
97
99 using typename Superclass::MetricType;
101
104
106 using typename Superclass::MeasureType;
107 using MetricValuesListType = std::vector<MeasureType>;
108
111
113 void
115
117 void
118 StartOptimization(bool doOnlyInitialization = false) override;
119
122 virtual void
124
127 virtual void
129
133
137
139 void
141
145
149
151 itkSetObjectMacro(LocalOptimizer, OptimizerType);
152 itkGetModifiableObjectMacro(LocalOptimizer, OptimizerType);
157 {
158 return this->m_BestParametersIndex;
159 }
160
161protected:
164 ~MultiStartOptimizerv4Template() override = default;
167 void
168 PrintSelf(std::ostream & os, Indent indent) const override;
169
170 /* Common variables for optimization control and reporting */
171 bool m_Stop{ false };
173 StopConditionDescriptionType m_StopConditionDescription{};
174 ParametersListType m_ParametersList{};
175 MetricValuesListType m_MetricValuesList{};
176 MeasureType m_MinimumMetricValue{};
177 MeasureType m_MaximumMetricValue{};
178 ParameterListSizeType m_BestParametersIndex{};
179 OptimizerPointer m_LocalOptimizer{};
180};
181
184
185} // end namespace itk
186
187#ifndef ITK_MANUAL_INSTANTIATION
188# include "itkMultiStartOptimizerv4.hxx"
189#endif
190
191#endif
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Multi-start searches over input parameters and returns the best metric value.
typename MetricType::DerivativeType DerivativeType
std::vector< ParametersType > ParametersListType
typename OptimizerType::Pointer OptimizerPointer
~MultiStartOptimizerv4Template() override=default
const StopConditionReturnStringType GetStopConditionDescription() const override
typename LocalOptimizerType::Pointer LocalOptimizerPointer
void StartOptimization(bool doOnlyInitialization=false) override
typename ParametersListType::size_type ParameterListSizeType
void PrintSelf(std::ostream &os, Indent indent) const override
void SetParametersList(ParametersListType &p)
const MetricValuesListType & GetMetricValuesList() const
ParametersListType & GetParametersList()
typename MetricType::Pointer MetricTypePointer
typename itk::GradientDescentOptimizerv4Template< TInternalComputationValueType > LocalOptimizerType
std::vector< MeasureType > MetricValuesListType
TInternalComputationValueType InternalComputationValueType
Abstract base for object-to-object optimizers.
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....