E04PCF (PDF version)
E04 Chapter Contents
E04 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

E04PCF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

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

2  Specification

SUBROUTINE E04PCF ( ITYPE, M, N, A, LDA, B, BL, BU, TOL, X, RNORM, NFREE, W, INDX, IFAIL)
INTEGER  ITYPE, M, N, LDA, NFREE, INDX(N), IFAIL
REAL (KIND=nag_wp)  A(LDA,*), B(M), BL(N), BU(N), TOL, X(N), RNORM, W(N)

3  Description

Given an m by n matrix A, an n-vector l of lower bounds, an n-vector u of upper bounds, and an m-vector b, E04PCF computes an n-vector x that solves the least squares problem Ax=b subject to xi satisfying li xi ui .
A facility is provided to return a ‘regularized’ solution, which will closely approximate a minimal length solution whenever A 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 R. In general the elements of x corresponding to the columns of R will be the candidate nonzero solutions. If a diagonal element of R is small compared to the other members of R then this is undesirable. R will be nearly singular and the equations for x 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.

4  References

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

5  Arguments

1:     ITYPE – INTEGERInput
On entry: provides the choice of returning a regularized solution if the matrix is not of full rank.
ITYPE=0
Specifies that a regularized solution is to be computed.
ITYPE=1
Specifies that no regularization is to take place.
Suggested value: unless there is a definite need for a minimal length solution we recommend that ITYPE=1 is used.
Constraint: ITYPE=0 or 1.
2:     M – INTEGERInput
On entry: m, the number of linear equations.
Constraint: M0.
3:     N – INTEGERInput
On entry: n, the number of variables.
Constraint: N0.
4:     ALDA* – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array A must be at least N.
On entry: the m by n matrix A.
On exit: if ITYPE=1, A contains the product matrix QA, where Q is an m by m orthogonal matrix generated by E04PCF; otherwise A is unchanged.
5:     LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which E04PCF is called.
Constraint: LDAM.
6:     BM – REAL (KIND=nag_wp) arrayInput/Output
On entry: the right-hand side vector b.
On exit: if ITYPE=1, the product of Q times the original vector b, where Q is as described in argument A; otherwise B is unchanged.
7:     BLN – REAL (KIND=nag_wp) arrayInput
8:     BUN – REAL (KIND=nag_wp) arrayInput
On entry: BLi and BUi must specify the lower and upper bounds, li and ui respectively, to be imposed on the solution vector xi.
Constraint: BLi BUi, for i=1,2,,N.
9:     TOL – REAL (KIND=nag_wp)Input
On entry: TOL 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 machine precision will increase the likelihood of additional elements of x being set to zero. It may be worth experimenting with increasing values of TOL to determine whether the nature of the solution, x, changes significantly. In practice a value of machine precision is recommended (see X02AJF).
If on entry TOL<machine precision, then machine precision is used.
Suggested value: TOL=0.0
10:   XN – REAL (KIND=nag_wp) arrayOutput
On exit: the solution vector x.
11:   RNORM – REAL (KIND=nag_wp)Output
On exit: the Euclidean norm of the residual vector b-Ax.
12:   NFREE – INTEGEROutput
On exit: indicates the number of components of the solution vector that are not at one of the constraints.
13:   WN – REAL (KIND=nag_wp) arrayOutput
On exit: contains the dual solution vector. The magnitude of Wi gives a measure of the improvement in the objective value if the corresponding bound were to be relaxed so that xi could take different values.
A value of Wi equal to the special value -999.0 is indicative of the matrix A not having full rank. It is only likely to occur when ITYPE=1. However a matrix may have less than full rank without Wi being set to -999.0. If ITYPE=1 then the values contained in W (other than those set to -999.0) may be unreliable; the corresponding values in INDX may likewise be unreliable. If you have any doubts set ITYPE=0. Otherwise the values of Wi have the following meaning:
Wi=0
if xi is unconstrained.
Wi<0
if xi is constrained by its lower bound.
Wi>0
if xi is constrained by its upper bound.
Wi
may be any value if li=ui.
14:   INDXN – INTEGER arrayOutput
On exit: the contents of this array describe the components of the solution vector as follows:
INDXi, for i=1,2,,NFREE
These elements of the solution have not hit a constraint; i.e., Wi=0.
INDXi, for i=NFREE+1,,k
These elements of the solution have been constrained by either the lower or upper bound.
INDXi, for i=k+1 ,,N
These elements of the solution are fixed by the bounds; i.e., BLi=BUi.
Here k is determined from NFREE and the number of fixed components. (Often the latter will be 0, so k will be N-NFREE.)
15:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, because for this routine the values of the output arguments may be useful even if IFAIL0 on exit, the recommended value is -1. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Note: E04PCF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
IFAIL=1
On entry, M=value.
Constraint: M0.
On entry, M=value and LDA=value.
Constraint: LDAM.
On entry, N=value.
Constraint: N0.
On entry, when i=value, BLi=value and BUi=value.
Constraint: BLiBUi.
IFAIL=2
The routine failed to converge in 3×n iterations. This is not expected. Please contact NAG.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7  Accuracy

Orthogonal rotations are used.

8  Parallelism and Performance

E04PCF makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9  Further Comments

If either M or N is zero on entry then E04PCF sets IFAIL=0 and simply returns without setting any other output arguments.

10  Example

The example minimizes Ax-b2  where
A = 0.05 0.05 0.25 -0.25 0.25 0.25 0.05 -0.05 0.35 0.35 1.75 -1.75 1.75 1.75 0.35 -0.35 0.30 -0.30 0.30 0.30 0.40 -0.40 0.40 0.40  
and
b = 1.0 2.0 3.0 4.0 5.0 6.0 T  
subject to 1x5.

10.1  Program Text

Program Text (e04pcfe.f90)

10.2  Program Data

Program Data (e04pcfe.d)

10.3  Program Results

Program Results (e04pcfe.r)


E04PCF (PDF version)
E04 Chapter Contents
E04 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2016