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 #include "itkMersenneTwisterRandomVariateGenerator.h"
00006 
00007 
00008 namespace itk
00009 {
00010   
00027   class SPSAOptimizer
00028     : public SingleValuedNonLinearOptimizer
00029   {
00030    public:
00031     
00033     typedef SPSAOptimizer                       Self;
00034     typedef SingleValuedNonLinearOptimizer      Superclass;
00035     typedef SmartPointer<Self>                  Pointer;
00036     typedef SmartPointer<const Self>             ConstPointer;
00037 
00039     itkNewMacro( Self );
00040 
00042     itkTypeMacro( SPSAOptimizer, SingleValuedNonLinearOptimizer );
00043 
00045     typedef enum {
00046       Unknown,
00047       MaximumNumberOfIterations,
00048       BelowTolerance,
00049       MetricError  } StopConditionType;
00050 
00052     virtual void AdvanceOneStep( void );
00053 
00055     void StartOptimization( void );
00056 
00059     void ResumeOptimization( void );
00060 
00063     void StopOptimization( void );
00064 
00066     virtual MeasureType GetValue( void ) const;
00067 
00069     virtual MeasureType GetValue( const ParametersType & parameters ) const;
00070 
00084     virtual void GuessParameters(
00085                                  unsigned long numberOfGradientEstimates,
00086                                  double initialStepSize);
00087 
00089     itkGetConstMacro( CurrentIteration, unsigned long );
00090 
00092     itkGetConstMacro( StopCondition, StopConditionType );
00093 
00095     itkGetConstMacro( LearningRate, double);
00096 
00098     itkGetConstMacro( GradientMagnitude, double);
00099 
00101     itkGetConstReferenceMacro( Gradient, DerivativeType);
00102 
00104     itkSetMacro( a, double );
00105     itkGetConstMacro( a, double );
00107 
00109     itkSetMacro( c, double );
00110     itkGetConstMacro( c, double );
00112 
00114     itkSetMacro( A, double );
00115     itkGetConstMacro( A, double );
00117 
00119     itkSetMacro( Alpha, double );
00120     itkGetConstMacro( Alpha, double );
00122 
00124     itkSetMacro( Gamma, double );
00125     itkGetConstMacro( Gamma, double );
00127 
00129     itkGetConstMacro( Maximize, bool );
00130     itkSetMacro( Maximize, bool );
00131     itkBooleanMacro( Maximize );
00132     bool GetMinimize( ) const
00133     { return !m_Maximize; }
00134     void SetMinimize(bool v)
00135     { this->SetMaximize(!v); }
00136     void MinimizeOn()
00137     { this->MaximizeOff(); }
00138     void MinimizeOff()
00139     { this->MaximizeOn(); }
00141 
00147     itkSetMacro( NumberOfPerturbations, unsigned long );
00148     itkGetConstMacro( NumberOfPerturbations, unsigned long );
00150 
00151 
00163     itkGetConstMacro( StateOfConvergence, double );
00164 
00166     itkSetMacro( StateOfConvergenceDecayRate, double );
00167     itkGetConstMacro( StateOfConvergenceDecayRate, double );
00169 
00171     itkSetMacro( MinimumNumberOfIterations, unsigned long);
00172     itkGetConstMacro( MinimumNumberOfIterations, unsigned long);
00174 
00176     itkSetMacro( MaximumNumberOfIterations, unsigned long );
00177     itkGetConstMacro( MaximumNumberOfIterations, unsigned long );
00179 
00181     itkSetMacro(Tolerance, double);
00182     itkGetConstMacro(Tolerance, double);
00184 
00185    protected:
00186 
00187     SPSAOptimizer();
00188     virtual ~SPSAOptimizer() {};
00189 
00191     void PrintSelf( std::ostream& os, Indent indent ) const;
00192 
00194     DerivativeType               m_Gradient; 
00195     double                       m_LearningRate;
00196     DerivativeType               m_Delta;
00197     bool                         m_Stop;
00198     StopConditionType            m_StopCondition;
00199     double                       m_StateOfConvergence;
00200     unsigned long                m_CurrentIteration;
00201 
00203     Statistics::MersenneTwisterRandomVariateGenerator::Pointer m_Generator;
00204 
00206     virtual double Compute_a( unsigned long k ) const;
00207 
00212     virtual double Compute_c( unsigned long k ) const;
00213 
00215     virtual void GenerateDelta( const unsigned int spaceDimension );
00216 
00221     virtual void ComputeGradient(
00222                                  const ParametersType & parameters,
00223                                  DerivativeType & gradient);
00224 
00225    private:
00226 
00227     SPSAOptimizer( const Self& );    // purposely not implemented
00228     void operator=( const Self& );  // purposely not implemented
00229     
00231     unsigned long                 m_MinimumNumberOfIterations;
00232     unsigned long                 m_MaximumNumberOfIterations;
00233     double                        m_StateOfConvergenceDecayRate;
00234     double                        m_Tolerance;
00235     bool                          m_Maximize;
00236     double                        m_GradientMagnitude;
00237     unsigned long                 m_NumberOfPerturbations;
00238 
00240     double                        m_a;
00241     double                        m_c;
00242     double                        m_A;
00243     double                        m_Alpha;
00244     double                        m_Gamma;
00245 
00246   }; // end class SPSAOptimizer
00247 
00248 } // end namespace itk
00249 
00250 #endif // end #ifndef __itkSPSAOptimizer_h
00251 
00252 

Generated at Mon Mar 12 03:07:31 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000