ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkLBFGSOptimizer.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkLBFGSOptimizer_h
19 #define itkLBFGSOptimizer_h
20 
22 #include "vnl/algo/vnl_lbfgs.h"
23 #include "ITKOptimizersExport.h"
24 
25 namespace itk
26 {
33 class ITKOptimizers_EXPORT LBFGSOptimizer:
35 {
36 public:
42 
44  itkNewMacro(Self);
45 
48 
50  typedef vnl_vector< double > InternalParametersType;
51 
53  typedef vnl_lbfgs InternalOptimizerType;
54 
56  vnl_lbfgs * GetOptimizer();
57 
59  virtual void StartOptimization(void) ITK_OVERRIDE;
60 
62  virtual void SetCostFunction(SingleValuedCostFunction *costFunction) ITK_OVERRIDE;
63 
67  virtual void SetTrace(bool flag);
68 
69  itkGetMacro(Trace, bool);
70  itkBooleanMacro(Trace);
71 
73  virtual void SetMaximumNumberOfFunctionEvaluations(unsigned int n);
74 
75  itkGetMacro(MaximumNumberOfFunctionEvaluations, unsigned int);
76 
82  virtual void SetGradientConvergenceTolerance(double gtol);
83 
84  itkGetMacro(GradientConvergenceTolerance, double);
85 
92  virtual void SetLineSearchAccuracy(double tol);
93 
94  itkGetMacro(LineSearchAccuracy, double);
95 
100  virtual void SetDefaultStepLength(double stp);
101 
102  itkGetMacro(DefaultStepLength, double);
103 
105  MeasureType GetValue() const;
106 
108  virtual const std::string GetStopConditionDescription() const ITK_OVERRIDE;
109 
110 protected:
111  LBFGSOptimizer();
112  virtual ~LBFGSOptimizer();
113  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
114 
116 
117 private:
118  LBFGSOptimizer(const Self &); //purposely not implemented
119  void operator=(const Self &); //purposely not implemented
120 
121  bool m_OptimizerInitialized;
122  InternalOptimizerType * m_VnlOptimizer;
123  mutable std::ostringstream m_StopConditionDescription;
124 
125  bool m_Trace;
126  unsigned int m_MaximumNumberOfFunctionEvaluations;
127  double m_GradientConvergenceTolerance;
128  double m_LineSearchAccuracy;
129  double m_DefaultStepLength;
130 };
131 } // end namespace itk
132 
133 #endif
vnl_vector< double > InternalParametersType
This class is a base for the CostFunctions returning a single value.
Light weight base class for most itk classes.
vnl_lbfgs InternalOptimizerType
Superclass::CostFunctionAdaptorType CostFunctionAdaptorType
SmartPointer< const Self > ConstPointer
This class is a base for the Optimization methods that optimize a single valued function.
Wrap of the vnl_lbfgs algorithm.
SmartPointer< Self > Pointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
SingleValuedNonLinearVnlOptimizer Superclass