naginterfaces.library.fit.glinc_l1sol¶
- naginterfaces.library.fit.glinc_l1sol(m, e, f, x, mxs, monit, iprint, data=None)[source]¶
glinc_l1sol
calculates an solution to an overdetermined system of linear equations, possibly subject to linear inequality constraints.For full information please refer to the NAG Library document for e02gb
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/e02/e02gbf.html
- Parameters
- mint
The number of equations in the overdetermined system, (i.e., the number of rows of the matrix ).
- efloat, array-like, shape
The equation and constraint matrices stored in the following manner.
The first columns contain the rows of the matrix ; element specifying the element in the th row and th column of (the coefficient of the th unknown in the th equation), for , for .
The next columns contain the rows of the constraint matrix ; element containing the element in the th row and th column of (the coefficient of the th unknown in the th constraint), for , for .
- ffloat, array-like, shape
, for , must contain (the th element of the right-hand side vector of the overdetermined system of equations) and , for , must contain (the th element of the right-hand side vector of the constraints), where is the number of constraints.
- xfloat, array-like, shape
must contain an estimate of the th unknown, for . If no better initial estimate for is available, set .
- mxsint
The maximum number of steps to be allowed for the solution of the unconstrained problem. Typically this may be a modest multiple of . If, on entry, is zero or negative, the value returned by
machine.integer_max
is used.- monitcallable monit(x, niter, k, el1n, data=None)
can be used to print out the current values of any selection of its arguments.
The frequency with which is called in
glinc_l1sol
is controlled by .- Parameters
- xfloat, ndarray, shape
The latest estimate of the unknowns.
- niterint
The number of iterations so far carried out.
- kint
The total number of equations and constraints which are currently active (i.e., the number of equations with zero residuals plus the number of constraints which are satisfied as equations).
- el1nfloat
The -norm of the current residuals of the overdetermined system of equations.
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- iprintint
The frequency of iteration print out.
is called every iterations and at the solution.
Information is printed out at the solution only. Otherwise is not called.
- dataarbitrary, optional
User-communication data for callback functions.
- Returns
- efloat, ndarray, shape
Unchanged, except possibly to the extent of a small multiple of the machine precision. (See Further Comments.)
- xfloat, ndarray, shape
The latest estimate of the th unknown, for . If no exception or warning is raised on exit, these are the solution values.
- kint
The total number of equations and constraints which are then active (i.e., the number of equations with zero residuals plus the number of constraints which are satisfied as equalities).
- el1nfloat
The -norm (sum of absolute values) of the equation residuals.
- indxint, ndarray, shape
Specifies which columns of relate to the inactive equations and constraints. up to number the active columns and up to number the inactive columns.
- Raises
- NagValueError
- (errno )
The constraints cannot all be satisfied simultaneously: they are not compatible with one another. Hence no solution is possible.
- (errno )
The limit imposed by has been reached without finding a solution. Consider restarting from the current point by simply calling
glinc_l1sol
again without changing the arguments.- (errno )
The function has failed because of numerical difficulties; the problem is too ill-conditioned. Consider rescaling the unknowns.
- (errno )
Elements to of one of the first columns of the array are all zero – this corresponds to a zero row in either of the matrices or .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, .
Constraint: .
- Notes
No equivalent traditional C interface for this routine exists in the NAG Library.
Given a matrix with rows and columns and a vector with elements, the function calculates an solution to the overdetermined system of equations
That is to say, it calculates a vector , with elements, which minimizes the -norm (the sum of the absolute values) of the residuals
where the residuals are given by
Here is the element in row and column of , is the th element of and the th element of .
If, in addition, a matrix with rows and columns and a vector with elements, are given, the vector computed by the function is such as to minimize the -norm subject to the set of inequality constraints .
The matrices and need not be of full rank.
Typically in applications to data fitting, data consisting of points with coordinates is to be approximated by a linear combination of known functions ,
in the -norm, possibly subject to linear inequality constraints on the coefficients of the form where is the vector of the and and are as in the previous paragraph. This is equivalent to finding an solution to the overdetermined system of equations
subject to .
Thus if, for each value of and , the element of the matrix above is set equal to the value of and is equal to and and are also supplied to the function, the solution vector will contain the required values of the . Note that the independent variable above can, instead, be a vector of several independent variables (this includes the case where each of is a function of a different variable, or set of variables).
The algorithm follows the Conn–Pietrzykowski approach (see Bartels et al. (1978) and Conn and Pietrzykowski (1977)), which is via an exact penalty function
where is a penalty argument, is the th row of the matrix , and is the th element of the vector . It proceeds in a step-by-step manner much like the simplex method for linear programming but does not move from vertex to vertex and does not require the problem to be cast in a form containing only non-negative unknowns. It uses stable procedures to update an orthogonal factorization of the current set of active equations and constraints.
- References
Bartels, R H, Conn, A R and Charalambous, C, 1976, Minimisation techniques for piecewise Differentiable functions – the solution to an overdetermined linear system, Technical Report No. 247, CORR 76/30, Mathematical Sciences Department, The John Hopkins University
Bartels, R H, Conn, A R and Sinclair, J W, 1976, A Fortran program for solving overdetermined systems of linear equations in the Sense, Technical Report No. 236, CORR 76/7, Mathematical Sciences Department, The John Hopkins University
Bartels, R H, Conn, A R and Sinclair, J W, 1978, Minimisation techniques for piecewise differentiable functions – the solution to an overdetermined linear system, SIAM J. Numer. Anal. (15), 224–241
Conn, A R and Pietrzykowski, T, 1977, A penalty-function method converging directly to a constrained optimum, SIAM J. Numer. Anal. (14), 348–375