Class 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 Detail

      • 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 Detail

      • 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.
      • 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