naginterfaces.library.opt.bnd_​lin_​lsq

naginterfaces.library.opt.bnd_lin_lsq(a, b, bl, bu, itype=1, tol=0.0)[source]

bnd_lin_lsq solves a linear least squares problem subject to fixed lower and upper bounds on the variables.

For full information please refer to the NAG Library document for e04pc

https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/e04/e04pcf.html

Parameters
afloat, array-like, shape

The matrix .

bfloat, array-like, shape

The right-hand side vector .

blfloat, array-like, shape

and must specify the lower and upper bounds, and respectively, to be imposed on the solution vector .

bufloat, array-like, shape

and must specify the lower and upper bounds, and respectively, to be imposed on the solution vector .

itypeint, optional

Provides the choice of returning a regularized solution if the matrix is not of full rank.

Specifies that a regularized solution is to be computed.

Specifies that no regularization is to take place.

tolfloat, optional

specifies a parameter used to determine the relative linear dependence of a column vector for a variable moved from its initial value. It determines the computational rank of the matrix. Increasing its value from will increase the likelihood of additional elements of being set to zero. It may be worth experimenting with increasing values of to determine whether the nature of the solution, , changes significantly. In practice a value of is recommended (see machine.precision).

If on entry , is used.

Returns
afloat, ndarray, shape

If , contains the product matrix , where is an orthogonal matrix generated by bnd_lin_lsq; otherwise, is unchanged.

bfloat, ndarray, shape

If , the product of times the original vector , where is as described in argument ; otherwise, is unchanged.

xfloat, ndarray, shape

The solution vector .

rnormfloat

The Euclidean norm of the residual vector .

nfreeint

Indicates the number of components of the solution vector that are not at one of the constraints.

wfloat, ndarray, shape

Contains the dual solution vector. The magnitude of gives a measure of the improvement in the objective value if the corresponding bound were to be relaxed so that could take different values.

A value of equal to the special value is indicative of the matrix not having full rank.

It is only likely to occur when .

However a matrix may have less than full rank without being set to .

If , then the values contained in (other than those set to ) may be unreliable; the corresponding values in may likewise be unreliable.

If you have any doubts set .

Otherwise, the values of have the following meaning:

if is unconstrained.

if is constrained by its lower bound.

if is constrained by its upper bound.

may be any value if .

indxint, ndarray, shape

The contents of this array describe the components of the solution vector as follows:

, for

These elements of the solution have not hit a constraint; i.e., .

, for

These elements of the solution have been constrained by either the lower or upper bound.

, for

These elements of the solution are fixed by the bounds; i.e., .

Here is determined from and the number of fixed components. (Often the latter will be , so will be .)

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, when , and .

Constraint: .

(errno )

On entry, and .

Constraint: .

Warns
NagAlgorithmicMajorWarning
(errno )

The function failed to converge in iterations. This is not expected. Please contact NAG.

Notes

Given an matrix , an -vector of lower bounds, an -vector of upper bounds, and an -vector , bnd_lin_lsq computes an -vector that solves the least squares problem subject to satisfying .

A facility is provided to return a ‘regularized’ solution, which will closely approximate a minimal length solution whenever is not of full rank. A minimal length solution is the solution to the problem which has the smallest Euclidean norm.

The algorithm works by applying orthogonal transformations to the matrix and to the right-hand side to obtain within the matrix an upper triangular matrix . In general the elements of corresponding to the columns of will be the candidate nonzero solutions. If a diagonal element of is small compared to the other members of then this is undesirable. will be nearly singular and the equations for thus ill-conditioned. You may specify the tolerance used to determine the relative linear dependence of a column vector for a variable moved from its initial value.

References

Lawson, C L and Hanson, R J, 1974, Solving Least Squares Problems, Prentice–Hall