Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkGradientDescentOptimizer_h
00018 #define __itkGradientDescentOptimizer_h
00019
00020 #include "itkSingleValuedNonLinearOptimizer.h"
00021 #include <string>
00022 namespace itk
00023 {
00024
00048 class ITK_EXPORT GradientDescentOptimizer :
00049 public SingleValuedNonLinearOptimizer
00050 {
00051 public:
00053 typedef GradientDescentOptimizer Self;
00054 typedef SingleValuedNonLinearOptimizer Superclass;
00055 typedef SmartPointer<Self> Pointer;
00056 typedef SmartPointer<const Self> ConstPointer;
00057
00059 itkNewMacro(Self);
00060
00062 itkTypeMacro( GradientDescentOptimizer, SingleValuedNonLinearOptimizer );
00063
00064
00066 typedef enum
00067 {
00068 MaximumNumberOfIterations,
00069 MetricError
00070 } StopConditionType;
00071
00073 itkGetConstReferenceMacro( Maximize, bool );
00074 itkSetMacro( Maximize, bool );
00075 itkBooleanMacro( Maximize );
00076 bool GetMinimize( ) const
00077 { return !m_Maximize; }
00078 void SetMinimize(bool v)
00079 { this->SetMaximize(!v); }
00080 void MinimizeOn()
00081 { this->MaximizeOff(); }
00082 void MinimizeOff()
00083 { this->MaximizeOn(); }
00085
00087 virtual void AdvanceOneStep( void );
00088
00090 void StartOptimization( void );
00091
00094 void ResumeOptimization( void );
00095
00098 void StopOptimization( void );
00099
00101 itkSetMacro( LearningRate, double );
00102
00104 itkGetConstReferenceMacro( LearningRate, double);
00105
00107 itkSetMacro( NumberOfIterations, unsigned long );
00108
00110 itkGetConstReferenceMacro( NumberOfIterations, unsigned long );
00111
00113 itkGetConstMacro( CurrentIteration, unsigned long );
00114
00116 itkGetConstReferenceMacro( Value, double );
00117
00119 itkGetConstReferenceMacro( StopCondition, StopConditionType );
00120 const std::string GetStopConditionDescription() const;
00122
00124 itkGetConstReferenceMacro( Gradient, DerivativeType );
00125
00126 protected:
00127 GradientDescentOptimizer();
00128 virtual ~GradientDescentOptimizer() {};
00129 void PrintSelf(std::ostream& os, Indent indent) const;
00130
00131
00132
00133 DerivativeType m_Gradient;
00134 bool m_Maximize;
00135 double m_LearningRate;
00136
00137 private:
00138 GradientDescentOptimizer(const Self&);
00139 void operator=(const Self&);
00140
00141 bool m_Stop;
00142 double m_Value;
00143 StopConditionType m_StopCondition;
00144 unsigned long m_NumberOfIterations;
00145 unsigned long m_CurrentIteration;
00146 OStringStream m_StopConditionDescription;
00147 };
00148
00149 }
00150
00151
00152 #endif
00153