ITK  5.0.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 {
85 class ITKOptimizers_EXPORT LBFGSOptimizer:
87 {
88 public:
89  ITK_DISALLOW_COPY_AND_ASSIGN(LBFGSOptimizer);
90 
96 
98  itkNewMacro(Self);
99 
102 
104  using InternalParametersType = vnl_vector< double >;
105 
107  using InternalOptimizerType = vnl_lbfgs;
108 
110  vnl_lbfgs * GetOptimizer();
111 
113  void StartOptimization() override;
114 
116  void SetCostFunction(SingleValuedCostFunction *costFunction) override;
117 
121  virtual void SetTrace(bool flag);
122 
123  itkGetMacro(Trace, bool);
124  itkBooleanMacro(Trace);
125 
127  virtual void SetMaximumNumberOfFunctionEvaluations(unsigned int n);
128 
129  itkGetMacro(MaximumNumberOfFunctionEvaluations, unsigned int);
130 
136  virtual void SetGradientConvergenceTolerance(double gtol);
137 
138  itkGetMacro(GradientConvergenceTolerance, double);
139 
146  virtual void SetLineSearchAccuracy(double tol);
147 
148  itkGetMacro(LineSearchAccuracy, double);
149 
154  virtual void SetDefaultStepLength(double stp);
155 
156  itkGetMacro(DefaultStepLength, double);
157 
159  MeasureType GetValue() const;
160 
162  const std::string GetStopConditionDescription() const override;
163 
164 protected:
165  LBFGSOptimizer();
166  ~LBFGSOptimizer() override;
167  void PrintSelf(std::ostream & os, Indent indent) const override;
168 
169  using CostFunctionAdaptorType = Superclass::CostFunctionAdaptorType;
170 
171 private:
174  mutable std::ostringstream m_StopConditionDescription;
175 
176  bool m_Trace;
181 };
182 } // end namespace itk
183 
184 #endif
InternalOptimizerType * m_VnlOptimizer
This class is a base for the CostFunctions returning a single value.
Light weight base class for most itk classes.
Superclass::CostFunctionAdaptorType CostFunctionAdaptorType
std::ostringstream m_StopConditionDescription
This class is a base for the Optimization methods that optimize a single valued function.
Wrap of the vnl_lbfgs algorithm for use in ITKv4 registration framework. The vnl_lbfgs is a wrapper f...
unsigned int m_MaximumNumberOfFunctionEvaluations
Control indentation during Print() invocation.
Definition: itkIndent.h:49
vnl_vector< double > InternalParametersType