ITK  4.3.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 {
33 class ITK_EXPORT LBFGSBOptimizerHelper;
34 
61 class ITK_EXPORT LBFGSBOptimizer:
63 {
64 public:
70 
72  itkNewMacro(Self);
73 
76 
81 
86 
89 
92 
95 
97  void StartOptimization(void);
98 
100  virtual void SetCostFunction(SingleValuedCostFunction *costFunction);
101 
105  virtual void SetTrace(bool flag);
106 
107  itkGetMacro(Trace, bool);
108  itkBooleanMacro(Trace);
109 
111  virtual void SetLowerBound(const BoundValueType & value);
112 
113  virtual const BoundValueType & GetLowerBound();
114 
116  virtual void SetUpperBound(const BoundValueType & value);
117 
118  virtual const BoundValueType & GetUpperBound();
119 
126  virtual void SetBoundSelection(const BoundSelectionType & select);
127 
128  virtual const BoundSelectionType & GetBoundSelection();
129 
136  virtual void SetCostFunctionConvergenceFactor(double);
137 
138  itkGetMacro(CostFunctionConvergenceFactor, double);
139 
144  virtual void SetProjectedGradientTolerance(double);
145 
146  itkGetMacro(ProjectedGradientTolerance, double);
147 
149  virtual void SetMaximumNumberOfIterations(unsigned int);
150 
151  itkGetMacro(MaximumNumberOfIterations, unsigned int);
152 
154  virtual void SetMaximumNumberOfEvaluations(unsigned int);
155 
156  itkGetMacro(MaximumNumberOfEvaluations, unsigned int);
157 
159  virtual void SetMaximumNumberOfCorrections(unsigned int);
160 
161  itkGetMacro(MaximumNumberOfCorrections, unsigned int);
162 
164  void SetScales(const ScalesType &)
165  {
166  itkExceptionMacro(<< "This optimizer does not support scales.");
167  }
168 
170  itkGetConstReferenceMacro(CurrentIteration, unsigned int);
171 
173  MeasureType GetValue() const;
174 
177  itkGetConstReferenceMacro(InfinityNormOfProjectedGradient, double);
178 
180  const std::string GetStopConditionDescription() const;
181 
182 protected:
183  LBFGSBOptimizer();
184  virtual ~LBFGSBOptimizer();
185  void PrintSelf(std::ostream & os, Indent indent) const;
186 
187  typedef Superclass::CostFunctionAdaptorType CostFunctionAdaptorType;
188 
189 private:
190  LBFGSBOptimizer(const Self &); //purposely not implemented
191  void operator=(const Self &); //purposely not implemented
192 
193  // give the helper access to member variables, to update iteration
194  // counts, etc.
195  friend class LBFGSBOptimizerHelper;
196 
197  bool m_Trace;
200  mutable std::ostringstream m_StopConditionDescription;
204 
210 
211  unsigned int m_CurrentIteration;
213 };
214 } // end namespace itk
215 
216 #endif
217