ITK  6.0.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 * https://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#include <memory> // For unique_ptr.
25
26namespace itk
27{
86class ITKOptimizers_EXPORT LBFGSOptimizer : public SingleValuedNonLinearVnlOptimizer
87{
88public:
89 ITK_DISALLOW_COPY_AND_MOVE(LBFGSOptimizer);
90
96
98 itkNewMacro(Self);
99
101 itkOverrideGetNameOfClassMacro(LBFGSOptimizer);
102
104 using InternalParametersType = vnl_vector<double>;
105
107 using InternalOptimizerType = vnl_lbfgs;
108
110 vnl_lbfgs *
112
114 void
116
118 void
120
124 virtual void
125 SetTrace(bool flag);
126
127 itkGetMacro(Trace, bool);
128 itkBooleanMacro(Trace);
129
131 virtual void
133
134 itkGetMacro(MaximumNumberOfFunctionEvaluations, unsigned int);
135
141 virtual void
143
144 itkGetMacro(GradientConvergenceTolerance, double);
145
152 virtual void
154
155 itkGetMacro(LineSearchAccuracy, double);
156
161 virtual void
163
164 itkGetMacro(DefaultStepLength, double);
165
168 GetValue() const;
169
171 const std::string
173
174protected:
176 ~LBFGSOptimizer() override;
177 void
178 PrintSelf(std::ostream & os, Indent indent) const override;
179
180 using CostFunctionAdaptorType = Superclass::CostFunctionAdaptorType;
181
182private:
183 bool m_OptimizerInitialized{};
184 std::unique_ptr<InternalOptimizerType> m_VnlOptimizer;
185 mutable std::ostringstream m_StopConditionDescription{};
186
187 bool m_Trace{};
188 unsigned int m_MaximumNumberOfFunctionEvaluations{};
189 double m_GradientConvergenceTolerance{};
190 double m_LineSearchAccuracy{};
191 double m_DefaultStepLength{};
192};
193} // end namespace itk
194
195#endif
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Wrap of the vnl_lbfgs algorithm for use in ITKv4 registration framework. The vnl_lbfgs is a wrapper f...
const std::string GetStopConditionDescription() const override
void StartOptimization() override
void PrintSelf(std::ostream &os, Indent indent) const override
vnl_lbfgs * GetOptimizer()
Superclass::CostFunctionAdaptorType CostFunctionAdaptorType
virtual void SetMaximumNumberOfFunctionEvaluations(unsigned int n)
virtual void SetGradientConvergenceTolerance(double f)
MeasureType GetValue() const
virtual void SetDefaultStepLength(double f)
vnl_vector< double > InternalParametersType
virtual void SetTrace(bool flag)
void SetCostFunction(SingleValuedCostFunction *costFunction) override
std::unique_ptr< InternalOptimizerType > m_VnlOptimizer
virtual void SetLineSearchAccuracy(double f)
~LBFGSOptimizer() override
Light weight base class for most itk classes.
This class is a base for the CostFunctions returning a single value.
This class is a base for the Optimization methods that optimize a single valued function.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....