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

itkRegularStepGradientDescentBaseOptimizer.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkRegularStepGradientDescentBaseOptimizer.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007/08/14 17:08:31 $
00007   Version:   $Revision: 1.22 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkRegularStepGradientDescentBaseOptimizer_h
00018 #define __itkRegularStepGradientDescentBaseOptimizer_h
00019 
00020 #include "itkSingleValuedNonLinearOptimizer.h"
00021 
00022 namespace itk
00023 {
00024   
00030 class ITK_EXPORT RegularStepGradientDescentBaseOptimizer : 
00031     public SingleValuedNonLinearOptimizer
00032 {
00033 public:
00035   typedef RegularStepGradientDescentBaseOptimizer      Self;
00036   typedef SingleValuedNonLinearOptimizer               Superclass;
00037   typedef SmartPointer<Self>                           Pointer;
00038   typedef SmartPointer<const Self>                     ConstPointer;
00039 
00041   itkNewMacro(Self);
00042 
00044   itkTypeMacro( RegularStepGradientDescentBaseOptimizer, 
00045                 SingleValuedNonLinearOptimizer );
00046 
00047 
00049   typedef enum {
00050     GradientMagnitudeTolerance = 1,
00051     StepTooSmall = 2,
00052     ImageNotAvailable = 3,
00053     CostFunctionError = 4,
00054     MaximumNumberOfIterations = 5,
00055     Unknown = 6
00056   } StopConditionType;
00057 
00059   itkSetMacro( Maximize, bool );
00060   itkGetConstReferenceMacro( Maximize, bool );
00061   itkBooleanMacro( Maximize );
00062   bool GetMinimize( ) const
00063     { return !m_Maximize; }
00064   void SetMinimize(bool v)
00065     { this->SetMaximize(!v); }
00066   void    MinimizeOn(void) 
00067     { SetMaximize( false ); }
00068   void    MinimizeOff(void) 
00069     { SetMaximize( true ); }
00071 
00073   void    StartOptimization( void );
00074 
00077   void    ResumeOptimization( void );
00078 
00081   void    StopOptimization( void );
00082 
00084   itkSetMacro( MaximumStepLength, double );
00085   itkSetMacro( MinimumStepLength, double );
00086   itkSetMacro( RelaxationFactor, double );
00087   itkSetMacro( NumberOfIterations, unsigned long );
00088   itkSetMacro( GradientMagnitudeTolerance, double );
00089   itkGetConstReferenceMacro( CurrentStepLength, double);
00090   itkGetConstReferenceMacro( MaximumStepLength, double );
00091   itkGetConstReferenceMacro( MinimumStepLength, double );
00092   itkGetConstReferenceMacro( RelaxationFactor, double );
00093   itkGetConstReferenceMacro( NumberOfIterations, unsigned long );
00094   itkGetConstReferenceMacro( GradientMagnitudeTolerance, double );
00095   itkGetConstMacro( CurrentIteration, unsigned int );
00096   itkGetConstReferenceMacro( StopCondition, StopConditionType );
00097   itkGetConstReferenceMacro( Value, MeasureType );
00098   itkGetConstReferenceMacro( Gradient, DerivativeType );
00100 
00101   
00102 protected:
00103   RegularStepGradientDescentBaseOptimizer();
00104   virtual ~RegularStepGradientDescentBaseOptimizer() {};
00105   void PrintSelf(std::ostream& os, Indent indent) const;
00106 
00110   virtual void AdvanceOneStep( void );
00111 
00117   virtual void StepAlongGradient( 
00118     double,
00119     const DerivativeType&)
00120     {
00121     ExceptionObject ex;
00122     ex.SetLocation(__FILE__);
00123     ex.SetDescription("This method MUST be overloaded in derived classes");
00124     throw ex;
00125     }
00127 
00128 private:  
00129   RegularStepGradientDescentBaseOptimizer(const Self&); //purposely not implemented
00130   void operator=(const Self&);//purposely not implemented
00131 
00132 protected:
00133   DerivativeType                m_Gradient; 
00134   DerivativeType                m_PreviousGradient; 
00135 
00136   bool                          m_Stop;
00137   bool                          m_Maximize;
00138   MeasureType                   m_Value;
00139   double                        m_GradientMagnitudeTolerance;
00140   double                        m_MaximumStepLength;
00141   double                        m_MinimumStepLength;
00142   double                        m_CurrentStepLength;
00143   double                        m_RelaxationFactor;
00144   StopConditionType             m_StopCondition;
00145   unsigned long                 m_NumberOfIterations;
00146   unsigned long                 m_CurrentIteration;
00147 
00148 
00149 };
00150 
00151 } // end namespace itk
00152 
00153 #endif
00154 

Generated at Tue Jul 29 22:03:42 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000