Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkSPSAOptimizer.h

Go to the documentation of this file.
00001 #ifndef __itkSPSAOptimizer_h
00002 #define __itkSPSAOptimizer_h
00003 
00004 #include "itkSingleValuedNonLinearOptimizer.h"
00005 
00006 
00007 namespace itk
00008 {
00009   
00026   class SPSAOptimizer
00027     : public SingleValuedNonLinearOptimizer
00028   {
00029    public:
00030     
00032     typedef SPSAOptimizer                       Self;
00033     typedef SingleValuedNonLinearOptimizer      Superclass;
00034     typedef SmartPointer<Self>                  Pointer;
00035     typedef SmartPointer<const Self>             ConstPointer;
00036     
00038     itkNewMacro( Self );
00039     
00041     itkTypeMacro( SPSAOptimizer, SingleValuedNonLinearOptimizer );
00042     
00044     typedef enum {
00045       Unknown,
00046       MaximumNumberOfIterations,
00047       BelowTolerance,
00048       MetricError  } StopConditionType;
00049     
00051     virtual void AdvanceOneStep( void );
00052     
00054     void StartOptimization( void );
00055     
00058     void ResumeOptimization( void );
00059     
00062     void StopOptimization( void );
00063     
00065     virtual MeasureType GetValue( void ) const;
00066 
00068     virtual MeasureType GetValue( const ParametersType & parameters ) const;
00069 
00083     virtual void GuessParameters(
00084                                  unsigned long numberOfGradientEstimates,
00085                                  double initialStepSize);
00086 
00088     itkGetConstMacro( CurrentIteration, unsigned long );
00089     
00091     itkGetConstMacro( StopCondition, StopConditionType );
00092 
00094     itkGetConstMacro( LearningRate, double);
00095 
00097     itkGetConstMacro( GradientMagnitude, double);
00098     
00100     itkGetConstReferenceMacro( Gradient, DerivativeType);
00101 
00103     itkSetMacro( a, double );
00104     itkGetConstMacro( a, double );
00105     
00107     itkSetMacro( c, double );
00108     itkGetConstMacro( c, double );
00109     
00111     itkSetMacro( A, double );
00112     itkGetConstMacro( A, double );
00113     
00115     itkSetMacro( Alpha, double );
00116     itkGetConstMacro( Alpha, double );
00117     
00119     itkSetMacro( Gamma, double );
00120     itkGetConstMacro( Gamma, double );
00121 
00123     itkGetConstMacro( Maximize, bool );
00124     itkSetMacro( Maximize, bool );
00125     itkBooleanMacro( Maximize );
00126     bool GetMinimize( ) const
00127     { return !m_Maximize; }
00128     void SetMinimize(bool v)
00129     { this->SetMaximize(!v); }
00130     void MinimizeOn()
00131     { this->MaximizeOff(); }
00132     void MinimizeOff()
00133     { this->MaximizeOn(); }
00134 
00140     itkSetMacro( NumberOfPerturbations, unsigned long );
00141     itkGetConstMacro( NumberOfPerturbations, unsigned long );
00142 
00143 
00155     itkGetConstMacro( StateOfConvergence, double );
00156 
00158     itkSetMacro( StateOfConvergenceDecayRate, double );
00159     itkGetConstMacro( StateOfConvergenceDecayRate, double );
00160 
00162     itkSetMacro( MinimumNumberOfIterations, unsigned long);
00163     itkGetConstMacro( MinimumNumberOfIterations, unsigned long);
00164     
00166     itkSetMacro( MaximumNumberOfIterations, unsigned long );
00167     itkGetConstMacro( MaximumNumberOfIterations, unsigned long );
00168     
00170     itkSetMacro(Tolerance, double);
00171     itkGetConstMacro(Tolerance, double);
00172     
00173    protected:
00174 
00175     SPSAOptimizer();
00176     virtual ~SPSAOptimizer() {};
00177 
00179     void PrintSelf( std::ostream& os, Indent indent ) const;
00180     
00182     DerivativeType               m_Gradient; 
00183     double                       m_LearningRate;
00184     DerivativeType               m_Delta;
00185     bool                         m_Stop;
00186     StopConditionType            m_StopCondition;
00187     double                       m_StateOfConvergence;
00188     unsigned long                m_CurrentIteration;
00189     
00191     virtual double Compute_a( unsigned long k ) const;
00192 
00197     virtual double Compute_c( unsigned long k ) const;
00198     
00200     virtual void GenerateDelta( const unsigned int spaceDimension );
00201 
00206     virtual void ComputeGradient(
00207                                  const ParametersType & parameters,
00208                                  DerivativeType & gradient);
00209     
00210    private:
00211 
00212     SPSAOptimizer( const Self& );    // purposely not implemented
00213     void operator=( const Self& );  // purposely not implemented
00214     
00216     unsigned long                 m_MinimumNumberOfIterations;
00217     unsigned long                 m_MaximumNumberOfIterations;
00218     double                        m_StateOfConvergenceDecayRate;
00219     double                        m_Tolerance;
00220     bool                          m_Maximize;
00221     double                        m_GradientMagnitude;
00222     unsigned long                 m_NumberOfPerturbations;
00223     
00225     double                        m_a;
00226     double                        m_c;
00227     double                        m_A;
00228     double                        m_Alpha;
00229     double                        m_Gamma;
00230     
00231   }; // end class SPSAOptimizer
00232 
00233 } // end namespace itk
00234 
00235 #endif // end #ifndef __itkSPSAOptimizer_h
00236 

Generated at Thu May 25 00:06:51 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000