00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkPowellOptimizer_h
00018 #define __itkPowellOptimizer_h
00019
00020 #include <itkVector.h>
00021 #include <itkMatrix.h>
00022 #include <itkSingleValuedNonLinearOptimizer.h>
00023
00024 namespace itk
00025 {
00026
00054 class ITK_EXPORT PowellOptimizer:
00055 public SingleValuedNonLinearOptimizer
00056 {
00057 public:
00059 typedef PowellOptimizer Self ;
00060 typedef SingleValuedNonLinearOptimizer Superclass;
00061 typedef SmartPointer<Self> Pointer;
00062 typedef SmartPointer<const Self> ConstPointer;
00063
00064 typedef SingleValuedNonLinearOptimizer::ParametersType
00065 ParametersType;
00066
00068 itkNewMacro(Self);
00069
00071 itkTypeMacro(PowellOptimizer, SingleValuedNonLinearOptimizer );
00072
00074 typedef SingleValuedCostFunction CostFunctionType;
00075 typedef CostFunctionType::Pointer CostFunctionPointer;
00076
00078 itkSetMacro( Maximize, bool );
00079 itkGetConstReferenceMacro( Maximize, bool );
00081
00083 itkSetMacro( MaximumIteration, unsigned int );
00084 itkGetConstReferenceMacro( MaximumIteration, unsigned int );
00086
00088 itkSetMacro(MaximumLineIteration, unsigned int);
00089 itkGetConstMacro(MaximumLineIteration, unsigned int);
00091
00094 itkSetMacro( StepLength, double ) ;
00095 itkGetConstReferenceMacro( StepLength, double );
00097
00100 itkSetMacro( StepTolerance, double ) ;
00101 itkGetConstReferenceMacro( StepTolerance, double );
00103
00107 itkSetMacro( ValueTolerance, double ) ;
00108 itkGetConstReferenceMacro( ValueTolerance, double );
00110
00112 itkGetConstReferenceMacro( CurrentCost, MeasureType );
00113 MeasureType GetValue() const { return this->GetCurrentCost(); }
00115
00117 itkGetConstReferenceMacro( CurrentIteration, unsigned int);
00118
00120 itkGetConstReferenceMacro( CurrentLineIteration, unsigned int);
00121
00123 void StartOptimization() ;
00124
00128 void StopOptimization()
00129 { m_Stop = true ; }
00130
00131 protected:
00132 PowellOptimizer() ;
00133 PowellOptimizer(const PowellOptimizer&) ;
00134 virtual ~PowellOptimizer() ;
00135 void PrintSelf(std::ostream& os, Indent indent) const;
00136
00137 itkSetMacro(CurrentCost, double);
00138
00141 void SetLine(const ParametersType & origin,
00142 const vnl_vector<double> & direction);
00143
00147 double GetLineValue(double x) const;
00148
00151 void SetCurrentLinePoint(double x, double fx);
00152
00155 void Swap(double *a, double *b) const;
00156
00159 void Shift(double *a, double *b, double *c, double d) const;
00160
00167 virtual void LineBracket(double *ax, double *bx, double *cx,
00168 double *fa, double *fb, double *fc);
00169
00175 virtual void BracketedLineOptimize(double ax, double bx, double cx,
00176 double fa, double fb, double fc,
00177 double * extX, double * extVal);
00178
00179 itkGetMacro(SpaceDimension, unsigned int);
00180 itkSetMacro(SpaceDimension, unsigned int);
00181
00182 itkSetMacro(CurrentIteration, unsigned int);
00183
00184 itkGetMacro(Stop, bool);
00185 itkSetMacro(Stop, bool);
00186
00187 private:
00188
00189 unsigned int m_SpaceDimension;
00190
00192 unsigned int m_CurrentIteration ;
00193 unsigned int m_CurrentLineIteration ;
00194
00196 unsigned int m_MaximumIteration ;
00197 unsigned int m_MaximumLineIteration ;
00198
00200 bool m_Maximize;
00201
00203 double m_StepLength ;
00204 double m_StepTolerance ;
00205
00206 ParametersType m_LineOrigin;
00207 vnl_vector<double> m_LineDirection;
00208
00209 double m_ValueTolerance;
00210
00212 MeasureType m_CurrentCost;
00213
00218 bool m_Stop ;
00219
00220 } ;
00221
00222 }
00223
00224 #endif
00225