>  Docs Center  >  IDL Reference  >  Advanced Math and Stats  >  IMSL_LINLSQ

IMSL_LINLSQ

IMSL_LINLSQ

The IMSL_LINLSQ function solves a linear least-squares problem with linear constraints.

This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.

The IMSL_LINLSQ function solves linear least-squares problems with linear constraints. These are systems of least-squares equations of the form:

Ax ≅ b

subject to

bl ≤ Cx ≤ bu

xl ≤ x ≤ xu

Here A is the coefficient matrix of the least-squares equations, b is the right-hand side, and C is the coefficient matrix of the constraints. The vectors bl, bu, xl and xu are the lower and upper bounds on the constraints and the variables, respectively. The system is solved by defining dependent variables y ≡ Cx and then solving the leastsquares system with the lower and upper bounds on x and y. The equation Cx − y = 0 is a set of equality constraints. These constraints are realized by heavy weighting, i.e., a penalty method, Hanson (1986, pp. 826-834).

Examples


Example 1

This example solves the following problem in the least-squares sense:

a = TRANSPOSE([[3.0, 2.0, 1.0], [4.0, 2.0, 1.0], $
[2.0, 2.0, 1.0], [1.0, 1.0, 1.0]])
b = [3.3, 2.3, 1.3, 1.0]
c = [[1.0], [1.0], [1.0]]
xub = [0.5, 0.5, 0.5]
xlb = [0.0, 0.0, 0.0]
contype = [1]
bc = [1.0]
; Note that only upper bound is set for contype =1.
sol = IMSL_LINLSQ(b, a, c, bc, bc, contype, Xlb = xlb, Xub = xub)
PM, sol, Title = 'Solution'
  0.500000
  0.300000
  0.200000

Example 2

The same problem solved in the first example is solved again. This time residuals of the least-squares equations at the approximate solution are returned, and the norm of the residual vector is printed.

a = TRANSPOSE([[3.0, 2.0, 1.0], [4.0, 2.0, 1.0], $
[2.0, 2.0, 1.0], [1.0, 1.0, 1.0]])
b = [3.3, 2.3, 1.3, 1.0]
c = [[1.0], [1.0], [1.0]]
xub = [0.5, 0.5, 0.5]
xlb = [0.0, 0.0, 0.0]
contype = [1]
bc = [1.0]
sol = IMSL_LINLSQ(b, a, c, bc, bc, contype, Xlb = xlb, $
Xub = xub, Residual = residual)
PM, sol, Title = 'Solution'
Solution
  0.500000
  0.300000
  0.200000
PM, residual, Title = 'Residual'
Residual
  -1.00000
  0.500000
  0.500000
  0.00000
PRINT, 'Norm of Residual =', IMSL_NORM(residual)
Norm of Residual = 1.22474

Syntax


Result = IMSL_LINLSQ( B, A, C, Bl, Bu, Contype [, ABS_TOLERANCE=value] [, /DOUBLE] [, ITMAX=value] [, REL_TOLERANCE=value] [, RESIDUAL=variable] [, XLB=array] [, XUB=array])

Return Value


One-dimensional array of length nca containing the approximate solution.

Arguments


A

Two-dimensional array of size nra by nca containing the coefficients of the leastsquares equations, where nra is the number of least-squares equations and nca is the number of variables.

B

One-dimensional array of length nra containing the right-hand sides of the least squares equations.

C

Two-dimensional array of size ncon by nca containing the coefficients of the constraints, where ncon is the number of constraints.

Bl

One-dimensional array of length ncon containing the lower limit of the general constraints. If there is no lower limit on the i-th constraint, then bl(i) will not be referenced.

Bu

One-dimensional array of length ncon containing the upper limit of the general constraints. If there is no upper limit on the i-th constraint, then bu(i) will not be referenced.

Ccontype

One-dimensional array of length ncon indicating the type of constraints exclusive of simple bounds, where CONTYPE(i) = 0, 1, 2, 3 indicates =, ≤, ≥, and range constraints, respectively.

Keywords


ABS_TOLERANCE (optional)

Absolute rank determination tolerance to be used. Default: SQRT(machine epsilon).

DOUBLE (optional)

If present and nonzero, double precision is used.

ITMAX (optional)

Set the maximum number of iterations. Default: 5*max(nra, nca)

REL_TOLERANCE (optional)

Relative rank determination tolerance to be used. Default: SQRT(machine epsilon).

RESIDUAL (optional)

Named variable into which an one-dimensional array containing the residuals b − Ax of the least-squares equations at the approximate solution is stored.

XLB (optional)

One-dimensional array of length nca containing the lower bound on the variables. If there is no lower bound on the i-th variable, then Xlb(i) should be set to 1.0e30.

XUB (optional)

One-dimensional array of length nca containing the upper bound on the variables. If there is no upper bound on the i-th variable, then XUB(i) should be set to −1.0e30.

Version History


6.4

Introduced

See Also


IMSL_CHNNDFAC, IMSL_CHNNDSOL, IMSL_QRFAC, IMSL_SVDCOMP



© 2019 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us