ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkQuasiNewtonOptimizerv4.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkQuasiNewtonOptimizerv4_h
00019 #define __itkQuasiNewtonOptimizerv4_h
00020 
00021 #include "itkArray2D.h"
00022 #include "itkGradientDescentOptimizerv4.h"
00023 
00024 #include "vnl/algo/vnl_matrix_inverse.h"
00025 #include "vnl/algo/vnl_determinant.h"
00026 
00027 #include "itkQuasiNewtonOptimizerv4EstimateNewtonStepThreader.h"
00028 
00029 namespace itk
00030 {
00060 class ITK_EXPORT QuasiNewtonOptimizerv4:
00061   public GradientDescentOptimizerv4
00062 {
00063 public:
00065   typedef QuasiNewtonOptimizerv4      Self;
00066   typedef GradientDescentOptimizerv4  Superclass;
00067   typedef SmartPointer< Self >        Pointer;
00068   typedef SmartPointer< const Self >  ConstPointer;
00069 
00071   itkNewMacro(Self);
00072 
00074   itkTypeMacro(QuasiNewtonOptimizerv4, GradientDescentObjectOptimizer);
00075 
00076   typedef Superclass::InternalComputationValueType    InternalComputationValueType;
00077 
00079   typedef itk::Array2D<InternalComputationValueType>  HessianType;
00080 
00082   typedef std::vector<HessianType>                    HessianArrayType;
00083 
00085   virtual void StartOptimization();
00086 
00088   itkSetMacro(MaximumIterationsWithoutProgress, SizeValueType);
00089 
00091   itkSetMacro(MaximumNewtonStepSizeInPhysicalUnits, InternalComputationValueType);
00092 
00094   itkGetConstReferenceMacro( NewtonStep, DerivativeType );
00095 
00096 protected:
00097 
00099   SizeValueType   m_MaximumIterationsWithoutProgress;
00100 
00102   ParametersType  m_CurrentPosition;
00103   ParametersType  m_OptimalStep;
00104 
00106   MeasureType     m_PreviousValue;
00107   ParametersType  m_PreviousPosition;
00108   DerivativeType  m_PreviousGradient;
00109 
00111   MeasureType     m_BestValue;
00112   ParametersType  m_BestPosition;
00113   SizeValueType   m_BestIteration;
00114 
00116   DerivativeType  m_NewtonStep;
00117 
00119   std::string     m_NewtonStepWarning;
00120 
00122   InternalComputationValueType  m_MaximumNewtonStepSizeInPhysicalUnits;
00123 
00125   HessianArrayType  m_HessianArray;
00126 
00128   std::vector<bool> m_NewtonStepValidFlags;
00129 
00131   virtual void EstimateNewtonStep();
00132 
00136   virtual void EstimateNewtonStepOverSubRange( const IndexRangeType& subrange );
00137 
00142   virtual bool ComputeHessianAndStepWithBFGS(IndexValueType location);
00143 
00145   virtual void ResetNewtonStep(IndexValueType location);
00146 
00151   void CombineGradientNewtonStep(void);
00152 
00161   void ModifyCombinedNewtonStep();
00162 
00167   virtual void AdvanceOneStep(void);
00168 
00169   QuasiNewtonOptimizerv4();
00170   virtual ~QuasiNewtonOptimizerv4();
00171 
00172   virtual void PrintSelf(std::ostream & os, Indent indent) const;
00173 
00174   friend class QuasiNewtonOptimizerv4EstimateNewtonStepThreader;
00175 
00176 private:
00177   QuasiNewtonOptimizerv4(const Self &);     //purposely not implemented
00178   void operator=(const Self &);           //purposely not implemented
00179 
00181   QuasiNewtonOptimizerv4EstimateNewtonStepThreader::Pointer m_EstimateNewtonStepThreader;
00182 };
00183 } // end namespace itk
00184 
00185 #endif
00186