Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __itkMoreThuenteLineSearchOptimizer_h
00016 #define __itkMoreThuenteLineSearchOptimizer_h
00017
00018 #include "itkLineSearchOptimizer.h"
00019
00020 namespace itk
00021 {
00067 class MoreThuenteLineSearchOptimizer :
00068 public LineSearchOptimizer
00069 {
00070 public:
00071 typedef MoreThuenteLineSearchOptimizer Self;
00072 typedef LineSearchOptimizer Superclass;
00073 typedef SmartPointer<Self> Pointer;
00074 typedef SmartPointer<const Self> ConstPointer;
00075
00076 itkNewMacro(Self);
00077 itkTypeMacro(MoreThuenteLineSearchOptimizer, LineSearchOptimizer);
00078
00079 typedef Superclass::MeasureType MeasureType;
00080 typedef Superclass::ParametersType ParametersType;
00081 typedef Superclass::DerivativeType DerivativeType;
00082 typedef Superclass::CostFunctionType CostFunctionType;
00083
00084 typedef enum {
00085 StrongWolfeConditionsSatisfied,
00086 MetricError,
00087 MaximumNumberOfIterations,
00088 StepTooSmall,
00089 StepTooLarge,
00090 IntervalTooSmall,
00091 RoundingError,
00092 AscentSearchDirection,
00093 Unknown } StopConditionType;
00094
00095 virtual void StartOptimization(void);
00096 virtual void StopOptimization(void);
00097
00100 virtual void SetInitialDerivative(const DerivativeType & derivative);
00101 virtual void SetInitialValue(MeasureType value);
00102
00105 virtual void GetCurrentValueAndDerivative(
00106 MeasureType & value, DerivativeType & derivative) const;
00107 virtual void GetCurrentDerivative(DerivativeType & derivative) const;
00108 virtual MeasureType GetCurrentValue(void) const;
00109 virtual const double GetCurrentDirectionalDerivative(void) const;
00110
00112 itkGetConstMacro(CurrentIteration, unsigned long);
00113 itkGetConstReferenceMacro(StopCondition, StopConditionType);
00114 itkGetConstMacro(SufficientDecreaseConditionSatisfied, bool);
00115 itkGetConstMacro(CurvatureConditionSatisfied, bool);
00116
00118 itkGetConstMacro(MaximumNumberOfIterations, unsigned long);
00119 itkSetClampMacro(MaximumNumberOfIterations, unsigned long,
00120 1, NumericTraits<unsigned long>::max());
00121
00131 itkSetClampMacro(ValueTolerance, double, 0.0, NumericTraits<double>::max() );
00132 itkGetConstMacro(ValueTolerance, double);
00133
00143 itkSetClampMacro(GradientTolerance, double, 0.0, NumericTraits<double>::max() );
00144 itkGetConstMacro(GradientTolerance, double);
00145
00154 itkSetClampMacro(IntervalTolerance, double, 0.0, NumericTraits<double>::max() );
00155 itkGetConstMacro(IntervalTolerance, double);
00156
00157
00158 protected:
00159 MoreThuenteLineSearchOptimizer();
00160 virtual ~MoreThuenteLineSearchOptimizer() {};
00161
00162 void PrintSelf(std::ostream& os, Indent indent) const {};
00163
00164 unsigned long m_CurrentIteration;
00165 bool m_InitialDerivativeProvided;
00166 bool m_InitialValueProvided;
00167 StopConditionType m_StopCondition;
00168 bool m_Stop;
00169 bool m_SufficientDecreaseConditionSatisfied;
00170 bool m_CurvatureConditionSatisfied;
00171
00174 virtual void GetInitialValueAndDerivative(void);
00175
00177 virtual int CheckSettings(void);
00178
00180 virtual void InitializeLineSearch(void);
00181
00184 virtual void UpdateIntervalMinimumAndMaximum(void);
00185
00187 void BoundStep(double & step) const;
00188
00190 virtual void PrepareForUnusualTermination(void);
00191
00193 virtual void ComputeCurrentValueAndDerivative(void);
00194
00196 virtual void TestConvergence(bool & stop);
00197
00199 virtual void ComputeNewStepAndInterval(void);
00200
00202 virtual void ForceSufficientDecreaseInIntervalWidth(void);
00203
00206 virtual int SafeGuardedStep(
00207 double & stx, double & fx, double & dx,
00208 double & sty, double & fy, double & dy,
00209 double & stp, const double & fp, const double & dp,
00210 bool & brackt,
00211 const double & stpmin, const double & stpmax) const;
00212
00213 double m_step;
00214 double m_stepx;
00215 double m_stepy;
00216 double m_stepmin;
00217 double m_stepmax;
00218
00219 MeasureType m_f;
00220 MeasureType m_fx;
00221 MeasureType m_fy;
00222 MeasureType m_finit;
00223
00224 DerivativeType m_g;
00225 double m_dg;
00226 double m_dginit;
00227 double m_dgx;
00228 double m_dgy;
00229 double m_dgtest;
00230
00231 double m_width;
00232 double m_width1;
00233
00234 bool m_brackt;
00235 bool m_stage1;
00236 bool m_SafeGuardedStepFailed;
00237
00238 private:
00239 MoreThuenteLineSearchOptimizer(const Self&);
00240 void operator=(const Self&);
00241
00242 unsigned long m_MaximumNumberOfIterations;
00243 double m_ValueTolerance;
00244 double m_GradientTolerance;
00245 double m_IntervalTolerance;
00246
00247 };
00248
00249
00250 }
00251
00252
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363 #endif // #ifndef __itkMoreThuenteLineSearchOptimizer_h
00364