# 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://www.nag.com/numeric/nl/nagdoc_28.5/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 )

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 .