Class GaussNewtonBase_F64<C extends ConfigGaussNewton,​HM extends HessianMath>

java.lang.Object
org.ddogleg.optimization.GaussNewtonBase_F64<C,​HM>
Direct Known Subclasses:
LevenbergMarquardt_F64, TrustRegionBase_F64

public abstract class GaussNewtonBase_F64<C extends ConfigGaussNewton,​HM extends HessianMath>
extends Object
Base class for Gauss-Newton based approaches for unconstrained optimization.
  • Field Details

    • hessian

      public HM extends HessianMath hessian
    • x

      public DMatrixRMaj x
    • x_next

      public DMatrixRMaj x_next
    • p

      public DMatrixRMaj p
    • fx

      public double fx
    • gradient

      public DMatrixRMaj gradient
      Storage for the gradient
    • sameStateAsCost

      protected boolean sameStateAsCost
    • hessianScaling

      protected DMatrixRMaj hessianScaling
    • mode

      protected GaussNewtonBase_F64.Mode mode
    • totalFullSteps

      protected int totalFullSteps
    • totalSelectSteps

      protected int totalSelectSteps
    • verbose

      @Nullable protected @Nullable PrintStream verbose
    • verboseLevel

      protected int verboseLevel
    • config

      public C extends ConfigGaussNewton config
    • ftest_val

      public double ftest_val
    • gtest_val

      public double gtest_val
  • Constructor Details

    • GaussNewtonBase_F64

      protected GaussNewtonBase_F64​(HM hessian)
  • Method Details

    • initialize

      public void initialize​(double[] initial, int numberOfParameters)
    • iterate

      public boolean iterate()
      Performs one iteration
      Returns:
      true if it has converged or false if not
    • updateDerivates

      protected abstract boolean updateDerivates()
      Computes all the derived data structures and attempts to update the parameters
      Returns:
      true if it has converged.
    • computeStep

      protected abstract boolean computeStep()
      Selects the next step
      Returns:
      true if it has converged.
    • computeHessianScaling

      protected void computeHessianScaling()
      Sets scaling to the sqrt() of the diagonal elements in the Hessian matrix
    • computeHessianScaling

      public void computeHessianScaling​(DMatrixRMaj scaling)
      Applies the standard formula for computing scaling. This is broken off into its own function so that it easily invoked if the function above is overridden
      Parameters:
      scaling - Vector containing scaling information
    • applyHessianScaling

      protected void applyHessianScaling()
      Apply scaling to gradient and Hessian
    • undoHessianScalingOnParameters

      protected void undoHessianScalingOnParameters​(DMatrixRMaj p)
      Undo scaling on estimated parameters
    • checkConvergenceGTest

      protected boolean checkConvergenceGTest​(DMatrixRMaj g)

      Checks for convergence using f-test:

      g-test : gtol ≤ ||g(x)||_inf
      Returns:
      true if converged or false if it hasn't converged
    • functionGradientHessian

      protected abstract void functionGradientHessian​(DMatrixRMaj x, boolean sameStateAsCost, DMatrixRMaj gradient, HM hessian)
      Computes the gradient and Hessian at 'x'. If sameStateAsCost is true then it can be assumed that 'x' has not changed since the cost was last computed.
      Parameters:
      gradient - (Input) x
      sameStateAsCost - (Input) If true then when the cost (or residuals) was last called it had the same value of x
      gradient - (Output) gradient
      hessian - (Output) hessian
    • computePredictedReduction

      public double computePredictedReduction​(DMatrixRMaj p)
      Computes predicted reduction for step 'p'
      Parameters:
      p - Change in state or the step
      Returns:
      predicted reduction in quadratic model
    • mode

      public GaussNewtonBase_F64.Mode mode()
    • setVerbose

      public void setVerbose​(@Nullable @Nullable PrintStream out, int level)
      If set to a non-null output then extra information will be printed to the specified stream.
      Parameters:
      out - Stream that is printed to. Set to null to disable
      level - (Future use) Parameter which can be used to specify level of verbose output. Set to zero for now.