Loading...
Searching...
No Matches
itkMoreThuenteLineSearchOptimizer.h
Go to the documentation of this file.
/*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkMoreThuenteLineSearchOptimizer_h
#define itkMoreThuenteLineSearchOptimizer_h
#include "itkLineSearchOptimizer.h"
namespace itk
{
class MoreThuenteLineSearchOptimizer : public LineSearchOptimizer
{
public:
ITK_DISALLOW_COPY_AND_MOVE(MoreThuenteLineSearchOptimizer);
using Self = MoreThuenteLineSearchOptimizer;
using Superclass = LineSearchOptimizer;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;
itkNewMacro(Self);
itkTypeMacro(MoreThuenteLineSearchOptimizer, LineSearchOptimizer);
using Superclass::MeasureType;
using Superclass::ParametersType;
using Superclass::DerivativeType;
using Superclass::CostFunctionType;
enum StopConditionType
{
StrongWolfeConditionsSatisfied,
MetricError,
MaximumNumberOfIterations,
StepTooSmall,
StepTooLarge,
IntervalTooSmall,
RoundingError,
AscentSearchDirection,
Unknown
};
void
StartOptimization() override;
virtual void
StopOptimization();
void
SetInitialDerivative(const DerivativeType & derivative) override;
void
SetInitialValue(MeasureType value) override;
void
GetCurrentValueAndDerivative(MeasureType & value, DerivativeType & derivative) const override;
void
GetCurrentDerivative(DerivativeType & derivative) const override;
MeasureType
GetCurrentValue() const override;
virtual double
GetCurrentDirectionalDerivative() const;
itkGetConstMacro(CurrentIteration, unsigned long);
itkGetConstReferenceMacro(StopCondition, StopConditionType);
itkGetConstMacro(SufficientDecreaseConditionSatisfied, bool);
itkGetConstMacro(CurvatureConditionSatisfied, bool);
itkGetConstMacro(MaximumNumberOfIterations, unsigned long);
itkSetClampMacro(MaximumNumberOfIterations, unsigned long, 1, NumericTraits<unsigned long>::max());
itkSetClampMacro(ValueTolerance, double, 0.0, NumericTraits<double>::max());
itkGetConstMacro(ValueTolerance, double);
itkSetClampMacro(GradientTolerance, double, 0.0, NumericTraits<double>::max());
itkGetConstMacro(GradientTolerance, double);
itkSetClampMacro(IntervalTolerance, double, 0.0, NumericTraits<double>::max());
itkGetConstMacro(IntervalTolerance, double);
protected:
MoreThuenteLineSearchOptimizer();
~MoreThuenteLineSearchOptimizer() override = default;
void
PrintSelf(std::ostream & os, Indent indent) const override;
unsigned long m_CurrentIteration{};
bool m_InitialDerivativeProvided{};
bool m_InitialValueProvided{};
StopConditionType m_StopCondition{};
bool m_Stop{};
bool m_SufficientDecreaseConditionSatisfied{};
bool m_CurvatureConditionSatisfied{};
virtual void
GetInitialValueAndDerivative();
virtual int
CheckSettings();
void
InitializeLineSearch();
virtual void
UpdateIntervalMinimumAndMaximum();
void
BoundStep(double & step) const;
virtual void
PrepareForUnusualTermination();
virtual void
ComputeCurrentValueAndDerivative();
virtual void
TestConvergence(bool & stop);
virtual void
ComputeNewStepAndInterval();
virtual void
ForceSufficientDecreaseInIntervalWidth();
virtual int
SafeGuardedStep(double & stx,
double & fx,
double & dx,
double & sty,
double & fy,
double & dy,
double & stp,
const double fp,
const double dp,
bool & brackt,
const double stpmin,
const double stpmax) const;
double m_step{};
double m_stepx{};
double m_stepy{};
double m_stepmin{};
double m_stepmax{};
MeasureType m_f{}; // CurrentValue
MeasureType m_fx{};
MeasureType m_fy{};
MeasureType m_finit{};
DerivativeType m_g{}; // CurrentDerivative
double m_dg{}; // CurrentDirectionalDerivative
double m_dginit{};
double m_dgx{};
double m_dgy{};
double m_dgtest{};
double m_width{};
double m_width1{};
bool m_brackt{};
bool m_stage1{};
bool m_SafeGuardedStepFailed{};
private:
unsigned long m_MaximumNumberOfIterations{};
double m_ValueTolerance{};
double m_GradientTolerance{};
double m_IntervalTolerance{};
};
} // end namespace itk
/* SUBROUTINE MCSRCH */
/* A slight modification of the subroutine CSRCH of More' and Thuente. */
/* The changes are to allow reverse communication, and do not affect */
/* the performance of the routine. */
/* THE PURPOSE OF MCSRCH IS TO FIND A STEP WHICH SATISFIES */
/* A SUFFICIENT DECREASE CONDITION AND A CURVATURE CONDITION. */
/* AT EACH STAGE THE SUBROUTINE UPDATES AN INTERVAL OF */
/* UNCERTAINTY WITH ENDPOINTS STX AND STY. THE INTERVAL OF */
/* UNCERTAINTY IS INITIALLY CHOSEN SO THAT IT CONTAINS A */
/* MINIMIZER OF THE MODIFIED FUNCTION */
/* F(X+STP*S) - F(X) - FTOL*STP*(GRADF(X)'S). */
/* IF A STEP IS OBTAINED FOR WHICH THE MODIFIED FUNCTION */
/* HAS A NONPOSITIVE FUNCTION VALUE AND NONNEGATIVE DERIVATIVE, */
/* THEN THE INTERVAL OF UNCERTAINTY IS CHOSEN SO THAT IT */
/* CONTAINS A MINIMIZER OF F(X+STP*S). */
/* THE ALGORITHM IS DESIGNED TO FIND A STEP WHICH SATISFIES */
/* THE SUFFICIENT DECREASE CONDITION */
/* F(X+STP*S) .LE. F(X) + FTOL*STP*(GRADF(X)'S), */
/* AND THE CURVATURE CONDITION */
/* ABS(GRADF(X+STP*S)'S)) .LE. GTOL*ABS(GRADF(X)'S). */
/* IF FTOL IS LESS THAN GTOL AND IF, FOR EXAMPLE, THE FUNCTION */
/* IS BOUNDED BELOW, THEN THERE IS ALWAYS A STEP WHICH SATISFIES */
/* BOTH CONDITIONS. IF NO STEP CAN BE FOUND WHICH SATISFIES BOTH */
/* CONDITIONS, THEN THE ALGORITHM USUALLY STOPS WHEN ROUNDING */
/* ERRORS PREVENT FURTHER PROGRESS. IN THIS CASE STP ONLY */
/* SATISFIES THE SUFFICIENT DECREASE CONDITION. */
/* THE SUBROUTINE STATEMENT IS */
/* SUBROUTINE MCSRCH(N,X,F,G,S,STP,FTOL,XTOL, MAXFEV,INFO,NFEV,WA) */
/* WHERE */
/* N IS A POSITIVE INTEGER INPUT VARIABLE SET TO THE NUMBER */
/* OF VARIABLES. */
/* X IS AN ARRAY OF LENGTH N. ON INPUT IT MUST CONTAIN THE */
/* BASE POINT FOR THE LINE SEARCH. ON OUTPUT IT CONTAINS */
/* X + STP*S. */
/* F IS A VARIABLE. ON INPUT IT MUST CONTAIN THE VALUE OF F */
/* AT X. ON OUTPUT IT CONTAINS THE VALUE OF F AT X + STP*S. */
/* G IS AN ARRAY OF LENGTH N. ON INPUT IT MUST CONTAIN THE */
/* GRADIENT OF F AT X. ON OUTPUT IT CONTAINS THE GRADIENT */
/* OF F AT X + STP*S. */
/* S IS AN INPUT ARRAY OF LENGTH N WHICH SPECIFIES THE */
/* SEARCH DIRECTION. */
/* STP IS A NONNEGATIVE VARIABLE. ON INPUT STP CONTAINS AN */
/* INITIAL ESTIMATE OF A SATISFACTORY STEP. ON OUTPUT */
/* STP CONTAINS THE FINAL ESTIMATE. */
/* FTOL AND GTOL ARE NONNEGATIVE INPUT VARIABLES. (In this reverse */
/* communication implementation GTOL is defined in a COMMON */
/* statement.) TERMINATION OCCURS WHEN THE SUFFICIENT DECREASE */
/* CONDITION AND THE DIRECTIONAL DERIVATIVE CONDITION ARE */
/* SATISFIED. */
/* XTOL IS A NONNEGATIVE INPUT VARIABLE. TERMINATION OCCURS */
/* WHEN THE RELATIVE WIDTH OF THE INTERVAL OF UNCERTAINTY */
/* IS AT MOST XTOL. */
/* STPMIN AND STPMAX ARE NONNEGATIVE INPUT VARIABLES WHICH */
/* SPECIFY LOWER AND UPPER BOUNDS FOR THE STEP. (In this reverse */
/* communication implementatin they are defined in a COMMON */
/* statement). */
/* MAXFEV IS A POSITIVE INTEGER INPUT VARIABLE. TERMINATION */
/* OCCURS WHEN THE NUMBER OF CALLS TO FCN IS AT LEAST */
/* MAXFEV BY THE END OF AN ITERATION. */
/* INFO IS AN INTEGER OUTPUT VARIABLE SET AS FOLLOWS: */
/* INFO = 0 IMPROPER INPUT PARAMETERS. */
/* INFO =-1 A RETURN IS MADE TO COMPUTE THE FUNCTION AND GRADIENT. */
/* NFEV IS AN INTEGER OUTPUT VARIABLE SET TO THE NUMBER OF */
/* CALLS TO FCN. */
/* WA IS A WORK ARRAY OF LENGTH N. */
/* SUBPROGRAMS CALLED */
/* MCSTEP */
/* FORTRAN-SUPPLIED...ABS,MAX,MIN */
/* ARGONNE NATIONAL LABORATORY. MINPACK PROJECT. JUNE 1983 */
/* JORGE J. MORE', DAVID J. THUENTE */
/* ********** */
#endif // #ifndef itkMoreThuenteLineSearchOptimizer_h
itk::LineSearchOptimizer::LineSearchOptimizer
LineSearchOptimizer()
itk::MoreThuenteLineSearchOptimizer::m_GradientTolerance
double m_GradientTolerance
Definition itkMoreThuenteLineSearchOptimizer.h:279
itk::MoreThuenteLineSearchOptimizer::GetCurrentValueAndDerivative
void GetCurrentValueAndDerivative(MeasureType &value, DerivativeType &derivative) const override
itk::MoreThuenteLineSearchOptimizer::SetInitialDerivative
void SetInitialDerivative(const DerivativeType &derivative) override
itk::MoreThuenteLineSearchOptimizer::m_dginit
double m_dginit
Definition itkMoreThuenteLineSearchOptimizer.h:264
itk::MoreThuenteLineSearchOptimizer::~MoreThuenteLineSearchOptimizer
~MoreThuenteLineSearchOptimizer() override=default
itk::MoreThuenteLineSearchOptimizer::ComputeCurrentValueAndDerivative
virtual void ComputeCurrentValueAndDerivative()
itk::MoreThuenteLineSearchOptimizer::GetCurrentValue
MeasureType GetCurrentValue() const override
itk::MoreThuenteLineSearchOptimizer::m_fx
MeasureType m_fx
Definition itkMoreThuenteLineSearchOptimizer.h:258
itk::MoreThuenteLineSearchOptimizer::m_dgx
double m_dgx
Definition itkMoreThuenteLineSearchOptimizer.h:265
itk::MoreThuenteLineSearchOptimizer::m_finit
MeasureType m_finit
Definition itkMoreThuenteLineSearchOptimizer.h:260
itk::MoreThuenteLineSearchOptimizer::m_width
double m_width
Definition itkMoreThuenteLineSearchOptimizer.h:269
itk::MoreThuenteLineSearchOptimizer::m_MaximumNumberOfIterations
unsigned long m_MaximumNumberOfIterations
Definition itkMoreThuenteLineSearchOptimizer.h:277
itk::MoreThuenteLineSearchOptimizer::m_InitialValueProvided
bool m_InitialValueProvided
Definition itkMoreThuenteLineSearchOptimizer.h:186
itk::MoreThuenteLineSearchOptimizer::m_g
DerivativeType m_g
Definition itkMoreThuenteLineSearchOptimizer.h:262
itk::MoreThuenteLineSearchOptimizer::m_SufficientDecreaseConditionSatisfied
bool m_SufficientDecreaseConditionSatisfied
Definition itkMoreThuenteLineSearchOptimizer.h:189
itk::MoreThuenteLineSearchOptimizer::m_CurrentIteration
unsigned long m_CurrentIteration
Definition itkMoreThuenteLineSearchOptimizer.h:184
itk::MoreThuenteLineSearchOptimizer::m_brackt
bool m_brackt
Definition itkMoreThuenteLineSearchOptimizer.h:272
itk::MoreThuenteLineSearchOptimizer::TestConvergence
virtual void TestConvergence(bool &stop)
itk::MoreThuenteLineSearchOptimizer::m_f
MeasureType m_f
Definition itkMoreThuenteLineSearchOptimizer.h:257
itk::MoreThuenteLineSearchOptimizer::m_width1
double m_width1
Definition itkMoreThuenteLineSearchOptimizer.h:270
itk::MoreThuenteLineSearchOptimizer::m_step
double m_step
Definition itkMoreThuenteLineSearchOptimizer.h:251
itk::MoreThuenteLineSearchOptimizer::m_stage1
bool m_stage1
Definition itkMoreThuenteLineSearchOptimizer.h:273
itk::MoreThuenteLineSearchOptimizer::PrepareForUnusualTermination
virtual void PrepareForUnusualTermination()
itk::MoreThuenteLineSearchOptimizer::ITK_DISALLOW_COPY_AND_MOVE
ITK_DISALLOW_COPY_AND_MOVE(MoreThuenteLineSearchOptimizer)
itk::MoreThuenteLineSearchOptimizer::CheckSettings
virtual int CheckSettings()
itk::MoreThuenteLineSearchOptimizer::ConstPointer
SmartPointer< const Self > ConstPointer
Definition itkMoreThuenteLineSearchOptimizer.h:79
itk::MoreThuenteLineSearchOptimizer::m_InitialDerivativeProvided
bool m_InitialDerivativeProvided
Definition itkMoreThuenteLineSearchOptimizer.h:185
itk::MoreThuenteLineSearchOptimizer::m_ValueTolerance
double m_ValueTolerance
Definition itkMoreThuenteLineSearchOptimizer.h:278
itk::MoreThuenteLineSearchOptimizer::BoundStep
void BoundStep(double &step) const
itk::MoreThuenteLineSearchOptimizer::m_dgtest
double m_dgtest
Definition itkMoreThuenteLineSearchOptimizer.h:267
itk::MoreThuenteLineSearchOptimizer::m_fy
MeasureType m_fy
Definition itkMoreThuenteLineSearchOptimizer.h:259
itk::MoreThuenteLineSearchOptimizer::m_dg
double m_dg
Definition itkMoreThuenteLineSearchOptimizer.h:263
itk::MoreThuenteLineSearchOptimizer::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::MoreThuenteLineSearchOptimizer::Pointer
SmartPointer< Self > Pointer
Definition itkMoreThuenteLineSearchOptimizer.h:78
itk::MoreThuenteLineSearchOptimizer::m_StopCondition
StopConditionType m_StopCondition
Definition itkMoreThuenteLineSearchOptimizer.h:187
itk::MoreThuenteLineSearchOptimizer::StopConditionType
StopConditionType
Definition itkMoreThuenteLineSearchOptimizer.h:90
itk::MoreThuenteLineSearchOptimizer::StepTooSmall
@ StepTooSmall
Definition itkMoreThuenteLineSearchOptimizer.h:94
itk::MoreThuenteLineSearchOptimizer::IntervalTooSmall
@ IntervalTooSmall
Definition itkMoreThuenteLineSearchOptimizer.h:96
itk::MoreThuenteLineSearchOptimizer::StepTooLarge
@ StepTooLarge
Definition itkMoreThuenteLineSearchOptimizer.h:95
itk::MoreThuenteLineSearchOptimizer::MaximumNumberOfIterations
@ MaximumNumberOfIterations
Definition itkMoreThuenteLineSearchOptimizer.h:93
itk::MoreThuenteLineSearchOptimizer::StrongWolfeConditionsSatisfied
@ StrongWolfeConditionsSatisfied
Definition itkMoreThuenteLineSearchOptimizer.h:91
itk::MoreThuenteLineSearchOptimizer::MetricError
@ MetricError
Definition itkMoreThuenteLineSearchOptimizer.h:92
itk::MoreThuenteLineSearchOptimizer::RoundingError
@ RoundingError
Definition itkMoreThuenteLineSearchOptimizer.h:97
itk::MoreThuenteLineSearchOptimizer::Unknown
@ Unknown
Definition itkMoreThuenteLineSearchOptimizer.h:99
itk::MoreThuenteLineSearchOptimizer::AscentSearchDirection
@ AscentSearchDirection
Definition itkMoreThuenteLineSearchOptimizer.h:98
itk::MoreThuenteLineSearchOptimizer::SafeGuardedStep
virtual int SafeGuardedStep(double &stx, double &fx, double &dx, double &sty, double &fy, double &dy, double &stp, const double fp, const double dp, bool &brackt, const double stpmin, const double stpmax) const
itk::MoreThuenteLineSearchOptimizer::Superclass
LineSearchOptimizer Superclass
Definition itkMoreThuenteLineSearchOptimizer.h:77
itk::MoreThuenteLineSearchOptimizer::InitializeLineSearch
void InitializeLineSearch()
itk::MoreThuenteLineSearchOptimizer::m_SafeGuardedStepFailed
bool m_SafeGuardedStepFailed
Definition itkMoreThuenteLineSearchOptimizer.h:274
itk::MoreThuenteLineSearchOptimizer::m_stepy
double m_stepy
Definition itkMoreThuenteLineSearchOptimizer.h:253
itk::MoreThuenteLineSearchOptimizer::m_stepmin
double m_stepmin
Definition itkMoreThuenteLineSearchOptimizer.h:254
itk::MoreThuenteLineSearchOptimizer::ForceSufficientDecreaseInIntervalWidth
virtual void ForceSufficientDecreaseInIntervalWidth()
itk::MoreThuenteLineSearchOptimizer::m_stepmax
double m_stepmax
Definition itkMoreThuenteLineSearchOptimizer.h:255
itk::MoreThuenteLineSearchOptimizer::StopOptimization
virtual void StopOptimization()
itk::MoreThuenteLineSearchOptimizer::ComputeNewStepAndInterval
virtual void ComputeNewStepAndInterval()
itk::MoreThuenteLineSearchOptimizer::UpdateIntervalMinimumAndMaximum
virtual void UpdateIntervalMinimumAndMaximum()
itk::MoreThuenteLineSearchOptimizer::GetCurrentDerivative
void GetCurrentDerivative(DerivativeType &derivative) const override
itk::MoreThuenteLineSearchOptimizer::Self
MoreThuenteLineSearchOptimizer Self
Definition itkMoreThuenteLineSearchOptimizer.h:76
itk::MoreThuenteLineSearchOptimizer::m_IntervalTolerance
double m_IntervalTolerance
Definition itkMoreThuenteLineSearchOptimizer.h:280
itk::MoreThuenteLineSearchOptimizer::m_dgy
double m_dgy
Definition itkMoreThuenteLineSearchOptimizer.h:266
itk::MoreThuenteLineSearchOptimizer::m_CurvatureConditionSatisfied
bool m_CurvatureConditionSatisfied
Definition itkMoreThuenteLineSearchOptimizer.h:190
itk::MoreThuenteLineSearchOptimizer::GetCurrentDirectionalDerivative
virtual double GetCurrentDirectionalDerivative() const
itk::MoreThuenteLineSearchOptimizer::StartOptimization
void StartOptimization() override
itk::MoreThuenteLineSearchOptimizer::GetInitialValueAndDerivative
virtual void GetInitialValueAndDerivative()
itk::MoreThuenteLineSearchOptimizer::MoreThuenteLineSearchOptimizer
MoreThuenteLineSearchOptimizer()
itk::MoreThuenteLineSearchOptimizer::m_stepx
double m_stepx
Definition itkMoreThuenteLineSearchOptimizer.h:252
itk::MoreThuenteLineSearchOptimizer::m_Stop
bool m_Stop
Definition itkMoreThuenteLineSearchOptimizer.h:188
itk::MoreThuenteLineSearchOptimizer::SetInitialValue
void SetInitialValue(MeasureType value) override
itkLineSearchOptimizer.h
itk
Definition itkAdvancedImageToImageMetric.h:43

Generated on 1768596610 for elastix by 1.15.0 |