00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkLBFGSOptimizer.h,v $ 00005 Language: C++ 00006 Date: $Date: 2004/08/20 23:31:54 $ 00007 Version: $Revision: 1.19 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkLBFGSOptimizer_h 00018 #define __itkLBFGSOptimizer_h 00019 00020 #include "itkSingleValuedNonLinearVnlOptimizer.h" 00021 #include "vnl/algo/vnl_lbfgs.h" 00022 00023 namespace itk 00024 { 00025 00031 class ITK_EXPORT LBFGSOptimizer : 00032 public SingleValuedNonLinearVnlOptimizer 00033 { 00034 public: 00036 typedef LBFGSOptimizer Self; 00037 typedef SingleValuedNonLinearVnlOptimizer Superclass; 00038 typedef SmartPointer<Self> Pointer; 00039 typedef SmartPointer<const Self> ConstPointer; 00040 00042 itkNewMacro(Self); 00043 00045 itkTypeMacro( LBFGSOptimizer, SingleValuedNonLinearVnlOptimizer ); 00046 00048 typedef vnl_vector<double> InternalParametersType; 00049 00051 typedef vnl_lbfgs InternalOptimizerType; 00052 00054 vnl_lbfgs * GetOptimizer(void); 00055 00057 void StartOptimization( void ); 00058 00060 virtual void SetCostFunction( SingleValuedCostFunction * costFunction ); 00061 00065 virtual void SetTrace( bool flag ); 00066 itkGetMacro( Trace, bool ); 00067 itkBooleanMacro( Trace ); 00068 00070 virtual void SetMaximumNumberOfFunctionEvaluations( unsigned int n ); 00071 itkGetMacro( MaximumNumberOfFunctionEvaluations, unsigned int ); 00072 00078 virtual void SetGradientConvergenceTolerance( double gtol ); 00079 itkGetMacro( GradientConvergenceTolerance, double ); 00080 00087 virtual void SetLineSearchAccuracy( double tol ); 00088 itkGetMacro( LineSearchAccuracy, double ); 00089 00094 virtual void SetDefaultStepLength( double stp ); 00095 itkGetMacro( DefaultStepLength, double ); 00096 00098 MeasureType GetValue(); 00099 00100 protected: 00101 LBFGSOptimizer(); 00102 virtual ~LBFGSOptimizer(); 00103 void PrintSelf(std::ostream& os, Indent indent) const; 00104 00105 typedef Superclass::CostFunctionAdaptorType CostFunctionAdaptorType; 00106 00107 private: 00108 LBFGSOptimizer(const Self&); //purposely not implemented 00109 void operator=(const Self&); //purposely not implemented 00110 00111 bool m_OptimizerInitialized; 00112 InternalOptimizerType * m_VnlOptimizer; 00113 00114 bool m_Trace; 00115 unsigned int m_MaximumNumberOfFunctionEvaluations; 00116 double m_GradientConvergenceTolerance; 00117 double m_LineSearchAccuracy; 00118 double m_DefaultStepLength; 00119 00120 }; 00121 00122 } // end namespace itk 00123 00124 00125 00126 #endif 00127 00128 00129