ITK  4.4.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 
24 namespace itk
25 {
32 class ITK_EXPORT LBFGSOptimizer:
34 {
35 public:
41 
43  itkNewMacro(Self);
44 
47 
49  typedef vnl_vector< double > InternalParametersType;
50 
52  typedef vnl_lbfgs InternalOptimizerType;
53 
55  vnl_lbfgs * GetOptimizer(void);
56 
58  void StartOptimization(void);
59 
61  virtual void SetCostFunction(SingleValuedCostFunction *costFunction);
62 
66  virtual void SetTrace(bool flag);
67 
68  itkGetMacro(Trace, bool);
69  itkBooleanMacro(Trace);
70 
72  virtual void SetMaximumNumberOfFunctionEvaluations(unsigned int n);
73 
74  itkGetMacro(MaximumNumberOfFunctionEvaluations, unsigned int);
75 
81  virtual void SetGradientConvergenceTolerance(double gtol);
82 
83  itkGetMacro(GradientConvergenceTolerance, double);
84 
91  virtual void SetLineSearchAccuracy(double tol);
92 
93  itkGetMacro(LineSearchAccuracy, double);
94 
99  virtual void SetDefaultStepLength(double stp);
100 
101  itkGetMacro(DefaultStepLength, double);
102 
104  MeasureType GetValue() const;
105 
107  const std::string GetStopConditionDescription() const;
108 
109 protected:
110  LBFGSOptimizer();
111  virtual ~LBFGSOptimizer();
112  void PrintSelf(std::ostream & os, Indent indent) const;
113 
114  typedef Superclass::CostFunctionAdaptorType CostFunctionAdaptorType;
115 
116 private:
117  LBFGSOptimizer(const Self &); //purposely not implemented
118  void operator=(const Self &); //purposely not implemented
119 
122  mutable std::ostringstream m_StopConditionDescription;
123 
124  bool m_Trace;
129 };
130 } // end namespace itk
131 
132 #endif
133