ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkQuasiNewtonOptimizerv4.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 {
58 template<typename TInternalComputationValueType>
59 class ITK_TEMPLATE_EXPORT QuasiNewtonOptimizerv4Template :
60  public GradientDescentOptimizerv4Template<TInternalComputationValueType>
61 {
62 public:
63  ITK_DISALLOW_COPY_AND_ASSIGN(QuasiNewtonOptimizerv4Template);
64 
70 
72  itkNewMacro(Self);
73 
76 
78  using InternalComputationValueType = TInternalComputationValueType;
79 
83  using IndexRangeType = typename Superclass::IndexRangeType;
84  using StopConditionType = typename Superclass::StopConditionType;
85 
88 
90  using HessianArrayType = std::vector<HessianType>;
91 
93  void StartOptimization( bool doOnlyInitialization = false ) override;
94 
96  itkSetMacro(MaximumIterationsWithoutProgress, SizeValueType);
97 
112  itkSetMacro(MaximumNewtonStepSizeInPhysicalUnits, TInternalComputationValueType);
113 
115  itkGetConstReferenceMacro( NewtonStep, DerivativeType );
116 
121  virtual void EstimateNewtonStepOverSubRange( const IndexRangeType& subrange );
122 
123 protected:
124 
126  SizeValueType m_MaximumIterationsWithoutProgress{30};
127 
131 
135 
139  SizeValueType m_BestIteration{0};
140 
143 
145  std::string m_NewtonStepWarning;
146 
148  TInternalComputationValueType m_MaximumNewtonStepSizeInPhysicalUnits;
149 
152 
154  std::vector<bool> m_NewtonStepValidFlags;
155 
157  virtual void EstimateNewtonStep();
158 
163  virtual bool ComputeHessianAndStepWithBFGS(IndexValueType location);
164 
166  virtual void ResetNewtonStep(IndexValueType location);
167 
172  void CombineGradientNewtonStep();
173 
182  void ModifyCombinedNewtonStep();
183 
188  void AdvanceOneStep() override;
189 
191  ~QuasiNewtonOptimizerv4Template() override = default;
192 
193  void PrintSelf(std::ostream & os, Indent indent) const override;
194 
195 private:
198 };
199 
202 
203 } // end namespace itk
204 
205 #ifndef ITK_MANUAL_INSTANTIATION
206 #include "itkQuasiNewtonOptimizerv4.hxx"
207 #endif
208 
209 #endif
Light weight base class for most itk classes.
unsigned long SizeValueType
Definition: itkIntTypes.h:83
typename Superclass::ParametersType ParametersType
DomainThreader< ThreadedIndexedContainerPartitioner, Self >::Pointer m_EstimateNewtonStepThreader
typename Superclass::DerivativeType DerivativeType
Array2D class representing a 2D array with size defined at construction time.
Definition: itkArray2D.h:45
signed long IndexValueType
Definition: itkIntTypes.h:90
class ITK_FORWARD_EXPORT QuasiNewtonOptimizerv4Template
TInternalComputationValueType m_MaximumNewtonStepSizeInPhysicalUnits
Control indentation during Print() invocation.
Definition: itkIndent.h:49
ThreadedIndexedContainerPartitioner::IndexRangeType IndexRangeType
Implement a Quasi-Newton optimizer with BFGS Hessian estimation.