ITK  4.1.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 
00104   itkSetMacro(MaximumNewtonStepSizeInPhysicalUnits, InternalComputationValueType);
00105 
00107   itkGetConstReferenceMacro( NewtonStep, DerivativeType );
00108 
00109 protected:
00110 
00112   SizeValueType   m_MaximumIterationsWithoutProgress;
00113 
00115   ParametersType  m_CurrentPosition;
00116   ParametersType  m_OptimalStep;
00117 
00119   MeasureType     m_PreviousValue;
00120   ParametersType  m_PreviousPosition;
00121   DerivativeType  m_PreviousGradient;
00122 
00124   MeasureType     m_BestValue;
00125   ParametersType  m_BestPosition;
00126   SizeValueType   m_BestIteration;
00127 
00129   DerivativeType  m_NewtonStep;
00130 
00132   std::string     m_NewtonStepWarning;
00133 
00135   InternalComputationValueType  m_MaximumNewtonStepSizeInPhysicalUnits;
00136 
00138   HessianArrayType  m_HessianArray;
00139 
00141   std::vector<bool> m_NewtonStepValidFlags;
00142 
00144   virtual void EstimateNewtonStep();
00145 
00149   virtual void EstimateNewtonStepOverSubRange( const IndexRangeType& subrange );
00150 
00155   virtual bool ComputeHessianAndStepWithBFGS(IndexValueType location);
00156 
00158   virtual void ResetNewtonStep(IndexValueType location);
00159 
00164   void CombineGradientNewtonStep(void);
00165 
00174   void ModifyCombinedNewtonStep();
00175 
00180   virtual void AdvanceOneStep(void);
00181 
00182   QuasiNewtonOptimizerv4();
00183   virtual ~QuasiNewtonOptimizerv4();
00184 
00185   virtual void PrintSelf(std::ostream & os, Indent indent) const;
00186 
00187   friend class QuasiNewtonOptimizerv4EstimateNewtonStepThreader;
00188 
00189 private:
00190   QuasiNewtonOptimizerv4(const Self &);     //purposely not implemented
00191   void operator=(const Self &);           //purposely not implemented
00192 
00194   QuasiNewtonOptimizerv4EstimateNewtonStepThreader::Pointer m_EstimateNewtonStepThreader;
00195 };
00196 } // end namespace itk
00197 
00198 #endif
00199