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
00060 class ITK_EXPORT PowellOptimizer:
00061 public SingleValuedNonLinearOptimizer
00062 {
00063 public:
00065 typedef PowellOptimizer Self;
00066 typedef SingleValuedNonLinearOptimizer Superclass;
00067 typedef SmartPointer<Self> Pointer;
00068 typedef SmartPointer<const Self> ConstPointer;
00069
00070 typedef SingleValuedNonLinearOptimizer::ParametersType
00071 ParametersType;
00072
00074 itkNewMacro(Self);
00075
00077 itkTypeMacro(PowellOptimizer, SingleValuedNonLinearOptimizer );
00078
00080 typedef SingleValuedCostFunction CostFunctionType;
00081 typedef CostFunctionType::Pointer CostFunctionPointer;
00082
00084 itkSetMacro( Maximize, bool );
00085 itkGetConstReferenceMacro( Maximize, bool );
00087
00089 itkSetMacro( MaximumIteration, unsigned int );
00090 itkGetConstReferenceMacro( MaximumIteration, unsigned int );
00092
00094 itkSetMacro(MaximumLineIteration, unsigned int);
00095 itkGetConstMacro(MaximumLineIteration, unsigned int);
00097
00100 itkSetMacro( StepLength, double );
00101 itkGetConstReferenceMacro( StepLength, double );
00103
00106 itkSetMacro( StepTolerance, double );
00107 itkGetConstReferenceMacro( StepTolerance, double );
00109
00113 itkSetMacro( ValueTolerance, double );
00114 itkGetConstReferenceMacro( ValueTolerance, double );
00116
00118 itkGetConstReferenceMacro( CurrentCost, MeasureType );
00119 MeasureType GetValue() const { return this->GetCurrentCost(); }
00121
00123 itkGetConstReferenceMacro( CurrentIteration, unsigned int);
00124
00126 itkGetConstReferenceMacro( CurrentLineIteration, unsigned int);
00127
00129 void StartOptimization();
00130
00134 void StopOptimization()
00135 { m_Stop = true; }
00136
00137 protected:
00138 PowellOptimizer();
00139 PowellOptimizer(const PowellOptimizer&);
00140 virtual ~PowellOptimizer();
00141 void PrintSelf(std::ostream& os, Indent indent) const;
00142
00143 itkSetMacro(CurrentCost, double);
00144
00147 void SetLine(const ParametersType & origin,
00148 const vnl_vector<double> & direction);
00149
00153 double GetLineValue(double x) const;
00154
00157 void SetCurrentLinePoint(double x, double fx);
00158
00161 void Swap(double *a, double *b) const;
00162
00165 void Shift(double *a, double *b, double *c, double d) const;
00166
00176 virtual void LineBracket(double *ax, double *bx, double *cx,
00177 double *fa, double *fb, double *fc);
00178
00184 virtual void BracketedLineOptimize(double ax, double bx, double cx,
00185 double fa, double fb, double fc,
00186 double * extX, double * extVal);
00187
00188 itkGetMacro(SpaceDimension, unsigned int);
00189 itkSetMacro(SpaceDimension, unsigned int);
00190
00191 itkSetMacro(CurrentIteration, unsigned int);
00192
00193 itkGetMacro(Stop, bool);
00194 itkSetMacro(Stop, bool);
00195
00196 private:
00197 unsigned int m_SpaceDimension;
00198
00200 unsigned int m_CurrentIteration;
00201 unsigned int m_CurrentLineIteration;
00202
00204 unsigned int m_MaximumIteration;
00205 unsigned int m_MaximumLineIteration;
00206
00208 bool m_Maximize;
00209
00211 double m_StepLength;
00212 double m_StepTolerance;
00213
00214 ParametersType m_LineOrigin;
00215 vnl_vector<double> m_LineDirection;
00216
00217 double m_ValueTolerance;
00218
00220 MeasureType m_CurrentCost;
00221
00226 bool m_Stop;
00227
00228 };
00229
00230 }
00231
00232 #endif
00233