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: 2005/11/28 21:38:19 $
00007   Version:   $Revision: 1.18 $
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   } StopConditionType;
00056 
00058   itkSetMacro( Maximize, bool );
00059   itkGetConstReferenceMacro( Maximize, bool );
00060   itkBooleanMacro( Maximize );
00061   bool GetMinimize( ) const
00062   { return !m_Maximize; }
00063   void SetMinimize(bool v)
00064   { this->SetMaximize(!v); }
00065   void    MinimizeOn(void) 
00066   { SetMaximize( false ); }
00067   void    MinimizeOff(void) 
00068   { SetMaximize( true ); }
00069 
00071   void    StartOptimization( void );
00072 
00075   void    ResumeOptimization( void );
00076 
00079   void    StopOptimization( void );
00080 
00082   itkSetMacro( MaximumStepLength, double );
00083   itkSetMacro( MinimumStepLength, double );
00084   itkSetMacro( RelaxationFactor, double );
00085   itkSetMacro( NumberOfIterations, unsigned long );
00086   itkSetMacro( GradientMagnitudeTolerance, double );
00087   itkGetConstReferenceMacro( CurrentStepLength, double);
00088   itkGetConstReferenceMacro( MaximumStepLength, double );
00089   itkGetConstReferenceMacro( MinimumStepLength, double );
00090   itkGetConstReferenceMacro( RelaxationFactor, double );
00091   itkGetConstReferenceMacro( NumberOfIterations, unsigned long );
00092   itkGetConstReferenceMacro( GradientMagnitudeTolerance, double );
00093   itkGetConstMacro( CurrentIteration, unsigned int );
00094   itkGetConstReferenceMacro( StopCondition, StopConditionType );
00095   itkGetConstReferenceMacro( Value, MeasureType );
00096   itkGetConstReferenceMacro( Gradient, DerivativeType );
00097   
00098   
00099 protected:
00100   RegularStepGradientDescentBaseOptimizer();
00101   virtual ~RegularStepGradientDescentBaseOptimizer() {};
00102   void PrintSelf(std::ostream& os, Indent indent) const;
00103 
00107   virtual void AdvanceOneStep( void );
00108 
00114   virtual void StepAlongGradient( 
00115     double,
00116     const DerivativeType&)
00117   {
00118     ExceptionObject ex;
00119     ex.SetLocation(__FILE__);
00120     ex.SetDescription("This method MUST be overloaded in derived classes");
00121     throw ex;
00122   }
00123 
00124 
00125 private:  
00126   RegularStepGradientDescentBaseOptimizer(const Self&); //purposely not implemented
00127   void operator=(const Self&);//purposely not implemented
00128 
00129 protected:
00130   DerivativeType                m_Gradient; 
00131   DerivativeType                m_PreviousGradient; 
00132 
00133   bool                          m_Stop;
00134   bool                          m_Maximize;
00135   MeasureType                   m_Value;
00136   double                        m_GradientMagnitudeTolerance;
00137   double                        m_MaximumStepLength;
00138   double                        m_MinimumStepLength;
00139   double                        m_CurrentStepLength;
00140   double                        m_RelaxationFactor;
00141   StopConditionType             m_StopCondition;
00142   unsigned long                 m_NumberOfIterations;
00143   unsigned long                 m_CurrentIteration;
00144 
00145 
00146 };
00147 
00148 } // end namespace itk
00149 
00150 
00151 
00152 #endif
00153 
00154 
00155 

Generated at Wed May 24 23:58:22 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000