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 );
00080
00082 itkSetMacro( MaximumIteration, unsigned int );
00083 itkGetConstReferenceMacro( MaximumIteration, unsigned int );
00084
00087 itkSetMacro( StepLength, double ) ;
00088 itkGetConstReferenceMacro( StepLength, double );
00089
00092 itkSetMacro( StepTolerance, double ) ;
00093 itkGetConstReferenceMacro( StepTolerance, double );
00094
00098 itkSetMacro( ValueTolerance, double ) ;
00099 itkGetConstReferenceMacro( ValueTolerance, double );
00100
00102 itkGetConstReferenceMacro( CurrentCost, MeasureType );
00103 MeasureType GetValue() const { return this->GetCurrentCost(); }
00104
00106 itkGetConstReferenceMacro( CurrentIteration, unsigned int) ;
00107
00109 void StartOptimization() ;
00110
00114 void StopOptimization()
00115 { m_Stop = true ; }
00116
00117 protected:
00118 PowellOptimizer() ;
00119 PowellOptimizer(const PowellOptimizer&) ;
00120 virtual ~PowellOptimizer() ;
00121 void PrintSelf(std::ostream& os, Indent indent) const;
00122
00123 itkSetMacro(CurrentCost, double);
00124
00127 void SetLine(const ParametersType & origin,
00128 const vnl_vector<double> & direction);
00129
00133 double GetLineValue(double x) const;
00134
00137 void SetCurrentLinePoint(double x, double fx);
00138
00141 void Swap(double *a, double *b) const;
00142
00145 void Shift(double *a, double *b, double *c, double d) const;
00146
00153 virtual void LineBracket(double *ax, double *bx, double *cx,
00154 double *fa, double *fb, double *fc);
00155
00161 virtual void BracketedLineOptimize(double ax, double bx, double cx,
00162 double fa, double fb, double fc,
00163 double * extX, double * extVal);
00164
00165 private:
00166
00167 unsigned int m_SpaceDimension;
00168
00170 unsigned int m_CurrentIteration ;
00171 unsigned int m_CurrentLineIteration ;
00172
00174 unsigned int m_MaximumIteration ;
00175 unsigned int m_MaximumLineIteration ;
00176
00178 bool m_Maximize;
00179
00181 double m_StepLength ;
00182 double m_StepTolerance ;
00183
00184 ParametersType m_LineOrigin;
00185 vnl_vector<double> m_LineDirection;
00186
00187 double m_ValueTolerance;
00188
00190 MeasureType m_CurrentCost;
00191
00196 bool m_Stop ;
00197
00198 } ;
00199
00200 }
00201
00202 #endif