Class SequentialGaussNewtonOptimizer

java.lang.Object
org.hipparchus.optim.nonlinear.vector.leastsquares.SequentialGaussNewtonOptimizer
All Implemented Interfaces:
LeastSquaresOptimizer

public class SequentialGaussNewtonOptimizer extends Object implements LeastSquaresOptimizer
Sequential Gauss-Newton least-squares solver.

This class solve a least-square problem by solving the normal equations of the linearized problem at each iteration.

  • Constructor Details

    • SequentialGaussNewtonOptimizer

      public SequentialGaussNewtonOptimizer()
      Create a sequential Gauss Newton optimizer.

      The default for the algorithm is to use QR decomposition, not form normal equations and have no previous evaluation

    • SequentialGaussNewtonOptimizer

      public SequentialGaussNewtonOptimizer(MatrixDecomposer decomposer, boolean formNormalEquations, LeastSquaresProblem.Evaluation evaluation)
      Create a sequential Gauss Newton optimizer that uses the given matrix decomposition algorithm to solve the normal equations.

      The decomposer is used to solve JTJx=JTr.

      Parameters:
      decomposer - the decomposition algorithm to use.
      formNormalEquations - whether the normal equations should be explicitly formed. If true then decomposer is used to solve JTJx=JTr, otherwise decomposer is used to solve Jx=r. If decomposer can only solve square systems then this parameter should be true.
      evaluation - old evaluation previously computed, null if there are no previous evaluations.
  • Method Details

    • getDecomposer

      public MatrixDecomposer getDecomposer()
      Get the matrix decomposition algorithm.
      Returns:
      the decomposition algorithm.
    • withDecomposer

      public SequentialGaussNewtonOptimizer withDecomposer(MatrixDecomposer newDecomposer)
      Configure the matrix decomposition algorithm.
      Parameters:
      newDecomposer - the decomposition algorithm to use.
      Returns:
      a new instance.
    • isFormNormalEquations

      public boolean isFormNormalEquations()
      Get if the normal equations are explicitly formed.
      Returns:
      if the normal equations should be explicitly formed. If true then decomposer is used to solve JTJx=JTr, otherwise decomposer is used to solve Jx=r.
    • withFormNormalEquations

      public SequentialGaussNewtonOptimizer withFormNormalEquations(boolean newFormNormalEquations)
      Configure if the normal equations should be explicitly formed.
      Parameters:
      newFormNormalEquations - whether the normal equations should be explicitly formed. If true then decomposer is used to solve JTJx=JTr, otherwise decomposer is used to solve Jx=r. If decomposer can only solve square systems then this parameter should be true.
      Returns:
      a new instance.
    • getOldEvaluation

      public LeastSquaresProblem.Evaluation getOldEvaluation()
      Get the previous evaluation used by the optimizer.
      Returns:
      the previous evaluation.
    • withEvaluation

      public SequentialGaussNewtonOptimizer withEvaluation(LeastSquaresProblem.Evaluation previousEvaluation)
      Configure the previous evaluation used by the optimizer.

      This building method uses a complete evaluation to retrieve a priori data. Note that as withAPrioriData(RealVector, RealMatrix) generates a fake evaluation and calls this method, either withAPrioriData(RealVector, RealMatrix) or withEvaluation(LeastSquaresProblem.Evaluation) should be called, but not both as the last one called will override the previous one.

      Parameters:
      previousEvaluation - the previous evaluation used by the optimizer.
      Returns:
      a new instance.
    • withAPrioriData

      public SequentialGaussNewtonOptimizer withAPrioriData(RealVector aPrioriState, RealMatrix aPrioriCovariance)
      Configure from a priori state and covariance.

      This building method generates a fake evaluation and calls withEvaluation(LeastSquaresProblem.Evaluation), so either withAPrioriData(RealVector, RealMatrix) or withEvaluation(LeastSquaresProblem.Evaluation) should be called, but not both as the last one called will override the previous one.

      A Cholesky decomposition is used to compute the weighted jacobian from the a priori covariance. This method uses the default thresholds of the decomposition.

      Parameters:
      aPrioriState - a priori state to use
      aPrioriCovariance - a priori covariance to use
      Returns:
      a new instance.
      See Also:
    • withAPrioriData

      public SequentialGaussNewtonOptimizer withAPrioriData(RealVector aPrioriState, RealMatrix aPrioriCovariance, double relativeSymmetryThreshold, double absolutePositivityThreshold)
      Configure from a priori state and covariance.

      This building method generates a fake evaluation and calls withEvaluation(LeastSquaresProblem.Evaluation), so either withAPrioriData(RealVector, RealMatrix) or withEvaluation(LeastSquaresProblem.Evaluation) should be called, but not both as the last one called will override the previous one.

      A Cholesky decomposition is used to compute the weighted jacobian from the a priori covariance.

      Parameters:
      aPrioriState - a priori state to use
      aPrioriCovariance - a priori covariance to use
      relativeSymmetryThreshold - Cholesky decomposition threshold above which off-diagonal elements are considered too different and matrix not symmetric
      absolutePositivityThreshold - Cholesky decomposition threshold below which diagonal elements are considered null and matrix not positive definite
      Returns:
      a new instance.
      Since:
      2.3
    • optimize

      Solve the non-linear least squares problem.
      Specified by:
      optimize in interface LeastSquaresOptimizer
      Parameters:
      lsp - the problem definition, including model function and convergence criteria.
      Returns:
      The optimum.
    • toString

      public String toString()
      Overrides:
      toString in class Object