00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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,
00052 ImageNotAvailable,
00053 SamplesNotAvailable,
00054 MaximumNumberOfIterations
00055 } StopConditionType;
00056
00058
itkSetMacro( Maximize,
bool );
00059
itkGetConstMacro( 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( NumberOfIterations,
unsigned long );
00085
itkSetMacro( GradientMagnitudeTolerance,
double );
00086
itkGetConstMacro( CurrentStepLength,
double);
00087
itkGetConstMacro( MaximumStepLength,
double );
00088
itkGetConstMacro( MinimumStepLength,
double );
00089
itkGetConstMacro( NumberOfIterations,
unsigned long );
00090
itkGetConstMacro( GradientMagnitudeTolerance,
double );
00091
itkGetConstMacro( CurrentIteration,
unsigned int );
00092
itkGetConstMacro( StopCondition, StopConditionType );
00093
itkGetConstMacro( Value, MeasureType );
00094
itkGetConstReferenceMacro( Gradient, DerivativeType );
00095
00096
00097
protected:
00098 RegularStepGradientDescentBaseOptimizer();
00099
virtual ~RegularStepGradientDescentBaseOptimizer() {};
00100
void PrintSelf(std::ostream& os, Indent indent)
const;
00101
00105
virtual void AdvanceOneStep(
void );
00106
00112
virtual void StepAlongGradient(
00113
double,
00114 const DerivativeType&)
00115 {
00116 ExceptionObject ex;
00117 ex.SetLocation(__FILE__);
00118 ex.SetDescription(
"This method MUST be overloaded in derived classes");
00119
throw ex;
00120 }
00121
00122
00123
private:
00124 RegularStepGradientDescentBaseOptimizer(
const Self&);
00125
void operator=(
const Self&);
00126
00127
protected:
00128 DerivativeType m_Gradient;
00129 DerivativeType m_PreviousGradient;
00130
00131 bool m_Stop;
00132 bool m_Maximize;
00133 MeasureType m_Value;
00134 double m_GradientMagnitudeTolerance;
00135 double m_MaximumStepLength;
00136 double m_MinimumStepLength;
00137 double m_CurrentStepLength;
00138 StopConditionType m_StopCondition;
00139 unsigned long m_NumberOfIterations;
00140 unsigned long m_CurrentIteration;
00141
00142
00143 };
00144
00145 }
00146
00147
00148
00149
#endif
00150
00151
00152