e04pc solves a linear least squares problem subject to fixed lower and upper bounds on the variables.
Syntax
C# |
---|
public static void e04pc( int itype, int m, int n, double[,] a, double[] b, double[] bl, double[] bu, double tol, double[] x, out double rnorm, out int nfree, double[] w, int[] indx, out int ifail ) |
Visual Basic |
---|
Public Shared Sub e04pc ( _ itype As Integer, _ m As Integer, _ n As Integer, _ a As Double(,), _ b As Double(), _ bl As Double(), _ bu As Double(), _ tol As Double, _ x As Double(), _ <OutAttribute> ByRef rnorm As Double, _ <OutAttribute> ByRef nfree As Integer, _ w As Double(), _ indx As Integer(), _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void e04pc( int itype, int m, int n, array<double,2>^ a, array<double>^ b, array<double>^ bl, array<double>^ bu, double tol, array<double>^ x, [OutAttribute] double% rnorm, [OutAttribute] int% nfree, array<double>^ w, array<int>^ indx, [OutAttribute] int% ifail ) |
F# |
---|
static member e04pc : itype : int * m : int * n : int * a : float[,] * b : float[] * bl : float[] * bu : float[] * tol : float * x : float[] * rnorm : float byref * nfree : int byref * w : float[] * indx : int[] * ifail : int byref -> unit |
Parameters
- itype
- Type: System..::..Int32On entry: 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.
Suggested value: unless there is a definite need for a minimal length solution we recommend that is used.Constraint: or .
- m
- Type: System..::..Int32On entry: , the number of linear equations.Constraint: .
- n
- Type: System..::..Int32On entry: , the number of variables.Constraint: .
- a
- Type: array<System..::..Double,2>[,](,)[,][,]An array of size [dim1, dim2]Note: dim1 must satisfy the constraint:Note: the second dimension of the array a must be at least .On entry: the by matrix .
- b
- Type: array<System..::..Double>[]()[][]An array of size [m]On entry: the right-hand side vector .
- bl
- Type: array<System..::..Double>[]()[][]An array of size [n]On entry: and must specify the lower and upper bounds, and respectively, to be imposed on the solution vector .Constraint: , for .
- bu
- Type: array<System..::..Double>[]()[][]An array of size [n]On entry: and must specify the lower and upper bounds, and respectively, to be imposed on the solution vector .Constraint: , for .
- tol
- Type: System..::..DoubleOn 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 will increase the likelihood of additional elements of being set to zero. It may be worth experimenting with increasing values of tol to determine whether the nature of the solution, , changes significantly. In practice a value of is recommended (see x02aj).If on entry , then is used.Suggested value:
- x
- Type: array<System..::..Double>[]()[][]An array of size [n]On exit: the solution vector .
- rnorm
- Type: System..::..Double%On exit: the Euclidean norm of the residual vector .
- nfree
- Type: System..::..Int32%On exit: indicates the number of components of the solution vector that are not at one of the constraints.
- w
- Type: array<System..::..Double>[]()[][]An array of size [n]On exit: 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 w (other than those set to ) may be unreliable; the corresponding values in indx 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 .
- indx
- Type: array<System..::..Int32>[]()[][]An array of size [n]On exit: 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 nfree and the number of fixed components. (Often the latter will be , so will be .)
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
Given an by matrix , an -vector of lower bounds, an -vector of upper bounds, and an -vector , e04pc 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 non-zero 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
Error Indicators and Warnings
Note: e04pc may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface
(LDA) In these
cases, an error in another parameter has usually caused an incorrect value to be inferred.
- One of the following input errors has occurred:
- ,
- ,
- ,
- for at least one value of .
- The routine failed to converge in iterations. This is not expected. Please contact NAG.
Accuracy
Orthogonal rotations are used.
Parallelism and Performance
None.
Further Comments
Example
The example minimizes where
and
subject to .
Example program (C#): e04pce.cs