15 #ifndef itkUCLPowellOptimizer_h
16 #define itkUCLPowellOptimizer_h
20 #include <NifTKConfigure.h>
23 #include <itkVector.h>
24 #include <itkMatrix.h>
25 #include <itkSingleValuedNonLinearOptimizer.h>
65 public SingleValuedNonLinearOptimizer
74 typedef SingleValuedNonLinearOptimizer::ParametersType
88 itkSetMacro( Maximize,
bool );
89 itkGetConstReferenceMacro( Maximize,
bool );
92 itkSetMacro( MaximumIteration,
unsigned int );
93 itkGetConstReferenceMacro( MaximumIteration,
unsigned int );
96 itkSetMacro(MaximumLineIteration,
unsigned int);
97 itkGetConstMacro(MaximumLineIteration,
unsigned int);
101 itkSetMacro( StepLength,
double );
102 itkGetConstReferenceMacro( StepLength,
double );
106 itkSetMacro( StepTolerance,
double );
107 itkGetConstReferenceMacro( StepTolerance,
double );
112 itkSetMacro( ValueTolerance,
double );
113 itkGetConstReferenceMacro( ValueTolerance,
double );
116 itkGetConstReferenceMacro( CurrentCost, MeasureType );
117 MeasureType
GetValue()
const {
return this->GetCurrentCost(); }
120 itkGetConstReferenceMacro( CurrentIteration,
unsigned int);
123 itkGetConstReferenceMacro( CurrentLineIteration,
unsigned int);
126 void StartOptimization()
override;
134 itkGetMacro(CatchGetValueException,
bool);
135 itkSetMacro(CatchGetValueException,
bool);
137 itkGetMacro(MetricWorstPossibleValue,
double);
138 itkSetMacro(MetricWorstPossibleValue,
double);
140 itkGetMacro(ParameterTolerance,
double);
141 itkSetMacro(ParameterTolerance,
double);
143 const std::string GetStopConditionDescription()
const override;
149 void PrintSelf(std::ostream& os, Indent indent)
const override;
151 itkSetMacro(CurrentCost,
double);
156 const vnl_vector<double> & direction)
158 for(
unsigned int i=0; i<m_SpaceDimension; i++)
160 m_LineOrigin[i] = origin[i];
163 m_LineDirection[i] = direction[i];
173 return this->GetLineValue(x, tempCoord);
176 double GetLineValue(
double x, ParametersType & tempCoord)
const;
182 for(
unsigned int i=0; i<m_SpaceDimension; i++)
184 this->m_CurrentPosition[i] = this->m_LineOrigin[i] + x * this->m_LineDirection[i];
188 this->SetCurrentCost(-fx);
192 this->SetCurrentCost(fx);
199 inline void Swap(
double *
a,
double *
b)
const
209 inline void Shift(
double *
a,
double *
b,
double *
c,
double d)
const
225 inline void LineBracket(
double * x1,
double * x2,
double * x3,
double * f1,
double * f2,
double * f3)
228 this->LineBracket( x1, x2, x3, f1, f2, f3, tempCoord);
231 virtual void LineBracket(
double *ax,
double *bx,
double *cx,
232 double *fa,
double *fb,
double *fc,
233 ParametersType & tempCoord);
241 double fa,
double functionValueOfb,
double fc,
242 double * extX,
double * extVal)
245 this->BracketedLineOptimize( ax, bx, cx, fa, functionValueOfb, fc, extX, extVal, tempCoord);
248 virtual void BracketedLineOptimize(
double ax,
double bx,
double cx,
249 double fa,
double fb,
double fc,
250 double * extX,
double * extVal,
251 ParametersType & tempCoord);
253 itkGetMacro(SpaceDimension,
unsigned int);
256 this->m_SpaceDimension = dim;
257 this->m_LineDirection.set_size( dim );
258 this->m_LineOrigin.set_size( dim );
259 this->m_CurrentPosition.set_size( dim );
263 itkSetMacro(CurrentIteration,
unsigned int);
265 itkGetMacro(Stop,
bool);
266 itkSetMacro(Stop,
bool);
273 for(
unsigned int i=0; i<m_SpaceDimension; i++)
275 lastP[i] = lastP[i]/this->GetScales()[i];
276 p[i] = p[i]/this->GetScales()[i];
282 return dynamic_cast<SimilarityMeasureType*
>(this->m_CostFunction.GetPointer())->GetMeasureOfParameterChange(lastP, p);
286 unsigned int m_SpaceDimension;
289 unsigned int m_CurrentIteration;
290 unsigned int m_CurrentLineIteration;
293 unsigned int m_MaximumIteration;
294 unsigned int m_MaximumLineIteration;
296 bool m_CatchGetValueException;
297 double m_MetricWorstPossibleValue;
304 double m_StepTolerance;
306 ParametersType m_LineOrigin;
307 vnl_vector<double> m_LineDirection;
309 double m_ValueTolerance;
312 double m_ParameterTolerance;
315 MeasureType m_CurrentCost;
323 std::ostringstream m_StopConditionDescription;
double GetLineValue(double x) const
Definition: itkUCLPowellOptimizer.h:170
Abstract base class, implementing TemplateMethod [2] for similarity measures.
Definition: itkSimilarityMeasure.h:56
void SetCurrentLinePoint(double x, double fx)
Definition: itkUCLPowellOptimizer.h:180
const GLfloat * c
Definition: glew.h:14144
void LineBracket(double *x1, double *x2, double *x3, double *f1, double *f2, double *f3)
Definition: itkUCLPowellOptimizer.h:225
SmartPointer< const Self > ConstPointer
Definition: itkUCLPowellOptimizer.h:72
Definition: niftkITKAffineResampleImage.cxx:74
SingleValuedCostFunction CostFunctionType
Definition: itkUCLPowellOptimizer.h:81
void SetSpaceDimension(unsigned int dim)
Definition: itkUCLPowellOptimizer.h:254
SmartPointer< Self > Pointer
Definition: itkUCLPowellOptimizer.h:71
double GetMeasureOfParameterChange(ParametersType lastP, ParametersType p)
Definition: itkUCLPowellOptimizer.h:271
void Swap(double *a, double *b) const
Definition: itkUCLPowellOptimizer.h:199
GLdouble GLdouble GLdouble b
Definition: glew.h:7885
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:8272
GLfloat GLfloat p
Definition: glew.h:14169
SingleValuedNonLinearOptimizer::ParametersType ParametersType
Definition: itkUCLPowellOptimizer.h:75
void Shift(double *a, double *b, double *c, double d) const
Definition: itkUCLPowellOptimizer.h:209
void SetLine(const ParametersType &origin, const vnl_vector< double > &direction)
Definition: itkUCLPowellOptimizer.h:155
GLint GLint GLint GLint GLint x
Definition: glew.h:1236
void StopOptimization()
Definition: itkUCLPowellOptimizer.h:131
virtual void BracketedLineOptimize(double ax, double bx, double cx, double fa, double functionValueOfb, double fc, double *extX, double *extVal)
Definition: itkUCLPowellOptimizer.h:240
UCLPowellOptimizer Self
Definition: itkUCLPowellOptimizer.h:69
Simultaneous itk::Image and itk::Array (and hence vnl_vector) class.
MeasureType GetValue() const
Definition: itkUCLPowellOptimizer.h:117
SingleValuedNonLinearOptimizer Superclass
Definition: itkUCLPowellOptimizer.h:70
itk::Image< float, 3 > FloatImageType
Definition: niftkKNDoubleWindowBSI.cxx:56
Definition: itkUCLPowellOptimizer.h:64
GLsizei const GLcharARB ** string
Definition: glew.h:5194
CostFunctionType::Pointer CostFunctionPointer
Definition: itkUCLPowellOptimizer.h:85