Package gov.nih.mipav.model.algorithms
Class Lmmin
java.lang.Object
gov.nih.mipav.model.algorithms.Lmmin
- Direct Known Subclasses:
AlgorithmELSUNCOpt2D.FitOAR2DLMModel,AlgorithmELSUNCOpt3D.FitOAR3DLMModel
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
FieldsModifier and TypeFieldDescriptionprivate final intprivate final intprivate final intprivate final intprivate final intprivate final doubleprivate final doubleprivate final double2**-1022 = D1MACH(1).protected booleanprotected booleanprotected double[]diag is an array of length n.private final intprotected doublestep used to calculate the jacobian epsfcn is an input variable used in choosing a step length for the forward-difference approximation.private final intprotected doubleinitial 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 doublenorm of the residue vector fvecprivate final intprotected doubleftol 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 doublegtol is a nonnegative input variable.private final intprivate final intprivate final intprivate final intprivate final intprivate final intprotected 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 intprivate final intprivate final intprivate final intprivate final intprivate final intprivate final doubleprivate final String[]Set message texts (indexed by info)private final doubleresolution of arithmeticprivate final String[]private final doubleSquare should not underflowprivate final doubleSquare should not overflowprivate final doubleprivate intm is a positive integer input variable set to the number of functions.protected intmaximum number of iterationsprivate intmaxfev is a positive integer input variable.private final intprotected intmode is an integer input variable.private final intprivate intn is a positive integer variable set to the number of variables; n must not exceed m.protected intactual number of iterationsprivate final intprivate final intprivate double[]private final intprivate final intprotected intBits ored to show where to output diagnosticsprivate double[]qtf is an OUTPUT array of length n which contains the first n elements of the vector (q transpose)*fvec.private final intprivate intprivate booleanprivate 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 intprivate final intprotected double[]x is an array of length n.private double[]protected doublextol is a nonnegative input variable.private double[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddriver()driver.voidprivate voidabstract voidfitToFunction(double[] x, double[] fvec, int[] info) private voidfitToTestFunction(double[] par, double[] fvec) lm_enorm.double[]int(package private) doublelm_enorm(int n, double[] x, int offset) private voidlm_lmdif()private voidlm_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 voidlm_printout_std(double[] par, double[] fvec, int printflags, int iflag, int iter, int nfev) private voidlm_qrfac(int m, int n, double[] a, int pivot, int[] ipvt, double[] rdiag, double[] acnorm, double[] wa) private voidlm_qrsolv(int n, double[] r, int ldr, int[] ipvt, double[] diag, double[] qtb, double[] x, double[] sdiag, double[] wa) private doubleshiftedChebyshev(double x, int n) voidstatusMessage(int status)
-
Field Details
-
testMode
private boolean testMode -
DBL_EPSILON
private final double DBL_EPSILON -
DBL_MIN
private final double DBL_MIN2**-1022 = D1MACH(1). -
DBL_MAX
private final double DBL_MAX- See Also:
-
LM_MACHEP
private final double LM_MACHEPresolution of arithmetic -
LM_DWARF
private final double LM_DWARF -
LM_SQRT_DWARF
private final double LM_SQRT_DWARFSquare should not underflow -
LM_SQRT_GIANT
private final double LM_SQRT_GIANTSquare should not overflow -
LM_USERTOL
private final double LM_USERTOL -
ftol
protected double ftolftol 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 xtolxtol 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 gtolgtol 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 epsfcnstep 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 factorinitial 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 maxcallmaximum number of iterations -
maxfev
private int maxfevmaxfev 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 modemode 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 printflagsBits ored to show where to output diagnostics -
lm_infmsg
Set message texts (indexed by info) -
lm_shortmsg
-
debugMessages
protected boolean debugMessages -
debugMatrix
protected boolean debugMatrix -
m
private int mm is a positive integer input variable set to the number of functions. -
n
private int nn is a positive integer variable set to the number of variables; n must not exceed m. -
x
protected double[] xx 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 fnormnorm of the residue vector fvec -
nfev
protected int nfevactual number of iterations -
info
protected int[] infostatus 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[] fvecfvec is an output array of length m which contains the functions evaluated at the output x. -
diag
protected double[] diagdiag 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[] qtfqtf is an OUTPUT array of length n which contains the first n elements of the vector (q transpose)*fvec. -
fjac
private double[] fjacfjac 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[] wa1wa1, wa2, and wa3 are work arrays of length n. -
wa2
private double[] wa2 -
wa3
private double[] wa3 -
wa4
private double[] wa4wa4 is a work array of length m, used among others to hold residuals from evaluate. -
ipvt
private int[] ipvtipvt 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 functionsn- the number of variables; n must not exceed m.
-
Lmmin
public Lmmin(int m, int n, double[] x) - Parameters:
m- the number of functionsn- 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)
-