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
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 MaximumNumberOfIterations,
00068 MetricError
00069 } StopConditionType;
00070
00072 itkGetMacro( Maximize, bool );
00073 itkSetMacro( Maximize, bool );
00074 itkBooleanMacro( Maximize );
00075 bool GetMinimize( ) const
00076 { return !m_Maximize; }
00077 void SetMinimize(bool v)
00078 { this->SetMaximize(!v); }
00079 void MinimizeOn()
00080 { this->MaximizeOff(); }
00081 void MinimizeOff()
00082 { this->MaximizeOn(); }
00083
00085 virtual void AdvanceOneStep( void );
00086
00088 void StartOptimization( void );
00089
00092 void ResumeOptimization( void );
00093
00096 void StopOptimization( void );
00097
00099 itkSetMacro( LearningRate, double );
00100
00102 itkGetConstMacro( LearningRate, double);
00103
00105 itkSetMacro( NumberOfIterations, unsigned long );
00106
00108 itkGetConstMacro( NumberOfIterations, unsigned long );
00109
00111 itkGetConstMacro( CurrentIteration, unsigned int );
00112
00114 itkGetConstMacro( Value, double );
00115
00117 itkGetConstMacro( StopCondition, StopConditionType );
00118
00119
00120 protected:
00121 GradientDescentOptimizer();
00122 virtual ~GradientDescentOptimizer() {};
00123 void PrintSelf(std::ostream& os, Indent indent) const;
00124
00125
00126
00127 DerivativeType m_Gradient;
00128 bool m_Maximize;
00129 double m_LearningRate;
00130
00131 private:
00132 GradientDescentOptimizer(const Self&);
00133 void operator=(const Self&);
00134
00135 bool m_Stop;
00136 double m_Value;
00137 StopConditionType m_StopCondition;
00138 unsigned long m_NumberOfIterations;
00139 unsigned long m_CurrentIteration;
00140
00141
00142
00143 };
00144
00145 }
00146
00147
00148 #endif
00149
00150
00151