ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
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 __itkLBFGSOptimizer_h 00019 #define __itkLBFGSOptimizer_h 00020 00021 #include "itkSingleValuedNonLinearVnlOptimizer.h" 00022 #include "vnl/algo/vnl_lbfgs.h" 00023 00024 namespace itk 00025 { 00032 class ITK_EXPORT LBFGSOptimizer: 00033 public SingleValuedNonLinearVnlOptimizer 00034 { 00035 public: 00037 typedef LBFGSOptimizer Self; 00038 typedef SingleValuedNonLinearVnlOptimizer Superclass; 00039 typedef SmartPointer< Self > Pointer; 00040 typedef SmartPointer< const Self > ConstPointer; 00041 00043 itkNewMacro(Self); 00044 00046 itkTypeMacro(LBFGSOptimizer, SingleValuedNonLinearVnlOptimizer); 00047 00049 typedef vnl_vector< double > InternalParametersType; 00050 00052 typedef vnl_lbfgs InternalOptimizerType; 00053 00055 vnl_lbfgs * GetOptimizer(void); 00056 00058 void StartOptimization(void); 00059 00061 virtual void SetCostFunction(SingleValuedCostFunction *costFunction); 00062 00066 virtual void SetTrace(bool flag); 00067 00068 itkGetMacro(Trace, bool); 00069 itkBooleanMacro(Trace); 00070 00072 virtual void SetMaximumNumberOfFunctionEvaluations(unsigned int n); 00073 00074 itkGetMacro(MaximumNumberOfFunctionEvaluations, unsigned int); 00075 00081 virtual void SetGradientConvergenceTolerance(double gtol); 00082 00083 itkGetMacro(GradientConvergenceTolerance, double); 00084 00091 virtual void SetLineSearchAccuracy(double tol); 00092 00093 itkGetMacro(LineSearchAccuracy, double); 00094 00099 virtual void SetDefaultStepLength(double stp); 00100 00101 itkGetMacro(DefaultStepLength, double); 00102 00104 MeasureType GetValue() const; 00105 00107 const std::string GetStopConditionDescription() const; 00108 00109 protected: 00110 LBFGSOptimizer(); 00111 virtual ~LBFGSOptimizer(); 00112 void PrintSelf(std::ostream & os, Indent indent) const; 00113 00114 typedef Superclass::CostFunctionAdaptorType CostFunctionAdaptorType; 00115 private: 00116 LBFGSOptimizer(const Self &); //purposely not implemented 00117 void operator=(const Self &); //purposely not implemented 00118 00119 bool m_OptimizerInitialized; 00120 InternalOptimizerType * m_VnlOptimizer; 00121 mutable std::ostringstream m_StopConditionDescription; 00122 00123 bool m_Trace; 00124 unsigned int m_MaximumNumberOfFunctionEvaluations; 00125 double m_GradientConvergenceTolerance; 00126 double m_LineSearchAccuracy; 00127 double m_DefaultStepLength; 00128 }; 00129 } // end namespace itk 00130 00131 #endif 00132