00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkLBFGSBOptimizer_h
00018 #define __itkLBFGSBOptimizer_h
00019
00020 #include "itkSingleValuedNonLinearVnlOptimizer.h"
00021
00022 namespace itk
00023 {
00024
00031 class ITK_EXPORT LBFGSBOptimizerHelper;
00032
00033
00059 class ITK_EXPORT LBFGSBOptimizer :
00060 public SingleValuedNonLinearVnlOptimizer
00061 {
00062 public:
00064 typedef LBFGSBOptimizer Self;
00065 typedef SingleValuedNonLinearVnlOptimizer Superclass;
00066 typedef SmartPointer<Self> Pointer;
00067 typedef SmartPointer<const Self> ConstPointer;
00068
00070 itkNewMacro(Self);
00071
00073 itkTypeMacro( LBFGSBOptimizer, SingleValuedNonLinearVnlOptimizer );
00074
00078 typedef Array<double> BoundValueType;
00079
00083 typedef Array<long> BoundSelectionType;
00084
00086 typedef vnl_vector<double> InternalBoundValueType;
00087
00089 typedef vnl_vector<long> InternalBoundSelectionType;
00090
00092 typedef LBFGSBOptimizerHelper InternalOptimizerType;
00093
00094
00096 void StartOptimization( void );
00097
00099 virtual void SetCostFunction( SingleValuedCostFunction * costFunction );
00100
00102 virtual void SetLowerBound( const BoundValueType & value );
00103 virtual const BoundValueType & GetLowerBound();
00105
00107 virtual void SetUpperBound( const BoundValueType & value );
00108 virtual const BoundValueType & GetUpperBound();
00110
00117 virtual void SetBoundSelection( const BoundSelectionType & select );
00118 virtual const BoundSelectionType & GetBoundSelection();
00120
00127 virtual void SetCostFunctionConvergenceFactor( double );
00128 itkGetMacro( CostFunctionConvergenceFactor, double );
00130
00135 virtual void SetProjectedGradientTolerance( double );
00136 itkGetMacro( ProjectedGradientTolerance, double );
00138
00140 virtual void SetMaximumNumberOfIterations( unsigned int );
00141 itkGetMacro( MaximumNumberOfIterations, unsigned int );
00143
00145 virtual void SetMaximumNumberOfEvaluations( unsigned int );
00146 itkGetMacro( MaximumNumberOfEvaluations, unsigned int );
00148
00150 virtual void SetMaximumNumberOfCorrections( unsigned int );
00151 itkGetMacro( MaximumNumberOfCorrections, unsigned int );
00153
00155 void SetScales( const ScalesType & )
00156 {
00157 itkExceptionMacro( << "This optimizer does not support scales." );
00158 }
00159
00161 itkGetConstReferenceMacro( CurrentIteration, unsigned int );
00162
00164 itkGetConstReferenceMacro( Value, MeasureType );
00165
00168 itkGetConstReferenceMacro( InfinityNormOfProjectedGradient, double );
00169
00170 protected:
00171 LBFGSBOptimizer();
00172 virtual ~LBFGSBOptimizer();
00173 void PrintSelf(std::ostream& os, Indent indent) const;
00174
00175 typedef Superclass::CostFunctionAdaptorType CostFunctionAdaptorType;
00176
00177 private:
00178 LBFGSBOptimizer(const Self&);
00179 void operator=(const Self&);
00180
00181
00182
00183 friend class LBFGSBOptimizerHelper;
00184
00185 bool m_OptimizerInitialized;
00186 InternalOptimizerType * m_VnlOptimizer;
00187
00188 BoundValueType m_LowerBound;
00189 BoundValueType m_UpperBound;
00190 BoundSelectionType m_BoundSelection;
00191
00192 double m_CostFunctionConvergenceFactor;
00193 double m_ProjectedGradientTolerance;
00194 unsigned int m_MaximumNumberOfIterations;
00195 unsigned int m_MaximumNumberOfEvaluations;
00196 unsigned int m_MaximumNumberOfCorrections;
00197
00198 unsigned int m_CurrentIteration;
00199 MeasureType m_Value;
00200 double m_InfinityNormOfProjectedGradient;
00201
00202 };
00203
00204 }
00205
00206 #endif
00207