ITK  4.13.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:
68 
70  itkNewMacro(Self);
71 
74 
76  typedef TInternalComputationValueType InternalComputationValueType;
77 
78  typedef typename Superclass::ParametersType ParametersType;
80  typedef typename Superclass::DerivativeType DerivativeType;
81  typedef typename Superclass::IndexRangeType IndexRangeType;
82  typedef typename Superclass::StopConditionType StopConditionType;
83 
86 
88  typedef std::vector<HessianType> HessianArrayType;
89 
91  virtual void StartOptimization( bool doOnlyInitialization = false ) ITK_OVERRIDE;
92 
94  itkSetMacro(MaximumIterationsWithoutProgress, SizeValueType);
95 
110  itkSetMacro(MaximumNewtonStepSizeInPhysicalUnits, TInternalComputationValueType);
111 
113  itkGetConstReferenceMacro( NewtonStep, DerivativeType );
114 
119  virtual void EstimateNewtonStepOverSubRange( const IndexRangeType& subrange );
120 
121 protected:
122 
124  SizeValueType m_MaximumIterationsWithoutProgress;
125 
127  ParametersType m_CurrentPosition;
128  ParametersType m_OptimalStep;
129 
131  MeasureType m_PreviousValue;
132  ParametersType m_PreviousPosition;
133 
135  MeasureType m_BestValue;
136  ParametersType m_BestPosition;
137  SizeValueType m_BestIteration;
138 
140  DerivativeType m_NewtonStep;
141 
143  std::string m_NewtonStepWarning;
144 
146  TInternalComputationValueType m_MaximumNewtonStepSizeInPhysicalUnits;
147 
149  HessianArrayType m_HessianArray;
150 
152  std::vector<bool> m_NewtonStepValidFlags;
153 
155  virtual void EstimateNewtonStep();
156 
161  virtual bool ComputeHessianAndStepWithBFGS(IndexValueType location);
162 
164  virtual void ResetNewtonStep(IndexValueType location);
165 
170  void CombineGradientNewtonStep();
171 
180  void ModifyCombinedNewtonStep();
181 
186  virtual void AdvanceOneStep(void) ITK_OVERRIDE;
187 
189  virtual ~QuasiNewtonOptimizerv4Template() ITK_OVERRIDE;
190 
191  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
192 
193 private:
194  ITK_DISALLOW_COPY_AND_ASSIGN(QuasiNewtonOptimizerv4Template);
195 
197  typename DomainThreader<ThreadedIndexedContainerPartitioner, Self>::Pointer m_EstimateNewtonStepThreader;
198 };
199 
201 typedef QuasiNewtonOptimizerv4Template<double> QuasiNewtonOptimizerv4;
202 
203 } // end namespace itk
204 
205 #ifndef ITK_MANUAL_INSTANTIATION
206 #include "itkQuasiNewtonOptimizerv4.hxx"
207 #endif
208 
209 #endif
itk::Array2D< TInternalComputationValueType > HessianType
Light weight base class for most itk classes.
Multi-threaded processing on a domain by processing sub-domains per thread.
signed long IndexValueType
Definition: itkIntTypes.h:150
Superclass::StopConditionType StopConditionType
unsigned long SizeValueType
Definition: itkIntTypes.h:143
GradientDescentOptimizerv4Template< TInternalComputationValueType > Superclass
Array2D class representing a 2D array with size defined at construction time.
Definition: itkArray2D.h:45
TInternalComputationValueType InternalComputationValueType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
ThreadedIndexedContainerPartitioner::IndexRangeType IndexRangeType
Implement a Quasi-Newton optimizer with BFGS Hessian estimation.