ITK  5.4.0
Insight Toolkit
itkLBFGSBOptimizerv4.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 itkLBFGSBOptimizerv4_h
19 #define itkLBFGSBOptimizerv4_h
20 
22 #include "vnl/algo/vnl_lbfgsb.h"
23 #include "ITKOptimizersv4Export.h"
24 
25 namespace itk
26 {
27 /* Necessary forward declaration */
37 // Forward reference because of private implementation
38 class ITK_FORWARD_EXPORT LBFGSBOptimizerHelperv4;
39 
67 class ITKOptimizersv4_EXPORT LBFGSBOptimizerv4 : public LBFGSOptimizerBasev4<vnl_lbfgsb>
68 {
69 public:
70  ITK_DISALLOW_COPY_AND_MOVE(LBFGSBOptimizerv4);
71 
77 
78  using MetricType = Superclass::MetricType;
79  using ParametersType = Superclass::ParametersType;
80  using ScalesType = Superclass::ScalesType;
81 
83  itkNewMacro(Self);
84 
87 
89  {
90  UNBOUNDED = 0,
91  LOWERBOUNDED = 1,
92  BOTHBOUNDED = 2,
93  UPPERBOUNDED = 3
94  };
95 
100 
105 
107  void
108  SetInitialPosition(const ParametersType & param);
109 
113  {
114  return m_InitialPosition;
115  }
116 
118  void
119  StartOptimization(bool doOnlyInitialization = false) override;
120 
122  void
123  SetMetric(MetricType * metric) override;
124 
126  void
127  SetLowerBound(const BoundValueType & value);
128 
129  itkGetConstReferenceMacro(LowerBound, BoundValueType);
130 
132  void
133  SetUpperBound(const BoundValueType & value);
134 
135  itkGetConstReferenceMacro(UpperBound, BoundValueType);
136 
143  void
144  SetBoundSelection(const BoundSelectionType & value);
145 
146  itkGetConstReferenceMacro(BoundSelection, BoundSelectionType);
147 
154  virtual void
155  SetCostFunctionConvergenceFactor(double);
156 
157  itkGetConstMacro(CostFunctionConvergenceFactor, double);
158 
160  virtual void
161  SetMaximumNumberOfCorrections(unsigned int);
162 
163  itkGetConstMacro(MaximumNumberOfCorrections, unsigned int);
164 
166  void
167  SetScales(const ScalesType &) override;
168 
171  itkGetConstReferenceMacro(InfinityNormOfProjectedGradient, double);
172 
174  bool
175  CanUseScales() const override
176  {
177  return false;
178  }
179 
180 protected:
182  ~LBFGSBOptimizerv4() override;
183  void
184  PrintSelf(std::ostream & os, Indent indent) const override;
185 
186  using CostFunctionAdaptorType = Superclass::CostFunctionAdaptorType;
187 
190 
192 
193 private:
194  unsigned int m_MaximumNumberOfCorrections{ 5 };
195 
196  ParametersType m_InitialPosition{};
197  BoundValueType m_LowerBound{};
198  BoundValueType m_UpperBound{};
199  BoundSelectionType m_BoundSelection{};
200 };
201 } // end namespace itk
202 #endif
itk::LBFGSBOptimizerv4
Limited memory Broyden Fletcher Goldfarb Shannon minimization with simple bounds.
Definition: itkLBFGSBOptimizerv4.h:67
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::LBFGSBOptimizerv4::MetricType
Superclass::MetricType MetricType
Definition: itkLBFGSBOptimizerv4.h:78
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::LBFGSBOptimizerv4::CostFunctionAdaptorType
Superclass::CostFunctionAdaptorType CostFunctionAdaptorType
Definition: itkLBFGSBOptimizerv4.h:186
itk::LBFGSBOptimizerv4::ScalesType
Superclass::ScalesType ScalesType
Definition: itkLBFGSBOptimizerv4.h:80
itkOverrideGetNameOfClassMacro
itkOverrideGetNameOfClassMacro(AddImageFilter)
itk::LBFGSBOptimizerv4::BoundSelectionValues
BoundSelectionValues
Definition: itkLBFGSBOptimizerv4.h:88
LBFGSBOptimizerHelperv4
Wrapper helper around vnl_lbfgsb.
itk::LBFGSBOptimizerv4::ParametersType
Superclass::ParametersType ParametersType
Definition: itkLBFGSBOptimizerv4.h:79
itk::LBFGSBOptimizerHelperv4
class ITK_FORWARD_EXPORT LBFGSBOptimizerHelperv4
Definition: itkLBFGSBOptimizerv4.h:38
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::LBFGSBOptimizerv4::GetInitialPosition
ParametersType & GetInitialPosition()
Definition: itkLBFGSBOptimizerv4.h:112
itk::LBFGSBOptimizerv4::CanUseScales
bool CanUseScales() const override
Definition: itkLBFGSBOptimizerv4.h:175
itk::Array< double >
itkLBFGSOptimizerBasev4.h
itk::LBFGSOptimizerBasev4
Abstract base for vnl lbfgs algorithm optimizers in ITKv4 registration framework.
Definition: itkLBFGSOptimizerBasev4.h:76