Interface UnconstrainedLeastSquares<S extends DMatrix>

All Superinterfaces:
IterativeOptimization, Serializable
All Known Implementing Classes:
UnconLeastSqLevenbergMarquardt_F64, UnconLeastSqTrustRegion_F64

public interface UnconstrainedLeastSquares<S extends DMatrix> extends IterativeOptimization

Non-linear least squares problems have a special structure which can be taken advantage of for optimization. The least squares problem is defined below:
F(x) = 0.5*sum( i=1:M ; fi(x)2 )
where fi(x) is a function from ℜN to ℜ. M is number of functions, and N is number of fit parameters. M ≥ N
fi(x) = observed - predicted, which is known as the residual error.

F-Test: ftol ≤ 1 - f(x+p)/f(x)
G-Test: gtol ≤ ||g(x)||inf
An absolute f-test can be done by checking the value of getFunctionValue() in each iteration.

NOTE: The function computes the M outputs of the fi(x), residual error functions, NOT [fi(x)]2

FORMATS:
Input functions are specified using FunctionNtoM for the set of M functions, and FunctionNtoMxN for the Jacobian. The function's output is a vector of length M, where element i correspond to function i's output. The Jacobian is an array containing the partial derivatives of each function. Element J(i,j) corresponds to the partial of function i and parameter j. The array is stored in a row major format. The partial for F(i,j) would be stored at index = i*N+j in the data array.

NOTE: If you need to modify the optimization parameters this can be done inside the 'function'.

  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the value of the objective function being evaluated at the current parameters value.
    double[]
    After each iteration this function can be called to get the current best set of parameters.
    void
    initialize(double[] initial, double ftol, double gtol)
    Specify the initial set of parameters from which to start from.
    void
    setFunction(FunctionNtoM function, @Nullable FunctionNtoMxN<S> jacobian)
    Specifies a set of functions and their Jacobian.

    Methods inherited from interface org.ddogleg.optimization.IterativeOptimization

    isConverged, isUpdated, iterate, setVerbose
  • Method Details

    • setFunction

      void setFunction(FunctionNtoM function, @Nullable @Nullable FunctionNtoMxN<S> jacobian)
      Specifies a set of functions and their Jacobian. See class description for documentation on output data format.
      Parameters:
      function - Computes the output of M functions fi(x) which take in N fit parameters as input.
      jacobian - Computes the Jacobian of the M functions. If null a numerical Jacobian will be used.
    • initialize

      void initialize(double[] initial, double ftol, double gtol)
      Specify the initial set of parameters from which to start from. Call after setFunction(org.ddogleg.optimization.functions.FunctionNtoM, org.ddogleg.optimization.functions.FunctionNtoMxN<S>) has been called.
      Parameters:
      initial - Initial parameters or guess with N elements..
      ftol - Relative threshold for change in function value between iterations. 0 ≤ ftol ≤ 1. Try 1e-12
      gtol - Absolute threshold for convergence based on the gradient's norm. 0 disables test. 0 ≤ gtol. Try 1e-12
    • getParameters

      double[] getParameters()
      After each iteration this function can be called to get the current best set of parameters.
    • getFunctionValue

      double getFunctionValue()
      Returns the value of the objective function being evaluated at the current parameters value. If not supported then an exception is thrown.
      Returns:
      Objective function's value.