ITK  4.2.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 private:
189  LBFGSBOptimizer(const Self &); //purposely not implemented
190  void operator=(const Self &); //purposely not implemented
191 
192  // give the helper access to member variables, to update iteration
193  // counts, etc.
194  friend class LBFGSBOptimizerHelper;
195 
196  bool m_Trace;
199  mutable std::ostringstream m_StopConditionDescription;
203 
209 
210  unsigned int m_CurrentIteration;
212 };
213 } // end namespace itk
214 
215 #endif
216