go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkGenericConjugateGradientOptimizer.h
Go to the documentation of this file.
1 /*======================================================================
2 
3  This file is part of the elastix software.
4 
5  Copyright (c) University Medical Center Utrecht. All rights reserved.
6  See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
7  details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notices for more information.
12 
13 ======================================================================*/
14 
15 
16 #ifndef __itkGenericConjugateGradientOptimizer_h
17 #define __itkGenericConjugateGradientOptimizer_h
18 
20 #include "itkLineSearchOptimizer.h"
21 #include <vector>
22 #include <map>
23 
24 namespace itk
25 {
39  {
40  public:
41 
44  typedef SmartPointer<Self> Pointer;
45  typedef SmartPointer<const Self> ConstPointer;
46 
47  itkNewMacro(Self);
50 
57 
60 
64  )( const DerivativeType & ,
65  const DerivativeType & ,
66  const ParametersType & );
67  typedef std::string BetaDefinitionType;
68  typedef std::map< BetaDefinitionType,
70 
71  typedef enum {
79 
80  virtual void StartOptimization(void);
81  virtual void ResumeOptimization(void);
82  virtual void StopOptimization(void);
83 
85  itkGetConstMacro(CurrentIteration, unsigned long);
86  itkGetConstMacro(CurrentValue, MeasureType);
87  itkGetConstReferenceMacro(CurrentGradient, DerivativeType);
88  itkGetConstMacro(InLineSearch, bool);
89  itkGetConstReferenceMacro(StopCondition, StopConditionType);
90  itkGetConstMacro(CurrentStepLength, double);
91 
93  itkSetObjectMacro(LineSearchOptimizer, LineSearchOptimizerType);
94  itkGetObjectMacro(LineSearchOptimizer, LineSearchOptimizerType);
95 
97  itkGetConstMacro(MaximumNumberOfIterations, unsigned long);
98  itkSetClampMacro(MaximumNumberOfIterations, unsigned long,
100 
107  itkGetConstMacro(GradientMagnitudeTolerance, double);
108  itkSetMacro(GradientMagnitudeTolerance, double)
109 
110 
117  itkGetConstMacro(ValueTolerance, double);
118  itkSetMacro(ValueTolerance, double);
119 
123  virtual void SetMaxNrOfItWithoutImprovement(unsigned long arg);
124  itkGetConstMacro(MaxNrOfItWithoutImprovement, unsigned long);
125 
127  virtual void SetBetaDefinition(const BetaDefinitionType & arg);
128  itkGetConstReferenceMacro(BetaDefinition, BetaDefinitionType);
129 
130  protected:
132  virtual ~GenericConjugateGradientOptimizer(){};
133 
134  void PrintSelf( std::ostream & os, Indent indent ) const;
135 
138  unsigned long m_CurrentIteration;
140  bool m_Stop;
142 
146 
149  itkSetMacro(InLineSearch, bool);
150 
156 
159 
163 
169  virtual void AddBetaDefinition(
170  const BetaDefinitionType & name,
171  ComputeBetaFunctionType function);
172 
183  virtual void ComputeSearchDirection(
184  const DerivativeType & previousGradient,
185  const DerivativeType & gradient,
186  ParametersType & searchDir);
187 
192  virtual void LineSearch(
193  const ParametersType searchDir,
194  double & step,
195  ParametersType & x,
196  MeasureType & f,
197  DerivativeType & g );
198 
203  virtual bool TestConvergence(bool firstLineSearchDone);
204 
206  virtual double ComputeBeta(
207  const DerivativeType & previousGradient,
208  const DerivativeType & gradient,
209  const ParametersType & previousSearchDir);
210 
214  double ComputeBetaSD(
215  const DerivativeType & previousGradient,
216  const DerivativeType & gradient,
217  const ParametersType & previousSearchDir);
219  double ComputeBetaFR(
220  const DerivativeType & previousGradient,
221  const DerivativeType & gradient,
222  const ParametersType & previousSearchDir);
224  double ComputeBetaPR(
225  const DerivativeType & previousGradient,
226  const DerivativeType & gradient,
227  const ParametersType & previousSearchDir);
229  double ComputeBetaDY(
230  const DerivativeType & previousGradient,
231  const DerivativeType & gradient,
232  const ParametersType & previousSearchDir);
234  double ComputeBetaHS(
235  const DerivativeType & previousGradient,
236  const DerivativeType & gradient,
237  const ParametersType & previousSearchDir);
239  double ComputeBetaDYHS(
240  const DerivativeType & previousGradient,
241  const DerivativeType & gradient,
242  const ParametersType & previousSearchDir);
243 
244 
245  private:
246  GenericConjugateGradientOptimizer(const Self&); //purposely not implemented
247  void operator=(const Self&); //purposely not implemented
248 
253 
255 
256  }; // end class GenericConjugateGradientOptimizer
257 
258 
259 } // end namespace itk
260 
261 
262 #endif //#ifndef __itkGenericConjugateGradientOptimizer_h
263 
double ComputeBetaSD(const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
virtual void SetBetaDefinition(const BetaDefinitionType &arg)
Superclass::ScaledCostFunctionType ScaledCostFunctionType
SmartPointer< Self > Pointer
double ComputeBetaDY(const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
virtual void AddBetaDefinition(const BetaDefinitionType &name, ComputeBetaFunctionType function)
double ComputeBetaDYHS(const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
double ComputeBetaPR(const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
double ComputeBetaHS(const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
int max(int a, int b)
virtual void SetMaxNrOfItWithoutImprovement(unsigned long arg)
virtual void ComputeSearchDirection(const DerivativeType &previousGradient, const DerivativeType &gradient, ParametersType &searchDir)
A base class for LineSearch optimizers.
void PrintSelf(std::ostream &os, Indent indent) const
virtual bool TestConvergence(bool firstLineSearchDone)
double ComputeBetaFR(const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
virtual void LineSearch(const ParametersType searchDir, double &step, ParametersType &x, MeasureType &f, DerivativeType &g)
virtual double ComputeBeta(const DerivativeType &previousGradient, const DerivativeType &gradient, const ParametersType &previousSearchDir)
double(Self::* ComputeBetaFunctionType)(const DerivativeType &, const DerivativeType &, const ParametersType &)
std::map< BetaDefinitionType, ComputeBetaFunctionType > BetaDefinitionMapType


Generated on 06-12-2013 for elastix by doxygen 1.8.5 elastix logo