Class Lmmin

java.lang.Object
gov.nih.mipav.model.algorithms.Lmmin
Direct Known Subclasses:
AlgorithmELSUNCOpt2D.FitOAR2DLMModel, AlgorithmELSUNCOpt3D.FitOAR3DLMModel

public abstract class Lmmin extends Object
To run self tests in another module put: if (testMode) { new FitAll(); setCompleted(false); return; } class FitAll extends Lmmin { public FitAll() { super(); } public void fitToFunction(double x[], double fvec[], int info[]) { return; } }
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
     
    private final int
     
    private final int
     
    private final int
     
    private final int
     
    private final double
     
    private final double
     
    private final double
    2**-1022 = D1MACH(1).
    protected boolean
     
    protected boolean
     
    protected double[]
    diag is an array of length n.
    private final int
     
    protected double
    step used to calculate the jacobian epsfcn is an input variable used in choosing a step length for the forward-difference approximation.
    private final int
     
    protected double
    initial bound to steps in the outer loop factor is a positive input variable used in determining the initial step bound.
    private double[]
    fjac is an OUTPUT m by n array.
    protected double
    norm of the residue vector fvec
    private final int
     
    protected double
    ftol is a nonnegative input variable.
    private double[]
    fvec is an output array of length m which contains the functions evaluated at the output x.
    protected double
    gtol is a nonnegative input variable.
    private final int
     
    private final int
     
    private final int
     
    private final int
     
    private final int
     
    private final int
     
    protected int[]
    status of minimization info is an integer OUTPUT variable that indicates the termination status of lm_lmdif as follows: info invalid input: '<' 0 termination requested by user-supplied routine *evaluate; info = 0 fnorm almost vanishing; info = 1 both actual and predicted relative reductions in the sum of squares are at most ftol; info = 2 relative error between two consecutive iterates is at most xtol; info = 3 conditions for info = 1 and info = 2 both hold; info = 4 the cosine of the angle between fvec and any column of the jacobian is at most gtol in absolute value; info = 5 number of calls to lm_fcn has reached or exceeded maxfev; info = 6 ftol is too small: no further reduction in the sum of squares is possible; info = 7 xtol is too small: no further improvement in the approximate solution x is possible; info = 8 gtol is too small: fvec is orthogonal to the columns of the jacobian to machine precision; info =10 improper input parameters;
    private int[]
    ipvt is an integer OUTPUT array of length n.
    private final int
     
    private final int
     
    private final int
     
    private final int
     
    private final int
     
    private final int
     
    private final double
     
    private final String[]
    Set message texts (indexed by info)
    private final double
    resolution of arithmetic
    private final String[]
     
    private final double
    Square should not underflow
    private final double
    Square should not overflow
    private final double
     
    private int
    m is a positive integer input variable set to the number of functions.
    protected int
    maximum number of iterations
    private int
    maxfev is a positive integer input variable.
    private final int
     
    protected int
    mode is an integer input variable.
    private final int
     
    private int
    n is a positive integer variable set to the number of variables; n must not exceed m.
    protected int
    actual number of iterations
    private final int
     
    private final int
     
    private double[]
     
    private final int
     
    private final int
     
    protected int
    Bits ored to show where to output diagnostics
    private double[]
    qtf is an OUTPUT array of length n which contains the first n elements of the vector (q transpose)*fvec.
    private final int
     
    private int
     
    private boolean
     
    private double[]
    wa1, wa2, and wa3 are work arrays of length n.
    private double[]
     
    private double[]
     
    private double[]
    wa4 is a work array of length m, used among others to hold residuals from evaluate.
    private final int
     
    private final int
     
    protected double[]
    x is an array of length n.
    private double[]
     
    protected double
    xtol is a nonnegative input variable.
    private double[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    Lmmin(int m, int n)
     
    Lmmin(int m, int n, double[] x)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    driver.
    void
     
    private void
     
    abstract void
    fitToFunction(double[] x, double[] fvec, int[] info)
     
    private void
    fitToTestFunction(double[] par, double[] fvec)
    lm_enorm.
    double[]
     
    int
     
    (package private) double
    lm_enorm(int n, double[] x, int offset)
     
    private void
     
    private void
    lm_lmpar(int n, double[] r, int ldr, int[] ipvt, double[] diag, double[] qtb, double delta, double[] par, double[] x, double[] sdiag, double[] aux, double[] xdi)
     
    private void
    lm_printout_std(double[] par, double[] fvec, int printflags, int iflag, int iter, int nfev)
     
    private void
    lm_qrfac(int m, int n, double[] a, int pivot, int[] ipvt, double[] rdiag, double[] acnorm, double[] wa)
     
    private void
    lm_qrsolv(int n, double[] r, int ldr, int[] ipvt, double[] diag, double[] qtb, double[] x, double[] sdiag, double[] wa)
     
    private double
    shiftedChebyshev(double x, int n)
     
    void
    statusMessage(int status)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • testMode

      private boolean testMode
    • DBL_EPSILON

      private final double DBL_EPSILON
    • DBL_MIN

      private final double DBL_MIN
      2**-1022 = D1MACH(1).
    • DBL_MAX

      private final double DBL_MAX
      See Also:
    • LM_MACHEP

      private final double LM_MACHEP
      resolution of arithmetic
    • LM_DWARF

      private final double LM_DWARF
    • LM_SQRT_DWARF

      private final double LM_SQRT_DWARF
      Square should not underflow
    • LM_SQRT_GIANT

      private final double LM_SQRT_GIANT
      Square should not overflow
    • LM_USERTOL

      private final double LM_USERTOL
    • ftol

      protected double ftol
      ftol is a nonnegative input variable. Termination occurs when both the actual and predicted relative reductions in the sum of squares are at most ftol. Therefore, ftol measures the relative error desired in the sum of squares.
    • xtol

      protected double xtol
      xtol is a nonnegative input variable. Termination occurs when the relative error between two consecutive iterates is at most xtol. Therefore, xtol measures the relative error desired in the approximate solution.
    • gtol

      protected double gtol
      gtol is a nonnegative input variable. Termination occurs when the cosine of the angle between fvec and any column of the jacobian is at most gtol in absolute value. Therefore, gtol measures the orthogonality desired between the function vector and the columns of the jacobian.
    • epsfcn

      protected double epsfcn
      step used to calculate the jacobian epsfcn is an input variable used in choosing a step length for the forward-difference approximation. The relative errors in the functions are assumed to be of the order of epsfcn.
    • factor

      protected double factor
      initial bound to steps in the outer loop factor is a positive input variable used in determining the initial step bound. This bound is set to the product of factor and the euclidean norm of diag*x if nonzero, or else to factor itself. In most cases factor should lie in the interval (0.1,100.0). Generally, the value 100.0 is recommended.
    • maxcall

      protected int maxcall
      maximum number of iterations
    • maxfev

      private int maxfev
      maxfev is a positive integer input variable. Termination occurs when the number of calls to lm_fcn is at least maxfev by the end of an iteration.
    • mode

      protected int mode
      mode is an integer input variable. If mode = 1, the variables will be scaled internally. If mode = 2, the scaling is specified by the input diag.
    • printflags

      protected int printflags
      Bits ored to show where to output diagnostics
    • lm_infmsg

      private final String[] lm_infmsg
      Set message texts (indexed by info)
    • lm_shortmsg

      private final String[] lm_shortmsg
    • debugMessages

      protected boolean debugMessages
    • debugMatrix

      protected boolean debugMatrix
    • m

      private int m
      m is a positive integer input variable set to the number of functions.
    • n

      private int n
      n is a positive integer variable set to the number of variables; n must not exceed m.
    • x

      protected double[] x
      x is an array of length n. On input x must contain an initial estimate of the solution vector. On output x contains the final estimate of the solution vector.
    • fnorm

      protected double fnorm
      norm of the residue vector fvec
    • nfev

      protected int nfev
      actual number of iterations
    • info

      protected int[] info
      status of minimization info is an integer OUTPUT variable that indicates the termination status of lm_lmdif as follows: info invalid input: '<' 0 termination requested by user-supplied routine *evaluate; info = 0 fnorm almost vanishing; info = 1 both actual and predicted relative reductions in the sum of squares are at most ftol; info = 2 relative error between two consecutive iterates is at most xtol; info = 3 conditions for info = 1 and info = 2 both hold; info = 4 the cosine of the angle between fvec and any column of the jacobian is at most gtol in absolute value; info = 5 number of calls to lm_fcn has reached or exceeded maxfev; info = 6 ftol is too small: no further reduction in the sum of squares is possible; info = 7 xtol is too small: no further improvement in the approximate solution x is possible; info = 8 gtol is too small: fvec is orthogonal to the columns of the jacobian to machine precision; info =10 improper input parameters;
    • fvec

      private double[] fvec
      fvec is an output array of length m which contains the functions evaluated at the output x.
    • diag

      protected double[] diag
      diag is an array of length n. If mode = 1, diag is internally set. If mode = 2, diag must contain positive entries that serve as multiplicative scale factors for the variables.
    • qtf

      private double[] qtf
      qtf is an OUTPUT array of length n which contains the first n elements of the vector (q transpose)*fvec.
    • fjac

      private double[] fjac
      fjac is an OUTPUT m by n array. The upper n by n submatrix of fjac contains an upper triangular matrix r with diagonal elements of nonincreasing magnitude such that pT*(jacT*jac)*p = rT*r (NOTE: T stands for matrix transposition), where p is a permutation matrix and jac is the final calculated jacobian. Column j of p is column ipvt(j) (see below) of the identity matrix. The lower trapezoidal part of fjac contains information generated during the computation of r.
    • wa1

      private double[] wa1
      wa1, wa2, and wa3 are work arrays of length n.
    • wa2

      private double[] wa2
    • wa3

      private double[] wa3
    • wa4

      private double[] wa4
      wa4 is a work array of length m, used among others to hold residuals from evaluate.
    • ipvt

      private int[] ipvt
      ipvt is an integer OUTPUT array of length n. It defines a permutation matrix p such that jac*p = q*r, where jac is the final calculated jacobian, q is orthogonal (not stored), and r is upper triangular with diagonal elements of nonincreasing magnitude. Column j of p is column ipvt(j) of the identity matrix.
    • par

      private double[] par
    • testCase

      private int testCase
    • xSeries

      private double[] xSeries
    • ySeries

      private double[] ySeries
    • DRAPER24D

      private final int DRAPER24D
      See Also:
    • ROSENBROCK

      private final int ROSENBROCK
      See Also:
    • FREUDENSTEIN_AND_ROTH

      private final int FREUDENSTEIN_AND_ROTH
      See Also:
    • JENNRICH_AND_SAMPSON

      private final int JENNRICH_AND_SAMPSON
      See Also:
    • HELICAL_VALLEY

      private final int HELICAL_VALLEY
      See Also:
    • BARD

      private final int BARD
      See Also:
    • MEYER

      private final int MEYER
      See Also:
    • BOX_3D

      private final int BOX_3D
      See Also:
    • POWELL_SINGULAR

      private final int POWELL_SINGULAR
      See Also:
    • KOWALIK_AND_OSBORNE

      private final int KOWALIK_AND_OSBORNE
      See Also:
    • BROWN_AND_DENNIS

      private final int BROWN_AND_DENNIS
      See Also:
    • OSBORNE1

      private final int OSBORNE1
      See Also:
    • OSBORNE2

      private final int OSBORNE2
      See Also:
    • WATSON

      private final int WATSON
      See Also:
    • HOCK25

      private final int HOCK25
      See Also:
    • BROWN_ALMOST_LINEAR

      private final int BROWN_ALMOST_LINEAR
      See Also:
    • LINEAR_FULL_RANK

      private final int LINEAR_FULL_RANK
      See Also:
    • LINEAR_RANK1

      private final int LINEAR_RANK1
      See Also:
    • LINEAR_RANK1_WITH_ZERO_COLUMNS_AND_ROWS

      private final int LINEAR_RANK1_WITH_ZERO_COLUMNS_AND_ROWS
      See Also:
    • CHEBYQUAD

      private final int CHEBYQUAD
      See Also:
    • LEVMAR_ROSENBROCK

      private final int LEVMAR_ROSENBROCK
      See Also:
    • MODIFIED_ROSENBROCK

      private final int MODIFIED_ROSENBROCK
      See Also:
    • POWELL_2_PARAMETER

      private final int POWELL_2_PARAMETER
      See Also:
    • WOOD

      private final int WOOD
      See Also:
    • HOCK1

      private final int HOCK1
      See Also:
    • HOCK21_MODIFIED

      private final int HOCK21_MODIFIED
      See Also:
    • HATFLDB

      private final int HATFLDB
      See Also:
    • HATFLDC

      private final int HATFLDC
      See Also:
    • EQUILIBRIUM_COMBUSTION

      private final int EQUILIBRIUM_COMBUSTION
      See Also:
  • Constructor Details

    • Lmmin

      public Lmmin()
    • Lmmin

      public Lmmin(int m, int n)
      Parameters:
      m - the number of functions
      n - the number of variables; n must not exceed m.
    • Lmmin

      public Lmmin(int m, int n, double[] x)
      Parameters:
      m - the number of functions
      n - the number of variables; n must not exceed m.
      x -
  • Method Details

    • statusMessage

      public void statusMessage(int status)
    • getParameters

      public double[] getParameters()
    • fitTestModel

      private void fitTestModel()
    • dumpResults

      public void dumpResults()
    • getStatus

      public int getStatus()
    • driver

      public void driver()
      driver.
    • lm_lmdif

      private void lm_lmdif()
    • lm_qrfac

      private void lm_qrfac(int m, int n, double[] a, int pivot, int[] ipvt, double[] rdiag, double[] acnorm, double[] wa)
    • fitToFunction

      public abstract void fitToFunction(double[] x, double[] fvec, int[] info)
    • lm_printout_std

      private void lm_printout_std(double[] par, double[] fvec, int printflags, int iflag, int iter, int nfev)
    • lm_lmpar

      private void lm_lmpar(int n, double[] r, int ldr, int[] ipvt, double[] diag, double[] qtb, double delta, double[] par, double[] x, double[] sdiag, double[] aux, double[] xdi)
    • lm_qrsolv

      private void lm_qrsolv(int n, double[] r, int ldr, int[] ipvt, double[] diag, double[] qtb, double[] x, double[] sdiag, double[] wa)
    • lm_enorm

      double lm_enorm(int n, double[] x, int offset)
    • fitToTestFunction

      private void fitToTestFunction(double[] par, double[] fvec)
      lm_enorm.
    • shiftedChebyshev

      private double shiftedChebyshev(double x, int n)