ITK  5.4.0
Insight Toolkit
itkQuasiNewtonOptimizerv4.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 itkQuasiNewtonOptimizerv4_h
19#define itkQuasiNewtonOptimizerv4_h
20
21#include "itkArray2D.h"
22#include "itkBooleanStdVector.h"
24
25#include "vnl/algo/vnl_matrix_inverse.h"
26#include "vnl/algo/vnl_determinant.h"
27
28namespace itk
29{
60template <typename TInternalComputationValueType>
61class ITK_TEMPLATE_EXPORT QuasiNewtonOptimizerv4Template
62 : public GradientDescentOptimizerv4Template<TInternalComputationValueType>
63{
64public:
65 ITK_DISALLOW_COPY_AND_MOVE(QuasiNewtonOptimizerv4Template);
66
72
74 itkNewMacro(Self);
75
77 itkOverrideGetNameOfClassMacro(QuasiNewtonOptimizerv4Template);
78
80 using InternalComputationValueType = TInternalComputationValueType;
81
82 using typename Superclass::ParametersType;
83 using typename Superclass::MeasureType;
84 using typename Superclass::DerivativeType;
85 using typename Superclass::IndexRangeType;
86
89
91 using HessianArrayType = std::vector<HessianType>;
92
94 void
95 StartOptimization(bool doOnlyInitialization = false) override;
96
98 itkSetMacro(MaximumIterationsWithoutProgress, SizeValueType);
99
114 itkSetMacro(MaximumNewtonStepSizeInPhysicalUnits, TInternalComputationValueType);
115
117 itkGetConstReferenceMacro(NewtonStep, DerivativeType);
118
123 virtual void
125
126protected:
128 SizeValueType m_MaximumIterationsWithoutProgress{ 30 };
129
131 ParametersType m_CurrentPosition{};
132 ParametersType m_OptimalStep{};
133
135 MeasureType m_PreviousValue{};
136 ParametersType m_PreviousPosition{};
137
139 MeasureType m_BestValue{};
140 ParametersType m_BestPosition{};
141 SizeValueType m_BestIteration{ 0 };
142
144 DerivativeType m_NewtonStep{};
145
147 std::string m_NewtonStepWarning{};
148
150 TInternalComputationValueType m_MaximumNewtonStepSizeInPhysicalUnits{};
151
153 HessianArrayType m_HessianArray{};
154
157 BooleanStdVectorType m_NewtonStepValidFlags{};
158
160 virtual void
162
167 virtual bool
169
171 virtual void
173
178 void
180
189 void
191
196 void
197 AdvanceOneStep() override;
198
201
202 void
203 PrintSelf(std::ostream & os, Indent indent) const override;
204
205private:
208};
209
212
213} // end namespace itk
214
215#ifndef ITK_MANUAL_INSTANTIATION
216# include "itkQuasiNewtonOptimizerv4.hxx"
217#endif
218
219#endif
Array2D class representing a 2D array.
Definition: itkArray2D.h:43
ThreadedIndexedContainerPartitioner::IndexRangeType IndexRangeType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Implement a Quasi-Newton optimizer with BFGS Hessian estimation.
virtual void EstimateNewtonStepOverSubRange(const IndexRangeType &subrange)
~QuasiNewtonOptimizerv4Template() override=default
void StartOptimization(bool doOnlyInitialization=false) override
virtual void ResetNewtonStep(IndexValueType loc)
virtual bool ComputeHessianAndStepWithBFGS(IndexValueType loc)
void PrintSelf(std::ostream &os, Indent indent) const override
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
long IndexValueType
Definition: itkIntTypes.h:90
class ITK_FORWARD_EXPORT QuasiNewtonOptimizerv4Template
unsigned long SizeValueType
Definition: itkIntTypes.h:83
std::vector< Boolean > BooleanStdVectorType