18 #ifndef itkLBFGS2Optimizerv4_h
19 #define itkLBFGS2Optimizerv4_h
22 #include "ITKOptimizersv4Export.h"
88 extern ITKOptimizersv4_EXPORT std::ostream &
164 template <
typename TInternalComputationValueType>
174 #if !defined(ITK_LEGACY_REMOVE)
176 static constexpr
LineSearchMethodEnum LINESEARCH_DEFAULT = LineSearchMethodEnum::LINESEARCH_DEFAULT;
177 static constexpr
LineSearchMethodEnum LINESEARCH_MORETHUENTE = LineSearchMethodEnum::LINESEARCH_MORETHUENTE;
179 LineSearchMethodEnum::LINESEARCH_BACKTRACKING_ARMIJO;
180 static constexpr
LineSearchMethodEnum LINESEARCH_BACKTRACKING = LineSearchMethodEnum::LINESEARCH_BACKTRACKING;
182 LineSearchMethodEnum::LINESEARCH_BACKTRACKING_WOLFE;
184 LineSearchMethodEnum::LINESEARCH_BACKTRACKING_STRONG_WOLFE;
205 using typename Superclass::StopConditionReturnStringType;
215 StartOptimization(
bool doOnlyInitialization =
false)
override;
221 ResumeOptimization()
override;
224 GetStopConditionDescription()
const override;
235 SetHessianApproximationAccuracy(
int m);
237 GetHessianApproximationAccuracy()
const;
251 GetSolutionAccuracy()
const;
262 SetDeltaConvergenceDistance(
int nPast);
264 GetDeltaConvergenceDistance()
const;
280 GetDeltaConvergenceTolerance()
const;
292 SetMaximumIterations(
int maxIterations);
294 GetMaximumIterations()
const;
302 return GetMaximumIterations();
307 SetMaximumIterations(static_cast<int>(_arg));
318 SetLineSearch(
const LineSearchMethodEnum & linesearch);
320 GetLineSearch()
const;
329 SetMaximumLineSearchEvaluations(
int n);
331 GetMaximumLineSearchEvaluations()
const;
342 SetMinimumLineSearchStep(PrecisionType step);
344 GetMinimumLineSearchStep()
const;
355 SetMaximumLineSearchStep(PrecisionType step);
357 GetMaximumLineSearchStep()
const;
366 SetLineSearchAccuracy(PrecisionType ftol);
368 GetLineSearchAccuracy()
const;
381 SetWolfeCoefficient(PrecisionType wc);
383 GetWolfeCoefficient()
const;
398 SetLineSearchGradientAccuracy(PrecisionType gtol);
400 GetLineSearchGradientAccuracy()
const;
411 SetMachinePrecisionTolerance(PrecisionType xtol);
413 GetMachinePrecisionTolerance()
const;
430 SetOrthantwiseCoefficient(PrecisionType orthant_c);
432 GetOrthantwiseCoefficient()
const;
450 SetOrthantwiseStart(
int start);
452 GetOrthantwiseStart()
const;
463 SetOrthantwiseEnd(
int end);
465 GetOrthantwiseEnd()
const;
469 itkGetConstMacro(CurrentParameterNorm, PrecisionType);
472 itkGetConstMacro(CurrentGradientNorm, PrecisionType);
475 itkGetConstMacro(CurrentStepSize, PrecisionType);
478 itkGetConstMacro(CurrentNumberOfEvaluations, PrecisionType);
484 itkSetMacro(EstimateScalesAtEachIteration,
bool);
485 itkGetConstReferenceMacro(EstimateScalesAtEachIteration,
bool);
486 itkBooleanMacro(EstimateScalesAtEachIteration);
493 PrintSelf(std::ostream & os,
Indent indent)
const override;
498 UpdateProgressCallback(
void * instance,
499 const PrecisionType * x,
500 const PrecisionType * g,
501 const PrecisionType fx,
502 const PrecisionType xnorm,
503 const PrecisionType gnorm,
504 const PrecisionType step,
511 UpdateProgress(
const PrecisionType * x,
512 const PrecisionType * g,
513 const PrecisionType fx,
514 const PrecisionType xnorm,
515 const PrecisionType gnorm,
516 const PrecisionType step,
523 EvaluateCostCallback(
void * instance,
524 const PrecisionType * x,
527 const PrecisionType step);
530 EvaluateCost(
const PrecisionType * x, PrecisionType * g,
const int n,
const PrecisionType step);
534 class PrivateImplementationHolder;
535 lbfgs_parameter_t m_Parameters{};
537 bool m_EstimateScalesAtEachIteration{};
538 double m_CurrentStepSize{};
539 double m_CurrentParameterNorm{};
540 double m_CurrentGradientNorm{};
541 int m_CurrentNumberOfEvaluations{};
550 itkWarningMacro(
"Not supported. Please use LBFGS specific convergence methods.");
554 itkWarningMacro(
"Not supported. Please use LBFGS specific convergence methods.");
559 itkWarningMacro(
"Not supported. Please use LBFGS specific convergence methods.");
560 static double value = 0;
568 itkWarningMacro(
"LBFGS2Optimizerv4Template does not implement single step advance");
578 #ifndef ITK_MANUAL_INSTANTIATION
579 # include "itkLBFGS2Optimizerv4.hxx"