ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkLBFGSBOptimizer.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 itkLBFGSBOptimizer_h
19#define itkLBFGSBOptimizer_h
20
21#include "itkIntTypes.h"
23#include "ITKOptimizersExport.h"
24#include <memory> // For unique_ptr.
25
26namespace itk
27{
28/* Necessary forward declaration see below for definition */
36class ITK_FORWARD_EXPORT LBFGSBOptimizerHelper;
37
53class ITKOptimizers_EXPORT LBFGSBOptimizer : public SingleValuedNonLinearVnlOptimizer
54{
55public:
56 ITK_DISALLOW_COPY_AND_MOVE(LBFGSBOptimizer);
57
63
65 itkNewMacro(Self);
66
68 itkOverrideGetNameOfClassMacro(LBFGSBOptimizer);
69
74
79
81 using InternalBoundValueType = vnl_vector<double>;
82
84 using InternalBoundSelectionType = vnl_vector<long>;
85
88
90 void
92
94 void
95 SetCostFunction(SingleValuedCostFunction * costFunction) override;
96
100 virtual void
101 SetTrace(bool flag);
102
103 itkGetMacro(Trace, bool);
104 itkBooleanMacro(Trace);
105
107 virtual void
109 itkGetConstReferenceMacro(LowerBound, BoundValueType);
111
113 virtual void
115 itkGetConstReferenceMacro(UpperBound, BoundValueType);
117
124 virtual void
126 itkGetConstReferenceMacro(BoundSelection, BoundSelectionType);
128
135 virtual void
137
138 itkGetMacro(CostFunctionConvergenceFactor, double);
139
144 virtual void
146
147 itkGetMacro(ProjectedGradientTolerance, double);
148
150 virtual void
152
153 itkGetMacro(MaximumNumberOfIterations, unsigned int);
154
156 virtual void
158
159 itkGetMacro(MaximumNumberOfEvaluations, unsigned int);
160
162 virtual void
164
165 itkGetMacro(MaximumNumberOfCorrections, unsigned int);
166
168 void
170 {
171 itkExceptionMacro("This optimizer does not support scales.");
172 }
173
175 itkGetConstReferenceMacro(CurrentIteration, unsigned int);
176
179 GetValue() const;
180
183 itkGetConstReferenceMacro(InfinityNormOfProjectedGradient, double);
184
186 std::string
188
190 bool
191 CanUseScales() const override
192 {
193 return false;
194 }
195
196protected:
199 void
200 PrintSelf(std::ostream & os, Indent indent) const override;
201
203
204private:
205 // give the helper access to member variables, to update iteration
206 // counts, etc.
208
209 bool m_Trace{ false };
213 unsigned int m_MaximumNumberOfIterations{ 500 };
214 unsigned int m_MaximumNumberOfEvaluations{ 500 };
216 unsigned int m_CurrentIteration{ 0 };
218
219 std::unique_ptr<InternalOptimizerType> m_VnlOptimizer;
223};
224} // end namespace itk
225
226#endif
Array class with size defined at construction time.
Definition itkArray.h:48
Control indentation during Print() invocation.
Definition itkIndent.h:50
virtual void SetProjectedGradientTolerance(double)
SingleValuedNonLinearVnlOptimizer Superclass
~LBFGSBOptimizer() override
bool CanUseScales() const override
unsigned int m_MaximumNumberOfCorrections
std::unique_ptr< InternalOptimizerType > m_VnlOptimizer
virtual void SetCostFunctionConvergenceFactor(double)
vnl_vector< long > InternalBoundSelectionType
void SetCostFunction(SingleValuedCostFunction *costFunction) override
Superclass::CostFunctionAdaptorType CostFunctionAdaptorType
friend class LBFGSBOptimizerHelper
virtual void SetMaximumNumberOfIterations(unsigned int)
virtual void SetMaximumNumberOfEvaluations(unsigned int)
unsigned int m_MaximumNumberOfEvaluations
LBFGSBOptimizerHelper InternalOptimizerType
SmartPointer< const Self > ConstPointer
virtual void SetMaximumNumberOfCorrections(unsigned int)
vnl_vector< double > InternalBoundValueType
std::string GetStopConditionDescription() const override
MeasureType GetValue() const
void StartOptimization() override
virtual void SetUpperBound(const BoundValueType &value)
unsigned int m_MaximumNumberOfIterations
virtual void SetLowerBound(const BoundValueType &value)
Array< double > BoundValueType
virtual void SetBoundSelection(const BoundSelectionType &value)
SmartPointer< Self > Pointer
Array< long > BoundSelectionType
virtual void SetTrace(bool flag)
BoundSelectionType m_BoundSelection
void SetScales(const ScalesType &)
void PrintSelf(std::ostream &os, Indent indent) const override
Superclass::ScalesType ScalesType
This class is a base for the CostFunctions returning a single value.
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
class ITK_FORWARD_EXPORT LBFGSBOptimizerHelper