ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkLBFGSBOptimizer.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 __itkLBFGSBOptimizer_h
19 #define __itkLBFGSBOptimizer_h
20 
21 #include "itkIntTypes.h"
23 
24 namespace itk
25 {
26 /* Necessary forward declaration see below for definition */
34 class ITK_EXPORT LBFGSBOptimizerHelper;
35 
62 class ITK_EXPORT LBFGSBOptimizer:
64 {
65 public:
71 
73  itkNewMacro(Self);
74 
77 
82 
87 
89  typedef vnl_vector< double > InternalBoundValueType;
90 
92  typedef vnl_vector< long > InternalBoundSelectionType;
93 
96 
98  void StartOptimization(void);
99 
101  virtual void SetCostFunction(SingleValuedCostFunction *costFunction);
102 
106  virtual void SetTrace(bool flag);
107 
108  itkGetMacro(Trace, bool);
109  itkBooleanMacro(Trace);
110 
112  virtual void SetLowerBound(const BoundValueType & value);
113  itkGetConstReferenceMacro(LowerBound,BoundValueType);
115 
117  virtual void SetUpperBound(const BoundValueType & value);
118  itkGetConstReferenceMacro(UpperBound,BoundValueType);
120 
127  virtual void SetBoundSelection(const BoundSelectionType & select);
128  itkGetConstReferenceMacro(BoundSelection,BoundSelectionType);
130 
137  virtual void SetCostFunctionConvergenceFactor(double);
138 
139  itkGetMacro(CostFunctionConvergenceFactor, double);
140 
145  virtual void SetProjectedGradientTolerance(double);
146 
147  itkGetMacro(ProjectedGradientTolerance, double);
148 
150  virtual void SetMaximumNumberOfIterations(unsigned int);
151 
152  itkGetMacro(MaximumNumberOfIterations, unsigned int);
153 
155  virtual void SetMaximumNumberOfEvaluations(unsigned int);
156 
157  itkGetMacro(MaximumNumberOfEvaluations, unsigned int);
158 
160  virtual void SetMaximumNumberOfCorrections(unsigned int);
161 
162  itkGetMacro(MaximumNumberOfCorrections, unsigned int);
163 
165  void SetScales(const ScalesType &)
166  {
167  itkExceptionMacro(<< "This optimizer does not support scales.");
168  }
169 
171  itkGetConstReferenceMacro(CurrentIteration, unsigned int);
172 
174  MeasureType GetValue() const;
175 
178  itkGetConstReferenceMacro(InfinityNormOfProjectedGradient, double);
179 
181  const std::string GetStopConditionDescription() const;
182 
183 protected:
184  LBFGSBOptimizer();
185  virtual ~LBFGSBOptimizer();
186  void PrintSelf(std::ostream & os, Indent indent) const;
187 
188  typedef Superclass::CostFunctionAdaptorType CostFunctionAdaptorType;
189 
190 private:
191  LBFGSBOptimizer(const Self &); //purposely not implemented
192  void operator=(const Self &); //purposely not implemented
193 
194  // give the helper access to member variables, to update iteration
195  // counts, etc.
196  friend class LBFGSBOptimizerHelper;
197 
198  bool m_Trace;
205  unsigned int m_CurrentIteration;
207 
212 };
213 } // end namespace itk
214 
215 #endif
216