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 : public LineSearchOptimizer
00068 {
00069 public:
00070 typedef MoreThuenteLineSearchOptimizer Self;
00071 typedef LineSearchOptimizer Superclass;
00072 typedef SmartPointer<Self> Pointer;
00073 typedef SmartPointer<const Self> ConstPointer;
00074
00075 itkNewMacro( Self );
00076 itkTypeMacro( MoreThuenteLineSearchOptimizer, LineSearchOptimizer );
00077
00078 typedef Superclass::MeasureType MeasureType;
00079 typedef Superclass::ParametersType ParametersType;
00080 typedef Superclass::DerivativeType DerivativeType;
00081 typedef Superclass::CostFunctionType CostFunctionType;
00082
00083 typedef enum {
00084 StrongWolfeConditionsSatisfied,
00085 MetricError,
00086 MaximumNumberOfIterations,
00087 StepTooSmall,
00088 StepTooLarge,
00089 IntervalTooSmall,
00090 RoundingError,
00091 AscentSearchDirection,
00092 Unknown } StopConditionType;
00093
00094 virtual void StartOptimization( void );
00095 virtual void StopOptimization( void );
00096
00100 virtual void SetInitialDerivative( const DerivativeType & derivative );
00101 virtual void SetInitialValue( MeasureType value );
00102
00106 virtual void GetCurrentValueAndDerivative(
00107 MeasureType & value, DerivativeType & derivative ) const;
00108 virtual void GetCurrentDerivative( DerivativeType & derivative ) const;
00109 virtual MeasureType GetCurrentValue( void ) const;
00110 virtual double GetCurrentDirectionalDerivative( void ) const;
00111
00113 itkGetConstMacro( CurrentIteration, unsigned long );
00114 itkGetConstReferenceMacro( StopCondition, StopConditionType );
00115 itkGetConstMacro( SufficientDecreaseConditionSatisfied, bool );
00116 itkGetConstMacro( CurvatureConditionSatisfied, bool );
00117
00119 itkGetConstMacro( MaximumNumberOfIterations, unsigned long );
00120 itkSetClampMacro( MaximumNumberOfIterations, unsigned long,
00121 1, NumericTraits<unsigned long>::max() );
00122
00132 itkSetClampMacro( ValueTolerance, double, 0.0, NumericTraits<double>::max() );
00133 itkGetConstMacro( ValueTolerance, double );
00134
00144 itkSetClampMacro( GradientTolerance, double, 0.0, NumericTraits<double>::max() );
00145 itkGetConstMacro( GradientTolerance, double );
00146
00155 itkSetClampMacro( IntervalTolerance, double, 0.0, NumericTraits<double>::max() );
00156 itkGetConstMacro( IntervalTolerance, double );
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
00173 virtual void GetInitialValueAndDerivative( void );
00174
00176 virtual int CheckSettings( void );
00177
00179 virtual void InitializeLineSearch( void );
00180
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
00207 virtual int SafeGuardedStep(
00208 double & stx, double & fx, double & dx,
00209 double & sty, double & fy, double & dy,
00210 double & stp, const double & fp, const double & dp,
00211 bool & brackt,
00212 const double & stpmin, const double & stpmax ) const;
00213
00214 double m_step;
00215 double m_stepx;
00216 double m_stepy;
00217 double m_stepmin;
00218 double m_stepmax;
00219
00220 MeasureType m_f;
00221 MeasureType m_fx;
00222 MeasureType m_fy;
00223 MeasureType m_finit;
00224
00225 DerivativeType m_g;
00226 double m_dg;
00227 double m_dginit;
00228 double m_dgx;
00229 double m_dgy;
00230 double m_dgtest;
00231
00232 double m_width;
00233 double m_width1;
00234
00235 bool m_brackt;
00236 bool m_stage1;
00237 bool m_SafeGuardedStepFailed;
00238
00239 private:
00240 MoreThuenteLineSearchOptimizer(const Self&);
00241 void operator=(const Self&);
00242
00243 unsigned long m_MaximumNumberOfIterations;
00244 double m_ValueTolerance;
00245 double m_GradientTolerance;
00246 double m_IntervalTolerance;
00247
00248 };
00249
00250
00251 }
00252
00253
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
00364 #endif // #ifndef __itkMoreThuenteLineSearchOptimizer_h
00365