ITK  4.8.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 template< typename TInternalVnlOptimizerType >
39 class ITKOptimizersv4_EXPORT LBFGSOptimizerBaseHelperv4;
40 
72 template< typename TInternalVnlOptimizerType >
73 class ITKOptimizersv4_EXPORT LBFGSOptimizerBasev4:
75 {
76 public:
82 
85 
86  typedef Superclass::MetricType MetricType;
87  typedef Superclass::ParametersType ParametersType;
88  typedef Superclass::ScalesType ScalesType;
89 
91  typedef Superclass::StopConditionReturnStringType StopConditionReturnStringType;
92 
94  typedef Superclass::StopConditionDescriptionType StopConditionDescriptionType;
95 
98 
100  InternalOptimizerType * GetOptimizer();
101 
103  virtual void StartOptimization(bool doOnlyInitialization = false) ITK_OVERRIDE;
104 
106  virtual void SetMetric(MetricType *metric) ITK_OVERRIDE;
107 
111  virtual void SetTrace(bool flag);
112 
113  itkGetConstMacro(Trace, bool);
114  itkBooleanMacro(Trace);
115 
117  virtual void SetMaximumNumberOfFunctionEvaluations(unsigned int n);
118 
119  itkGetConstMacro(MaximumNumberOfFunctionEvaluations, unsigned int);
120 
126  virtual void SetGradientConvergenceTolerance(double gtol);
127 
128  itkGetConstMacro(GradientConvergenceTolerance, double);
129 
131  virtual const StopConditionReturnStringType GetStopConditionDescription() const ITK_OVERRIDE;
132 
133 protected:
135  virtual ~LBFGSOptimizerBasev4();
136  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
137 
139 
140  bool m_OptimizerInitialized;
141 
143  InternalOptimizerAutoPointer m_VnlOptimizer;
144 
145  mutable std::ostringstream m_StopConditionDescription;
146 
147  bool m_Trace;
148  unsigned int m_MaximumNumberOfFunctionEvaluations;
149  double m_GradientConvergenceTolerance;
150  double m_InfinityNormOfProjectedGradient;
151  double m_CostFunctionConvergenceFactor;
152 
153  // give the helper access to member variables, to update iteration
154  // counts, etc.
155  friend class LBFGSOptimizerBaseHelperv4<TInternalVnlOptimizerType>;
157 
158 private:
159  LBFGSOptimizerBasev4(const Self &); //purposely not implemented
160  void operator=(const Self &); //purposely not implemented
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