NLSL
lmnls.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine lmnls (fcn, m, n, x, fvec, fjac, ldfjac, ftol, xtol, gtol, maxfev, maxitr, diag, scale, factor, nprint, info, nfev, njev, ipvt, qtf, gnvec, gradf, wa1, wa2, wa3, wa4)
 

(L)evenberg-(M)arquardt (N)onlinear (L)east (S)quares

This is a modification of the original lmder subroutine from the MINPACK subroutine library. It uses a Levenberg-Marquardt nonlinear least-squares algorithm modified to carry out a local optimization constrained to lie within a "trust region" defined by a step bound delta using scaling of the variables. More...
 

Function/Subroutine Documentation

subroutine lmnls ( external  fcn,
integer  m,
integer  n,
double precision, dimension(n)  x,
double precision, dimension(m)  fvec,
double precision, dimension(ldfjac,njcol)  fjac,
integer  ldfjac,
double precision  ftol,
double precision  xtol,
double precision  gtol,
integer  maxfev,
integer  maxitr,
double precision, dimension(njcol)  diag,
double precision, dimension(njcol)  scale,
double precision  factor,
integer  nprint,
integer  info,
integer  nfev,
integer  njev,
integer, dimension(n)  ipvt,
double precision, dimension(njcol)  qtf,
double precision, dimension(njcol)  gnvec,
double precision, dimension(njcol)  gradf,
double precision, dimension(njcol)  wa1,
double precision, dimension(njcol)  wa2,
double precision, dimension(njcol)  wa3,
double precision, dimension(m)  wa4 
)

(L)evenberg-(M)arquardt (N)onlinear (L)east (S)quares

This is a modification of the original lmder subroutine from the MINPACK subroutine library. It uses a Levenberg-Marquardt nonlinear least-squares algorithm modified to carry out a local optimization constrained to lie within a "trust region" defined by a step bound delta using scaling of the variables.

For a description of the trust region approach for least squares problems, see J.E. Dennis and R.B. Schnabel, Numerical Methods for Unconstrained Optimization and Nonlinear Equations, Prentice-Hall, Englewood Cliffs, NJ (1983), sections 6.4, 7.1, and 10.2.

The purpose of LMDER is to minimize the sum of the squares of
m nonlinear functions in n variables by a modification of
the Levenberg-Marquardt algorithm. The user must provide a
subroutine which calculates the functions and the Jacobian.

The subroutine statement is

  subroutine lmnls(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol,
                   maxfev,maxitr,diag,scale,factor,nprint,info,
                   nfev,njev,ipvt,qtf,wa1,wa2,wa3,wa4) 
Parameters
FCNis the name of the user-supplied subroutine which calculates the functions and the Jacobian. FCN must be declared in an external statement in the user calling program, and should be written as follows:
 subroutine fcn(m,n,x,fvec,fjac,ldfjac,iflag)
 integer m,n,ldfjac,iflag
 double precision x(n),fvec(m),fjac(ldfjac,n)
 ----------
 If iflag=1 calculate the functions at x and
 return this vector in fvec. Do not alter fjac.
 If iflag=2 calculate the Jacobian at x and
 return this matrix in fjac. Do not alter fvec.
 ----------
 return
 end

The value of IFLAG should not be changed by FCN unless the user wants to terminate execution of LMDER. In this case set iflag to a negative integer.
Mis a positive integer input variable set to the number of functions.
Nis a positive integer input variable set to the number of variables. N must not exceed M.
Xis 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.
FVECis an output array of length M which contains the functions evaluated at the output X.
FJACis 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
        T     T           T
       P *(JAC *JAC)*P = R *R,

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.
LDFJACis a positive integer input variable not less than M which specifies the leading dimension of the array FJAC.
FTOLis 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.
XTOLis 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.
GTOLis 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.
MAXFEVis a positive integer input variable. Termination occurs when the number of calls to FCN with IFLAG=1 has reached MAXFEV.
SCALEis an array of length N containing multiplicative scale factors for each of the variables in X. If an element of SCALE is non-positive, it will be reset internally to unity. Positive entries in the SCALE array will be retained as user-specified scaling factors for the trust-region search of the algorithm. The step for the Ith parameter will be scaled using the norm of the Ith column of the Jacobian divided by SCALE(I). This produces larger steps along the ith dimension, at least initialy. The default value for all parameters is unity (i.e., the column norms of the Jacobian will be used).

NB: This convention differs from the original specifications of LMDER in MINPACK.

FACTORis a positive input variable used in determining the initial trust region 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 (.1,100.). 100 is a generally recommended value.
NPRINTis an integer input variable that enables controlled printing of iterates if it is positive. In this case, fcn is called with IFLAG=0 at the beginning of the first iteration and every NPRINT iterations thereafter and immediately prior to return, with X, FVEC, and FJAC available for printing. FVEC and FJAC should not be altered. If NPRINT is not positive, no special calls of FCN with IFLAG=0 are made.
INFO

is an integer output variable. If the user has terminated execution, INFFO is set to the (negative) value of IFLAG. See description of FCN. Otherwise, INFO is set as follows:

INFO=0 Improper input parameters.

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 FCN with IFLAG=1 has reached 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.

NFEVis an integer output variable set to the number of calls to FCN with IFLAG=1.
NJEVis an integer output variable set to the number of calls to NJEV with IFLAG=2.
IPVTis an integer output array of length N. IPVT 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.
QTFis an output array of length N which contains the first N elements of the vector (Q transpose)*FVEC.
WA1,WA2,andWA3 are work arrays of length N.
WA4is a work array of length M.

Definition at line 23 of file lmnls.f90.

Here is the call graph for this function:

Here is the caller graph for this function: