ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkLBFGSOptimizerBasev4.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 itkLBFGSOptimizerBasev4_h
19 #define itkLBFGSOptimizerBasev4_h
20 
22 #include "vnl/algo/vnl_lbfgs.h"
23 #include "vnl/algo/vnl_lbfgsb.h"
24 #include "itkAutoPointer.h"
25 #include "ITKOptimizersv4Export.h"
26 
27 namespace itk
28 {
29 /* Necessary forward declaration see below for definition */
38 // Forward reference because of circular dependencies
39 template< typename TInternalVnlOptimizerType >
40 class ITK_TEMPLATE_EXPORT LBFGSOptimizerBaseHelperv4;
41 
73 template< typename TInternalVnlOptimizerType >
74 class ITK_TEMPLATE_EXPORT LBFGSOptimizerBasev4:
76 {
77 public:
83 
86 
87  typedef Superclass::MetricType MetricType;
88  typedef Superclass::ParametersType ParametersType;
89  typedef Superclass::ScalesType ScalesType;
90 
92  typedef Superclass::StopConditionReturnStringType StopConditionReturnStringType;
93 
95  typedef Superclass::StopConditionDescriptionType StopConditionDescriptionType;
96 
99 
101  InternalOptimizerType * GetOptimizer();
102 
104  virtual void StartOptimization(bool doOnlyInitialization = false) ITK_OVERRIDE;
105 
107  virtual void SetMetric(MetricType *metric) ITK_OVERRIDE;
108 
112  virtual void SetTrace(bool flag);
113 
114  itkGetConstMacro(Trace, bool);
115  itkBooleanMacro(Trace);
116 
118  virtual void SetMaximumNumberOfFunctionEvaluations(unsigned int n);
119 
120  itkGetConstMacro(MaximumNumberOfFunctionEvaluations, unsigned int);
121 
127  virtual void SetGradientConvergenceTolerance(double gtol);
128 
129  itkGetConstMacro(GradientConvergenceTolerance, double);
130 
132  virtual const StopConditionReturnStringType GetStopConditionDescription() const ITK_OVERRIDE;
133 
134 protected:
136  virtual ~LBFGSOptimizerBasev4() ITK_OVERRIDE;
137  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
138 
140 
141  bool m_OptimizerInitialized;
142 
144  InternalOptimizerAutoPointer m_VnlOptimizer;
145 
146  mutable std::ostringstream m_StopConditionDescription;
147 
148  bool m_Trace;
149  unsigned int m_MaximumNumberOfFunctionEvaluations;
150  double m_GradientConvergenceTolerance;
151  double m_InfinityNormOfProjectedGradient;
152  double m_CostFunctionConvergenceFactor;
153 
154  // give the helper access to member variables, to update iteration
155  // counts, etc.
156  friend class LBFGSOptimizerBaseHelperv4<TInternalVnlOptimizerType>;
158 
159 private:
160  ITK_DISALLOW_COPY_AND_ASSIGN(LBFGSOptimizerBasev4);
161 
162 };
163 } // end namespace itk
164 
165 #ifndef ITK_MANUAL_INSTANTIATION
166 #include "itkLBFGSOptimizerBasev4.hxx"
167 #endif
168 
169 #endif
Superclass::StopConditionDescriptionType StopConditionDescriptionType
LBFGSOptimizerBaseHelperv4< TInternalVnlOptimizerType > InternalOptimizerType
Light weight base class for most itk classes.
Superclass::ScalesType ScalesType
Wrapper helper around vnl optimizer.
Wrapper helper around vnl_lbfgsb.
Superclass::MetricType MetricType
This class is an Adaptor that allows to pass itk::ObjectToObjectMetricBase objects to vnl_optimizers ...
This is a base for the ITKv4 Optimization methods using the vnl library.
Superclass::ParametersType ParametersType
SmartPointer< const Self > ConstPointer
Superclass::StopConditionReturnStringType StopConditionReturnStringType
Implements an Automatic Pointer to an object.
Superclass::StopConditionReturnStringType StopConditionReturnStringType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Abstract base for vnl lbfgs algorithm optimizers in ITKv4 registration framework. ...
SingleValuedNonLinearVnlOptimizerv4 Superclass