ITK  5.2.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  * 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 itkQuasiNewtonOptimizerv4_h
19 #define itkQuasiNewtonOptimizerv4_h
20 
21 #include "itkArray2D.h"
23 
24 #include "vnl/algo/vnl_matrix_inverse.h"
25 #include "vnl/algo/vnl_determinant.h"
26 
27 namespace itk
28 {
59 template <typename TInternalComputationValueType>
60 class ITK_TEMPLATE_EXPORT QuasiNewtonOptimizerv4Template
61  : public GradientDescentOptimizerv4Template<TInternalComputationValueType>
62 {
63 public:
64  ITK_DISALLOW_COPY_AND_MOVE(QuasiNewtonOptimizerv4Template);
65 
71 
73  itkNewMacro(Self);
74 
77 
79  using InternalComputationValueType = TInternalComputationValueType;
80 
84  using IndexRangeType = typename Superclass::IndexRangeType;
85 
88 
90  using HessianArrayType = std::vector<HessianType>;
91 
93  void
94  StartOptimization(bool doOnlyInitialization = false) override;
95 
97  itkSetMacro(MaximumIterationsWithoutProgress, SizeValueType);
98 
113  itkSetMacro(MaximumNewtonStepSizeInPhysicalUnits, TInternalComputationValueType);
114 
116  itkGetConstReferenceMacro(NewtonStep, DerivativeType);
117 
122  virtual void
123  EstimateNewtonStepOverSubRange(const IndexRangeType & subrange);
124 
125 protected:
127  SizeValueType m_MaximumIterationsWithoutProgress{ 30 };
128 
132 
136 
140  SizeValueType m_BestIteration{ 0 };
141 
144 
146  std::string m_NewtonStepWarning;
147 
149  TInternalComputationValueType m_MaximumNewtonStepSizeInPhysicalUnits;
150 
153 
155  std::vector<bool> m_NewtonStepValidFlags;
156 
158  virtual void
159  EstimateNewtonStep();
160 
165  virtual bool
166  ComputeHessianAndStepWithBFGS(IndexValueType loc);
167 
169  virtual void
170  ResetNewtonStep(IndexValueType loc);
171 
176  void
177  CombineGradientNewtonStep();
178 
187  void
188  ModifyCombinedNewtonStep();
189 
194  void
195  AdvanceOneStep() override;
196 
198  ~QuasiNewtonOptimizerv4Template() override = default;
199 
200  void
201  PrintSelf(std::ostream & os, Indent indent) const override;
202 
203 private:
206 };
207 
210 
211 } // end namespace itk
212 
213 #ifndef ITK_MANUAL_INSTANTIATION
214 # include "itkQuasiNewtonOptimizerv4.hxx"
215 #endif
216 
217 #endif
itk::QuasiNewtonOptimizerv4Template::m_PreviousValue
MeasureType m_PreviousValue
Definition: itkQuasiNewtonOptimizerv4.h:134
itk::QuasiNewtonOptimizerv4Template
class ITK_FORWARD_EXPORT QuasiNewtonOptimizerv4Template
Definition: itkQuasiNewtonOptimizerv4EstimateNewtonStepThreader.h:27
itk::GradientDescentOptimizerv4Template::DerivativeType
typename Superclass::DerivativeType DerivativeType
Definition: itkGradientDescentOptimizerv4.h:102
itk::GradientDescentOptimizerv4Template
Gradient descent optimizer.
Definition: itkGradientDescentOptimizerv4.h:78
itk::QuasiNewtonOptimizerv4Template::m_NewtonStep
DerivativeType m_NewtonStep
Definition: itkQuasiNewtonOptimizerv4.h:143
itk::QuasiNewtonOptimizerv4Template::m_BestPosition
ParametersType m_BestPosition
Definition: itkQuasiNewtonOptimizerv4.h:139
itk::QuasiNewtonOptimizerv4Template::m_OptimalStep
ParametersType m_OptimalStep
Definition: itkQuasiNewtonOptimizerv4.h:131
itk::QuasiNewtonOptimizerv4Template
Implement a Quasi-Newton optimizer with BFGS Hessian estimation.
Definition: itkQuasiNewtonOptimizerv4.h:60
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::GradientDescentOptimizerBasev4Template::ParametersType
typename Superclass::ParametersType ParametersType
Definition: itkGradientDescentOptimizerBasev4.h:94
itk::GradientDescentOptimizerBasev4Template::IndexRangeType
ThreadedIndexedContainerPartitioner::IndexRangeType IndexRangeType
Definition: itkGradientDescentOptimizerBasev4.h:169
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::QuasiNewtonOptimizerv4Template::m_HessianArray
HessianArrayType m_HessianArray
Definition: itkQuasiNewtonOptimizerv4.h:152
itkGradientDescentOptimizerv4.h
itk::QuasiNewtonOptimizerv4Template::m_BestValue
MeasureType m_BestValue
Definition: itkQuasiNewtonOptimizerv4.h:138
itk::QuasiNewtonOptimizerv4Template::m_PreviousPosition
ParametersType m_PreviousPosition
Definition: itkQuasiNewtonOptimizerv4.h:135
itk::GradientDescentOptimizerBasev4Template::InternalComputationValueType
TInternalComputationValueType InternalComputationValueType
Definition: itkGradientDescentOptimizerBasev4.h:80
itk::QuasiNewtonOptimizerv4Template::m_NewtonStepValidFlags
std::vector< bool > m_NewtonStepValidFlags
Definition: itkQuasiNewtonOptimizerv4.h:155
itkArray2D.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::QuasiNewtonOptimizerv4Template::m_CurrentPosition
ParametersType m_CurrentPosition
Definition: itkQuasiNewtonOptimizerv4.h:130
itk::QuasiNewtonOptimizerv4Template::m_EstimateNewtonStepThreader
DomainThreader< ThreadedIndexedContainerPartitioner, Self >::Pointer m_EstimateNewtonStepThreader
Definition: itkQuasiNewtonOptimizerv4.h:205
itk::IndexValueType
signed long IndexValueType
Definition: itkIntTypes.h:90
itk::Array2D
Array2D class representing a 2D array with size defined at construction time.
Definition: itkArray2D.h:45
itk::QuasiNewtonOptimizerv4Template::m_MaximumNewtonStepSizeInPhysicalUnits
TInternalComputationValueType m_MaximumNewtonStepSizeInPhysicalUnits
Definition: itkQuasiNewtonOptimizerv4.h:149
itk::GradientDescentOptimizerBasev4Template::DerivativeType
typename Superclass::DerivativeType DerivativeType
Definition: itkGradientDescentOptimizerBasev4.h:87
itk::GradientDescentOptimizerv4Template::ParametersType
typename Superclass::ParametersType ParametersType
Definition: itkGradientDescentOptimizerv4.h:108
itk::QuasiNewtonOptimizerv4Template::HessianArrayType
std::vector< HessianType > HessianArrayType
Definition: itkQuasiNewtonOptimizerv4.h:90
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::GradientDescentOptimizerv4Template::MeasureType
typename Superclass::MeasureType MeasureType
Definition: itkGradientDescentOptimizerv4.h:105
itk::GradientDescentOptimizerBasev4Template::MeasureType
typename Superclass::MeasureType MeasureType
Definition: itkGradientDescentOptimizerBasev4.h:90
itk::QuasiNewtonOptimizerv4Template::m_NewtonStepWarning
std::string m_NewtonStepWarning
Definition: itkQuasiNewtonOptimizerv4.h:146