ITK  5.3.0
Insight Toolkit
itkLBFGSOptimizer.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 : public SingleValuedNonLinearVnlOptimizer
86 {
87 public:
88  ITK_DISALLOW_COPY_AND_MOVE(LBFGSOptimizer);
89 
95 
97  itkNewMacro(Self);
98 
101 
103  using InternalParametersType = vnl_vector<double>;
104 
106  using InternalOptimizerType = vnl_lbfgs;
107 
109  vnl_lbfgs *
110  GetOptimizer();
111 
113  void
114  StartOptimization() override;
115 
117  void
118  SetCostFunction(SingleValuedCostFunction * costFunction) override;
119 
123  virtual void
124  SetTrace(bool flag);
125 
126  itkGetMacro(Trace, bool);
127  itkBooleanMacro(Trace);
128 
130  virtual void
131  SetMaximumNumberOfFunctionEvaluations(unsigned int n);
132 
133  itkGetMacro(MaximumNumberOfFunctionEvaluations, unsigned int);
134 
140  virtual void
141  SetGradientConvergenceTolerance(double f);
142 
143  itkGetMacro(GradientConvergenceTolerance, double);
144 
151  virtual void
152  SetLineSearchAccuracy(double f);
153 
154  itkGetMacro(LineSearchAccuracy, double);
155 
160  virtual void
161  SetDefaultStepLength(double f);
162 
163  itkGetMacro(DefaultStepLength, double);
164 
167  GetValue() const;
168 
170  const std::string
171  GetStopConditionDescription() const override;
172 
173 protected:
174  LBFGSOptimizer();
175  ~LBFGSOptimizer() override;
176  void
177  PrintSelf(std::ostream & os, Indent indent) const override;
178 
179  using CostFunctionAdaptorType = Superclass::CostFunctionAdaptorType;
180 
181 private:
184  mutable std::ostringstream m_StopConditionDescription;
185 
186  bool m_Trace;
191 };
192 } // end namespace itk
193 
194 #endif
itk::LBFGSOptimizer::m_OptimizerInitialized
bool m_OptimizerInitialized
Definition: itkLBFGSOptimizer.h:182
itk::LBFGSOptimizer::m_VnlOptimizer
InternalOptimizerType * m_VnlOptimizer
Definition: itkLBFGSOptimizer.h:183
itk::LBFGSOptimizer::m_LineSearchAccuracy
double m_LineSearchAccuracy
Definition: itkLBFGSOptimizer.h:189
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::LBFGSOptimizer::m_GradientConvergenceTolerance
double m_GradientConvergenceTolerance
Definition: itkLBFGSOptimizer.h:188
itk::LBFGSOptimizer::m_Trace
bool m_Trace
Definition: itkLBFGSOptimizer.h:186
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::SingleValuedCostFunction
This class is a base for the CostFunctions returning a single value.
Definition: itkSingleValuedCostFunction.h:34
itk::LBFGSOptimizer::m_MaximumNumberOfFunctionEvaluations
unsigned int m_MaximumNumberOfFunctionEvaluations
Definition: itkLBFGSOptimizer.h:187
itk::LBFGSOptimizer::CostFunctionAdaptorType
Superclass::CostFunctionAdaptorType CostFunctionAdaptorType
Definition: itkLBFGSOptimizer.h:179
itk::LBFGSOptimizer::m_StopConditionDescription
std::ostringstream m_StopConditionDescription
Definition: itkLBFGSOptimizer.h:184
itkSingleValuedNonLinearVnlOptimizer.h
itk::LBFGSOptimizer::InternalOptimizerType
vnl_lbfgs InternalOptimizerType
Definition: itkLBFGSOptimizer.h:106
itk::LBFGSOptimizer::m_DefaultStepLength
double m_DefaultStepLength
Definition: itkLBFGSOptimizer.h:190
itk::LBFGSOptimizer
Wrap of the vnl_lbfgs algorithm for use in ITKv4 registration framework. The vnl_lbfgs is a wrapper f...
Definition: itkLBFGSOptimizer.h:85
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::SingleValuedNonLinearOptimizer::MeasureType
CostFunctionType::MeasureType MeasureType
Definition: itkSingleValuedNonLinearOptimizer.h:62
itk::LBFGSOptimizer::InternalParametersType
vnl_vector< double > InternalParametersType
Definition: itkLBFGSOptimizer.h:103
itk::SingleValuedNonLinearVnlOptimizer
This class is a base for the Optimization methods that optimize a single valued function.
Definition: itkSingleValuedNonLinearVnlOptimizer.h:37