E04 Chapter Contents
E04 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentE04NQF

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.
Note: this routine uses optional parameters to define choices in the problem specification and in the details of the algorithm. If you wish to use default settings for all of the optional parameters, you need only read Sections 1 to 9 of this document. If, however, you wish to reset some or all of the settings please refer to Section 10 for a detailed description of the algorithm, to Section 11 for a detailed description of the specification of the optional parameters and to Section 12 for a detailed description of the monitoring information produced by the routine.

## 1  Purpose

E04NQF solves sparse linear programming or convex quadratic programming problems. The initialization routine E04NPF must have been called before calling E04NQF.

## 2  Specification

 SUBROUTINE E04NQF ( START, QPHX, M, N, NE, NNAME, LENC, NCOLH, IOBJ, OBJADD, PROB, ACOL, INDA, LOCA, BL, BU, C, NAMES, HELAST, HS, X, PI, RC, NS, NINF, SINF, OBJ, CW, LENCW, IW, LENIW, RW, LENRW, CUSER, IUSER, RUSER, IFAIL)
 INTEGER M, N, NE, NNAME, LENC, NCOLH, IOBJ, INDA(NE), LOCA(N+1), HELAST(N+M), HS(N+M), NS, NINF, LENCW, IW(LENIW), LENIW, LENRW, IUSER(*), IFAIL REAL (KIND=nag_wp) OBJADD, ACOL(NE), BL(N+M), BU(N+M), C(max(1,LENC)), X(N+M), PI(M), RC(N+M), SINF, OBJ, RW(LENRW), RUSER(*) CHARACTER(1) START CHARACTER(8) PROB, NAMES(NNAME), CW(LENCW), CUSER(*) EXTERNAL QPHX
Before calling E04NQF or one of the option setting routines E04NRF, E04NSF, E04NTF or E04NUF, E04NPF must be called.
The specification for E04NPF is:
 SUBROUTINE E04NPF ( CW, LENCW, IW, LENIW, RW, LENRW, IFAIL)
 INTEGER LENCW, IW(LENIW), LENIW, LENRW, IFAIL REAL (KIND=nag_wp) RW(LENRW) CHARACTER(8) CW(LENCW)
LENCW, LENIW and LENRW, the declared lengths of CW, IW and RW respectively, must satisfy:
• ${\mathbf{LENCW}}\ge 600$
• ${\mathbf{LENIW}}\ge 600$
• ${\mathbf{LENRW}}\ge 600$
The contents of the arrays CW, IW and RW must not be altered between calling routines E04NPF, E04NQF, E04NRF, E04NSF, E04NTF and E04NUF.
After calling E04NQF you can call one or both of the routines E04NXF or E04NYF to obtain the current value of an optional parameter.

## 3  Description

E04NQF is designed to solve large-scale linear or quadratic programming problems of the form:
 $minimize x∈Rn fx subject to ​ l≤ x Ax ≤u,$ (1)
where $x$ is an $n$-vector of variables, $l$ and $u$ are constant lower and upper bounds, $A$ is an $m$ by $n$ sparse matrix and $f\left(x\right)$ is a linear or quadratic objective function that may be specified in a variety of ways, depending upon the particular problem being solved. The optional parameter Maximize may be used to specify a problem in which $f\left(x\right)$ is maximized instead of minimized.
Upper and lower bounds are specified for all variables and constraints. This form allows full generality in specifying various types of constraint. In particular, the $j$th constraint may be defined as an equality by setting ${l}_{j}={u}_{j}$. If certain bounds are not present, the associated elements of $l$ or $u$ may be set to special values that are treated as $-\infty$ or $+\infty$.
The possible forms for the function $f\left(x\right)$ are summarised in Table 1. The most general form for $f\left(x\right)$ is
 $fx = q + cTx + 12 xTHx = q + ∑ j=1 n cj xj + 12 ∑ i=1 n ∑ j=1 n xi Hij xj$
where $q$ is a constant, $c$ is a constant $n$-vector and $H$ is a constant symmetric $n$ by $n$ matrix with elements $\left\{{H}_{ij}\right\}$. In this form, $f$ is a quadratic function of $x$ and (1) is known as a quadratic program (QP). E04NQF is suitable for all convex quadratic programs. The defining feature of a convex QP is that the matrix $H$ must be positive semidefinite, i.e., it must satisfy ${x}^{\mathrm{T}}Hx\ge 0$ for all $x$. If not, $f\left(x\right)$ is nonconvex and E04NQF will terminate with the error indicator ${\mathbf{IFAIL}}={\mathbf{11}}$. If $f\left(x\right)$ is nonconvex it may be more appropriate to call E04VHF instead.
 Problem type Objective function $f\left(x\right)$ Hessian matrix $H$ FP Not applicable $q=c=H=0$ LP $q+{c}^{\mathrm{T}}x$ $H=0$ QP $q+{c}^{\mathrm{T}}x+\frac{1}{2}{x}^{\mathrm{T}}Hx$ Symmetric positive semidefinite
Table 1
Choices for the objective function $f\left(x\right)$
If $H=0$, then $f\left(x\right)=q+{c}^{\mathrm{T}}x$ and the problem is known as a linear program (LP). In this case, rather than defining an $H$ with zero elements, you can define $H$ to have no columns by setting ${\mathbf{NCOLH}}=0$ (see Section 5).
If $H=0$, $q=0$, and $c=0$, there is no objective function and the problem is a feasible point problem (FP), which is equivalent to finding a point that satisfies the constraints on $x$. In the situation where no feasible point exists, several options are available for finding a point that minimizes the constraint violations (see the description of the optional parameter Elastic Mode).
E04NQF is suitable for large LPs and QPs in which the matrix $A$ is sparse, i.e., when the number of zero elements is sufficiently large that it is worthwhile using algorithms which avoid computations and storage involving zero elements. The matrix $A$ is input to E04NQF by means of the three array parameters ACOL, INDA and LOCA. This allows you to specify the pattern of nonzero elements in $A$.
E04NQF exploits structure in $H$ by requiring $H$ to be defined implicitly in a subroutine that computes the product $Hx$ for any given vector $x$. In many cases, the product $Hx$ can be computed very efficiently for any given $x$, e.g., $H$ may be a sparse matrix, or a sum of matrices of rank-one.
For problems in which $A$ can be treated as a dense matrix, it is usually more efficient to use E04MFF/E04MFA, E04NCF/E04NCA or E04NFF/E04NFA.
There is considerable flexibility allowed in the definition of $f\left(x\right)$ in Table 1. The vector $c$ defining the linear term ${c}^{\mathrm{T}}x$ can be input in three ways: as a sparse row of $A$; as an explicit dense vector $c$; or as both a sparse row and an explicit vector (in which case, ${c}^{\mathrm{T}}x$ will be the sum of two linear terms). When stored in $A$, $c$ is the IOBJth row of $A$, which is known as the objective row. The objective row must always be a free row of $A$ in the sense that its lower and upper bounds must be $-\infty$ and $+\infty$. Storing $c$ as part of $A$ is recommended if $c$ is a sparse vector. Storing $c$ as an explicit vector is recommended for a sequence of problems, each with a different objective (see parameters C and LENC).
The upper and lower bounds on the $m$ elements of $Ax$ are said to define the general constraints of the problem. Internally, E04NQF converts the general constraints to equalities by introducing a set of slack variables $s$, where $s={\left({s}_{1},{s}_{2},\dots ,{s}_{m}\right)}^{\mathrm{T}}$. For example, the linear constraint $5\le 2{x}_{1}+3{x}_{2}\le +\infty$ is replaced by $2{x}_{1}+3{x}_{2}-{s}_{1}=0$, together with the bounded slack $5\le {s}_{1}\le +\infty$. The problem defined by (1) can therefore be re-written in the following equivalent form:
 $minimize x ∈ Rn , s ∈ Rm fx subject to ​ Ax-s=0 , l ≤ x s ≤u.$
Since the slack variables $s$ are subject to the same upper and lower bounds as the elements of $Ax$, the bounds on $x$ and $Ax$ can simply be thought of as bounds on the combined vector $\left(x,s\right)$. (In order to indicate their special role in QP problems, the original variables $x$ are sometimes known as ‘column variables’, and the slack variables $s$ are known as ‘row variables’.)
Each LP or QP problem is solved using a two-phase iterative procedure (in which the general constraints are satisfied throughout): a feasibility phase (Phase 1), in which the sum of infeasibilities with respect to the bounds on $x$ and $s$ is minimized to find a feasible point that satisfies all constraints within a specified feasibility tolerance; and an optimality phase (Phase 2), in which $f\left(x\right)$ is minimized (or maximized) by constructing a sequence of iterates that lies within the feasible region.
Phase 1 involves solving a linear program of the form
 Phase 1 $\underset{x,s,v,w}{\mathrm{minimize}}\phantom{\rule{0.25em}{0ex}}\sum _{j=1}^{n+m}\left({v}_{j}+{w}_{j}\right)$ $\text{subject to ​}Ax-s=0\text{, }l\le \left(\begin{array}{c}x\\ s\end{array}\right)-v+w\le u\text{, }v\ge 0\text{, }w\ge 0$
which is equivalent to minimizing the sum of the constraint violations. If the constraints are feasible (i.e., at least one feasible point exists), eventually a point will be found at which both $v$ and $w$ are zero. Then the associated value of $\left(x,s\right)$ satisfies the original constraints and is used as the starting point for the Phase 2 iterations for minimizing $f\left(x\right)$.
If the constraints are infeasible (i.e., $v\ne 0$ or $w\ne 0$ at the end of Phase 1), no solution exists for (1) and you have the option of either terminating or continuing in so-called elastic mode (see the discussion of the optional parameter Elastic Mode). In elastic mode, a ‘relaxed’ or ‘perturbed’ problem is solved in which $f\left(x\right)$ is minimized while allowing some of the bounds to become ‘elastic’, i.e., to change from their specified values. Variables subject to elastic bounds are known as elastic variables. An elastic variable is free to violate one or both of its original upper or lower bounds. You are able to assign which bounds will become elastic if elastic mode is ever started (see the parameter HELAST in Section 5).
To make the relaxed problem meaningful, E04NQF minimizes $f\left(x\right)$ while (in some sense) finding the ‘smallest’ violation of the elastic variables. In the situation where all the variables are elastic, the relaxed problem has the form
 Phase 2 ($\gamma$) $\underset{x,s,v,w}{\mathrm{minimize}}\phantom{\rule{0.25em}{0ex}}f\left(x\right)+\gamma \sum _{j=1}^{n+m}\left({v}_{j}+{w}_{j}\right)$ $\text{subject to ​}Ax-s=0\text{, }l\le \left(\begin{array}{c}x\\ s\end{array}\right)-v+w\le u\text{, }v\ge 0\text{, }w\ge 0$,
where $\gamma$ is a non-negative parameter known as the elastic weight (see the description of the optional parameter Elastic Weight), and $f\left(x\right)+\gamma \sum _{j}\phantom{\rule{0.25em}{0ex}}\left({v}_{j}+{w}_{j}\right)$ is called the composite objective. In the more general situation where only a subset of the bounds are elastic, the $v$'s and $w$'s for the non-elastic bounds are fixed at zero.
The elastic weight can be chosen to make the composite objective behave like the original objective $f\left(x\right)$, the sum of infeasibilities, or anything in-between. If $\gamma =0$, E04NQF will attempt to minimize $f$ subject to the (true) upper and lower bounds on the non-elastic variables (and declare the problem infeasible if the non-elastic variables cannot be made feasible).
At the other extreme, choosing $\gamma$ sufficiently large will have the effect of minimizing the sum of the violations of the elastic variables subject to the original constraints on the non-elastic variables. Choosing a large value of the elastic weight is useful for defining a ‘least-infeasible’ point for an infeasible problem.
In Phase 1 and elastic mode, all calculations involving $v$ and $w$ are done implicitly in the sense that an elastic variable ${x}_{j}$ is allowed to violate its lower bound (say) and an explicit value of $v$ can be recovered as ${v}_{j}={l}_{j}-{x}_{j}$.
A constraint is said to be active or binding at $x$ if the associated element of either $x$ or $Ax$ is equal to one of its upper or lower bounds. Since an active constraint in $Ax$ has its associated slack variable at a bound, the status of both simple and general upper and lower bounds can be conveniently described in terms of the status of the variables $\left(x,s\right)$. A variable is said to be nonbasic if it is temporarily fixed at its upper or lower bound. It follows that regarding a general constraint as being active is equivalent to thinking of its associated slack as being nonbasic.
At each iteration of an active-set method, the constraints $Ax-s=0$ are (conceptually) partitioned into the form
 $BxB+SxS+NxN=0,$
where ${x}_{N}$ consists of the nonbasic elements of $\left(x,s\right)$ and the basis matrix $B$ is square and nonsingular. The elements of ${x}_{B}$ and ${x}_{S}$ are called the basic and superbasic variables respectively; with ${x}_{N}$ they are a permutation of the elements of $x$ and $s$. At a QP solution, the basic and superbasic variables will lie somewhere between their upper or lower bounds, while the nonbasic variables will be equal to one of their bounds. At each iteration, ${x}_{S}$ is regarded as a set of independent variables that are free to move in any desired direction, namely one that will improve the value of the objective function (or sum of infeasibilities). The basic variables are then adjusted in order to ensure that $\left(x,s\right)$ continues to satisfy $Ax-s=0$. The number of superbasic variables (${n}_{S}$ say) therefore indicates the number of degrees of freedom remaining after the constraints have been satisfied. In broad terms, ${n}_{S}$ is a measure of how nonlinear the problem is. In particular, ${n}_{S}$ will always be zero for FP and LP problems.
If it appears that no improvement can be made with the current definition of $B$, $S$ and $N$, a nonbasic variable is selected to be added to $S$, and the process is repeated with the value of ${n}_{S}$ increased by one. At all stages, if a basic or superbasic variable encounters one of its bounds, the variable is made nonbasic and the value of ${n}_{S}$ is decreased by one.
Associated with each of the $m$ equality constraints $Ax-s=0$ is a dual variable ${\pi }_{i}$. Similarly, each variable in $\left(x,s\right)$ has an associated reduced gradient ${d}_{j}$ (also known as a reduced cost). The reduced gradients for the variables $x$ are the quantities $g-{A}^{\mathrm{T}}\pi$, where $g$ is the gradient of the QP objective function, and the reduced gradients for the slack variables $s$ are the dual variables $\pi$. The QP subproblem is optimal if ${d}_{j}\ge 0$ for all nonbasic variables at their lower bounds, ${d}_{j}\le 0$ for all nonbasic variables at their upper bounds and ${d}_{j}=0$ for all superbasic variables. In practice, an approximate QP solution is found by slightly relaxing these conditions on ${d}_{j}$ (see the description of the optional parameter Optimality Tolerance).
The process of computing and comparing reduced gradients is known as pricing (a term first introduced in the context of the simplex method for linear programming). To ‘price’ a nonbasic variable ${x}_{j}$ means that the reduced gradient ${d}_{j}$ associated with the relevant active upper or lower bound on ${x}_{j}$ is computed via the formula ${d}_{j}={g}_{j}-{a}_{j}^{\mathrm{T}}\pi$, where ${a}_{j}$ is the $j$th column of $\left(\begin{array}{cc}A& -I\end{array}\right)$. (The variable selected by such a process and the corresponding value of ${d}_{j}$ (i.e., its reduced gradient) are the quantities +SBS and dj in the monitoring file output; see Section 8.1.) If $A$ has significantly more columns than rows (i.e., $n\gg m$), pricing can be computationally expensive. In this case, a strategy known as partial pricing can be used to compute and compare only a subset of the ${d}_{j}$s.
E04NQF is based on SQOPT, which is part of the SNOPT package described in Gill et al. (2005a). It uses stable numerical methods throughout and includes a reliable basis package (for maintaining sparse $LU$ factors of the basis matrix $B$), a practical anti-degeneracy procedure, efficient handling of linear constraints and bounds on the variables (by an active-set strategy), as well as automatic scaling of the constraints. Further details can be found in Section 10.

## 4  References

Fourer R (1982) Solving staircase linear programs by the simplex method Math. Programming 23 274–313
Gill P E and Murray W (1978) Numerically stable methods for quadratic programming Math. Programming 14 349–372
Gill P E, Murray W and Saunders M A (1995) User's guide for QPOPT 1.0: a Fortran package for quadratic programming Report SOL 95-4 Department of Operations Research, Stanford University
Gill P E, Murray W and Saunders M A (2005a) Users' guide for SQOPT 7: a Fortran package for large-scale linear and quadratic programming Report NA 05-1 Department of Mathematics, University of California, San Diego ftp://www.cam.ucsd.edu/pub/peg/reports/sqdoc7.pdf
Gill P E, Murray W and Saunders M A (2005b) Users' guide for SNOPT 7.1: a Fortran package for large-scale linear nonlinear programming Report NA 05-2 Department of Mathematics, University of California, San Diego ftp://www.cam.ucsd.edu/pub/peg/reports/sndoc7.pdf
Gill P E, Murray W, Saunders M A and Wright M H (1987) Maintaining LU factors of a general sparse matrix Linear Algebra and its Applics. 88/89 239–270
Gill P E, Murray W, Saunders M A and Wright M H (1989) A practical anti-cycling procedure for linearly constrained optimization Math. Programming 45 437–474
Gill P E, Murray W, Saunders M A and Wright M H (1991) Inertia-controlling methods for general quadratic programming SIAM Rev. 33 1–36
Hall J A J and McKinnon K I M (1996) The simplest examples where the simplex method cycles and conditions where EXPAND fails to prevent cycling Report MS 96–100 Department of Mathematics and Statistics, University of Edinburgh

## 5  Parameters

The first $n$ entries of the parameters BL, BU, HS and X refer to the variables $x$. The last $m$ entries refer to the slacks $s$.
1:     START – CHARACTER(1)Input
On entry: indicates how a starting basis (and certain other items) will be obtained.
${\mathbf{START}}=\text{'C'}$
Requests that an internal Crash procedure be used to choose an initial basis, unless a Basis file is provided via optional parameters Old Basis File, Insert File or Load File.
${\mathbf{START}}=\text{'B'}$
Is the same as ${\mathbf{START}}=\text{'C'}$ but is more meaningful when a Basis file is given.
${\mathbf{START}}=\text{'W'}$
Means that a basis is already defined in HS and a start point is already defined in X (probably from an earlier call).
Constraint: ${\mathbf{START}}=\text{'B'}$, $\text{'C'}$ or $\text{'W'}$.
2:     QPHX – SUBROUTINE, supplied by the NAG Library or the user.External Procedure
For QP problems, you must supply a version of QPHX to compute the matrix product $Hx$ for a given vector $x$. If $H$ has rows and columns of zeros, it is most efficient to order $x$ so that the nonlinear variables appear first. For example, if $x={\left(y,z\right)}^{\mathrm{T}}$ and only $y$ enters the objective quadratically then
 $H x= H1 0 0 0 y z = H1y 0 .$ (2)
In this case, NCOLH should be the dimension of $y$, and QPHX should compute ${H}_{1}y$. For FP and LP problems, QPHX will never be called by E04NQF and hence QPHX may be the dummy routine E04NSH.
The specification of QPHX is:
 SUBROUTINE QPHX ( NCOLH, X, HX, NSTATE, CUSER, IUSER, RUSER)
 INTEGER NCOLH, NSTATE, IUSER(*) REAL (KIND=nag_wp) X(NCOLH), HX(NCOLH), RUSER(*) CHARACTER(8) CUSER(*)
1:     NCOLH – INTEGERInput
On entry: this is the same parameter NCOLH as supplied to E04NQF.
2:     X(NCOLH) – REAL (KIND=nag_wp) arrayInput
On entry: the first NCOLH elements of the vector $x$.
3:     HX(NCOLH) – REAL (KIND=nag_wp) arrayOutput
On exit: the product $Hx$. If NCOLH is less than the input parameter N, $Hx$ is really the product ${H}_{1}y$ in (2).
4:     NSTATE – INTEGERInput
On entry: allows you to save computation time if certain data must be read or calculated only once. To preserve this data for a subsequent calculation place it in one of CUSER, RUSER or IUSER .
${\mathbf{NSTATE}}=1$
E04NQF is calling QPHX for the first time.
${\mathbf{NSTATE}}=0$
There is nothing special about the current call of QPHX.
${\mathbf{NSTATE}}\ge 2$
E04NQF is calling QPHX for the last time. This parameter setting allows you to perform some additional computation on the final solution.
${\mathbf{NSTATE}}=2$
The current $x$ is optimal.
${\mathbf{NSTATE}}=3$
The problem appears to be infeasible.
${\mathbf{NSTATE}}=4$
The problem appears to be unbounded.
${\mathbf{NSTATE}}=5$
The iterations limit was reached.
5:     CUSER($*$) – CHARACTER(8) arrayUser Workspace
6:     IUSER($*$) – INTEGER arrayUser Workspace
7:     RUSER($*$) – REAL (KIND=nag_wp) arrayUser Workspace
QPHX must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which E04NQF is called. Parameters denoted as Input must not be changed by this procedure.
3:     M – INTEGERInput
On entry: $m$, the number of general linear constraints (or slacks). This is the number of rows in the linear constraint matrix $A$, including the free row (if any; see IOBJ). Note that $A$ must have at least one row. If your problem has no constraints, or only upper or lower bounds on the variables, then you must include a dummy row with sufficiently wide upper and lower bounds (see also ACOL, INDA and LOCA).
Constraint: ${\mathbf{M}}\ge 1$.
4:     N – INTEGERInput
On entry: $n$, the number of variables (excluding slacks). This is the number of columns in the linear constraint matrix $A$.
Constraint: ${\mathbf{N}}\ge 1$.
5:     NE – INTEGERInput
On entry: the number of nonzero elements in $A$.
Constraint: $1\le {\mathbf{NE}}\le {\mathbf{N}}×{\mathbf{M}}$.
6:     NNAME – INTEGERInput
On entry: the number of column (i.e., variable) and row names supplied in the array NAMES.
${\mathbf{NNAME}}=1$
There are no names. Default names will be used in the printed output.
${\mathbf{NNAME}}={\mathbf{N}}+{\mathbf{M}}$
All names must be supplied.
Constraint: ${\mathbf{NNAME}}=1$ or ${\mathbf{N}}+{\mathbf{M}}$.
7:     LENC – INTEGERInput
On entry: the number of elements in the constant objective vector $c$.
If ${\mathbf{LENC}}>0$, the first LENC elements of $x$ belong to variables corresponding to the constant objective term $c$.
Constraint: $0\le {\mathbf{LENC}}\le {\mathbf{N}}$.
8:     NCOLH – INTEGERInput
On entry: ${n}_{H}$, the number of leading nonzero columns of the Hessian matrix $H$. For FP and LP problems, NCOLH must be set to zero.
The first NCOLH elements of $x$ belong to variables corresponding to the nonzero block of the QP Hessian.
Constraint: $0\le {\mathbf{NCOLH}}\le {\mathbf{N}}$.
9:     IOBJ – INTEGERInput
On entry: if ${\mathbf{IOBJ}}>0$, row IOBJ of $A$ is a free row containing the nonzero elements of the vector $c$ appearing in the linear objective term ${c}^{\mathrm{T}}x$.
If ${\mathbf{IOBJ}}=0$, there is no free row, and the linear objective vector should be supplied in array C.
Constraint: $0\le {\mathbf{IOBJ}}\le {\mathbf{M}}$.
On entry: the constant $q$, to be added to the objective for printing purposes. Typically ${\mathbf{OBJADD}}=\text{0.0E0}$.
11:   PROB – CHARACTER(8)Input
On entry: the name for the problem. It is used in the printed solution and in some routines that output Basis files. A blank name may be used.
12:   ACOL(NE) – REAL (KIND=nag_wp) arrayInput
On entry: the nonzero elements of $A$, ordered by increasing column index. Note that all elements must be assigned a value in the calling program.
13:   INDA(NE) – INTEGER arrayInput
On entry: ${\mathbf{INDA}}\left(\mathit{i}\right)$ must contain the row index of the nonzero element stored in ${\mathbf{ACOL}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NE}}$. Thus a pair of values $\left({\mathbf{ACOL}}\left(i\right),{\mathbf{INDA}}\left(i\right)\right)$ contains a matrix element and its corresponding row index.
Note that the row indices for a column may be supplied in any order.
Constraint: $1\le {\mathbf{INDA}}\left(\mathit{i}\right)\le {\mathbf{M}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{NE}}$.
14:   LOCA(${\mathbf{N}}+1$) – INTEGER arrayInput
On entry: ${\mathbf{LOCA}}\left(\mathit{j}\right)$ must contain the index in ACOL and INDA of the start of the $\mathit{j}$th column, for $\mathit{j}=1,2,\dots ,{\mathbf{N}}$. Thus for $j=1:{\mathbf{N}}$, the entries of column $j$ are held in ${\mathbf{ACOL}}\left(k:l\right)$ and their corresponding row indices are in ${\mathbf{INDA}}\left(k:l\right)$, where $k={\mathbf{LOCA}}\left(j\right)$ and $l={\mathbf{LOCA}}\left(j+1\right)-1$. To specify the $j$th column as empty, set ${\mathbf{LOCA}}\left(j\right)={\mathbf{LOCA}}\left(j+1\right)$. Note that the first and last elements of LOCA must be ${\mathbf{LOCA}}\left(1\right)=1$ and ${\mathbf{LOCA}}\left({\mathbf{N}}+1\right)={\mathbf{NE}}+1$. If your problem has no constraints, or just bounds on the variables, you may include a dummy ‘free’ row with a single (zero) element by setting ${\mathbf{NE}}=1$, ${\mathbf{ACOL}}\left(1\right)=0.0$, ${\mathbf{INDA}}\left(1\right)=1$, ${\mathbf{LOCA}}\left(1\right)=1$, and ${\mathbf{LOCA}}\left(j\right)=2$, for $j=2:{\mathbf{N}}+1$. This row is made ‘free’ by setting its bounds to be ${\mathbf{BL}}\left({\mathbf{N}}+1\right)=-\mathit{bigbnd}$ and ${\mathbf{BU}}\left({\mathbf{N}}+1\right)=\mathit{bigbnd}$, where $\mathit{bigbnd}$ is the value of the optional parameter Infinite Bound Size.
Constraints:
• ${\mathbf{LOCA}}\left(1\right)=1$;
• ${\mathbf{LOCA}}\left(\mathit{j}\right)\ge 1$, for $\mathit{j}=2,3,\dots ,{\mathbf{N}}$;
• ${\mathbf{LOCA}}\left({\mathbf{N}}+1\right)={\mathbf{NE}}+1$;
• $0\le {\mathbf{LOCA}}\left(\mathit{j}+1\right)-{\mathbf{LOCA}}\left(\mathit{j}\right)\le {\mathbf{M}}$, for $\mathit{j}=1,2,\dots ,{\mathbf{N}}$.
15:   BL(${\mathbf{N}}+{\mathbf{M}}$) – REAL (KIND=nag_wp) arrayInput
On entry: $l$, the lower bounds for all the variables and general constraints, in the following order. The first N elements of BL must contain the bounds on the variables $x$, and the next M elements the bounds for the general linear constraints $Ax$ (which, equivalently, are the bounds for the slacks, $s$) and the free row (if any). To fix the $j$th variable, set ${\mathbf{BL}}\left(j\right)={\mathbf{BU}}\left(j\right)=\beta$, say, where $\left|\beta \right|<\mathit{bigbnd}$. To specify a nonexistent lower bound (i.e., ${l}_{j}=-\infty$), set ${\mathbf{BL}}\left(j\right)\le -\mathit{bigbnd}$. Here, $\mathit{bigbnd}$ is the value of the optional parameter Infinite Bound Size. To specify the $j$th constraint as an equality, set ${\mathbf{BL}}\left({\mathbf{N}}+j\right)={\mathbf{BU}}\left({\mathbf{N}}+j\right)=\beta$, say, where $\left|\beta \right|<\mathit{bigbnd}$. Note that the lower bound corresponding to the free row must be set to $-\infty$ and stored in ${\mathbf{BL}}\left({\mathbf{N}}+{\mathbf{IOBJ}}\right)$.
Constraint: if ${\mathbf{IOBJ}}>0$, ${\mathbf{BL}}\left({\mathbf{N}}+{\mathbf{IOBJ}}\right)\le -\mathit{bigbnd}$
16:   BU(${\mathbf{N}}+{\mathbf{M}}$) – REAL (KIND=nag_wp) arrayInput
On entry: $u$, the upper bounds for all the variables and general constraints, in the following order. The first N elements of BU must contain the bounds on the variables $x$, and the next M elements the bounds for the general linear constraints $Ax$ (which, equivalently, are the bounds for the slacks, $s$) and the free row (if any). To specify a nonexistent upper bound (i.e., ${u}_{j}=+\infty$), set ${\mathbf{BU}}\left(j\right)\ge \mathit{bigbnd}$. Note that the upper bound corresponding to the free row must be set to $+\infty$ and stored in ${\mathbf{BU}}\left({\mathbf{N}}+{\mathbf{IOBJ}}\right)$.
Constraints:
• if ${\mathbf{IOBJ}}>0$, ${\mathbf{BU}}\left({\mathbf{N}}+{\mathbf{IOBJ}}\right)\ge \mathit{bigbnd}$;
• otherwise ${\mathbf{BL}}\left(i\right)\le {\mathbf{BU}}\left(i\right)$.
17:   C($\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LENC}}\right)$) – REAL (KIND=nag_wp) arrayInput
Note: the dimension of the array C must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LENC}}\right)$ if ${\mathbf{IOBJ}}\ne 0$, and at least $1$ otherwise.
On entry: contains the explicit objective vector $c$ (if any). If the problem is of type FP, or if ${\mathbf{LENC}}=0$, then C is not referenced. (In that case, C may be dimensioned (1), or it could be any convenient array.)
18:   NAMES(NNAME) – CHARACTER(8) arrayInput
On entry: the optional column and row names, respectively.
If ${\mathbf{NNAME}}=1$, NAMES is not referenced and the printed output will use default names for the columns and rows.
If ${\mathbf{NNAME}}={\mathbf{N}}+{\mathbf{M}}$, the first N elements must contain the names for the columns and the next M elements must contain the names for the rows. Note that the name for the free row (if any) must be stored in ${\mathbf{NAMES}}\left({\mathbf{N}}+{\mathbf{IOBJ}}\right)$.
19:   HELAST(${\mathbf{N}}+{\mathbf{M}}$) – INTEGER arrayInput
On entry: defines which variables are to be treated as being elastic in elastic mode. The allowed values of HELAST are:
 ${\mathbf{HELAST}}\left(j\right)$ Status in elastic mode $0$ Variable $j$ is non-elastic and cannot be infeasible $1$ Variable $j$ can violate its lower bound $2$ Variable $j$ can violate its upper bound $3$ Variable $j$ can violate either its lower or upper bound
HELAST need not be assigned if optional parameter ${\mathbf{Elastic Mode}}=0$.
Constraint: if ${\mathbf{Elastic Mode}}\ne 0$, ${\mathbf{HELAST}}\left(\mathit{j}\right)=0,1,2,3$, for $\mathit{j}=1,2,\dots ,{\mathbf{N}}+{\mathbf{M}}$.
20:   HS(${\mathbf{N}}+{\mathbf{M}}$) – INTEGER arrayInput/Output
On entry: if ${\mathbf{START}}=\text{'C'}$ or $\text{'B'}$, and a Basis file of some sort is to be input (see the description of the optional parameters Old Basis File, Insert File or Load File), then HS and X need not be set at all.
If ${\mathbf{START}}=\text{'C'}$ or $\text{'B'}$ and there is no Basis file, the first N elements of HS and X must specify the initial states and values, respectively, of the variables $x$. (The slacks $s$ need not be initialized.) An internal Crash procedure is then used to select an initial basis matrix $B$. The initial basis matrix will be triangular (neglecting certain small elements in each column). It is chosen from various rows and columns of $\left(\begin{array}{cc}A& -I\end{array}\right)$. Possible values for ${\mathbf{HS}}\left(j\right)$ are as follows:
 ${\mathbf{HS}}\left(j\right)$ State of ${\mathbf{X}}\left(j\right)$ during Crash procedure $0$ or $1$ Eligible for the basis $2$ Ignored $3$ Eligible for the basis (given preference over $0$ or $1$) $4$ or $5$ Ignored
If nothing special is known about the problem, or there is no wish to provide special information, you may set ${\mathbf{HS}}\left(\mathit{j}\right)=0$ and ${\mathbf{X}}\left(\mathit{j}\right)=0.0$, for $\mathit{j}=1,2,\dots ,{\mathbf{N}}$. All variables will then be eligible for the initial basis. Less trivially, to say that the $j$th variable will probably be equal to one of its bounds, set ${\mathbf{HS}}\left(j\right)=4$ and ${\mathbf{X}}\left(j\right)={\mathbf{BL}}\left(j\right)$ or ${\mathbf{HS}}\left(j\right)=5$ and ${\mathbf{X}}\left(j\right)={\mathbf{BU}}\left(j\right)$ as appropriate.
Following the Crash procedure, variables for which ${\mathbf{HS}}\left(j\right)=2$ are made superbasic. Other variables not selected for the basis are then made nonbasic at the value ${\mathbf{X}}\left(j\right)$ if ${\mathbf{BL}}\left(j\right)\le {\mathbf{X}}\left(j\right)\le {\mathbf{BU}}\left(j\right)$, or at the value ${\mathbf{BL}}\left(j\right)$ or ${\mathbf{BU}}\left(j\right)$ closest to ${\mathbf{X}}\left(j\right)$.
If ${\mathbf{START}}=\text{'W'}$, HS and X must specify the initial states and values, respectively, of the variables and slacks $\left(x,s\right)$. If E04NQF has been called previously with the same values of N and M, HS already contains satisfactory information.
Constraints:
• if ${\mathbf{START}}=\text{'C'}$ or $\text{'B'}$, $0\le {\mathbf{HS}}\left(\mathit{j}\right)\le 5$, for $\mathit{j}=1,2,\dots ,{\mathbf{N}}$;
• if ${\mathbf{START}}=\text{'W'}$, $0\le {\mathbf{HS}}\left(\mathit{j}\right)\le 3$, for $\mathit{j}=1,2,\dots ,{\mathbf{N}}+{\mathbf{M}}$.
On exit: the final states of the variables and slacks $\left(x,s\right)$. The significance of each possible value of ${\mathbf{HS}}\left(j\right)$ is as follows:
 ${\mathbf{HS}}\left(j\right)$ State of variable $j$ Normal value of ${\mathbf{X}}\left(j\right)$ $0$ Nonbasic ${\mathbf{BL}}\left(j\right)$ $1$ Nonbasic ${\mathbf{BU}}\left(j\right)$ $2$ Superbasic Between ${\mathbf{BL}}\left(j\right)$ and ${\mathbf{BU}}\left(j\right)$ $3$ Basic Between ${\mathbf{BL}}\left(j\right)$ and ${\mathbf{BU}}\left(j\right)$
If ${\mathbf{NINF}}=0$, basic and superbasic variables may be outside their bounds by as much as the value of the optional parameter Feasibility Tolerance. Note that unless the optional parameter ${\mathbf{Scale Option}}=0$ is specified, the optional parameter Feasibility Tolerance applies to the variables of the scaled problem. In this case, the variables of the original problem may be as much as $0.1$ outside their bounds, but this is unlikely unless the problem is very badly scaled.
Very occasionally some nonbasic variables may be outside their bounds by as much as the optional parameter Feasibility Tolerance, and there may be some nonbasic variables for which ${\mathbf{X}}\left(j\right)$ lies strictly between its bounds.
If ${\mathbf{NINF}}>0$, some basic and superbasic variables may be outside their bounds by an arbitrary amount (bounded by SINF if ${\mathbf{Scale Option}}=0$).
21:   X(${\mathbf{N}}+{\mathbf{M}}$) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the initial values of the variables $x$, and, if ${\mathbf{START}}=\text{'W'}$, the slacks $s$, i.e., $\left(x,s\right)$. (See the description for parameter HS.)
On exit: the final values of the variables and slacks $\left(x,s\right)$.
22:   PI(M) – REAL (KIND=nag_wp) arrayOutput
On exit: contains the dual variables $\pi$ (a set of Lagrange multipliers (shadow prices) for the general constraints).
23:   RC(${\mathbf{N}}+{\mathbf{M}}$) – REAL (KIND=nag_wp) arrayOutput
On exit: contains the reduced costs, $g-{\left(\begin{array}{cc}A& -I\end{array}\right)}^{\mathrm{T}}\pi$. The vector $g$ is the gradient of the objective if X is feasible, otherwise it is the gradient of the Phase 1 objective. In the former case, $g\left(i\right)=0$, for $i={\mathbf{N}}+1:{\mathbf{M}}$, hence ${\mathbf{RC}}\left({\mathbf{N}}+1:{\mathbf{M}}\right)=\pi$.
24:   NS – INTEGERInput/Output
On entry: ${n}_{S}$, the number of superbasics. For QP problems, NS need not be specified if ${\mathbf{START}}=\text{'C'}$, but must retain its value from a previous call when ${\mathbf{START}}=\text{'W'}$. For FP and LP problems, NS need not be initialized.
On exit: the final number of superbasics. This will be zero for FP and LP problems.
25:   NINF – INTEGEROutput
On exit: the number of infeasibilities.
26:   SINF – REAL (KIND=nag_wp)Output
On exit: the sum of the scaled infeasibilities. This will be zero if ${\mathbf{NINF}}=0$, and is most meaningful when ${\mathbf{Scale Option}}=0$.
27:   OBJ – REAL (KIND=nag_wp)Output
On exit: the value of the objective function.
If ${\mathbf{NINF}}=0$, OBJ includes the quadratic objective term $\frac{1}{2}{x}^{\mathrm{T}}Hx$ (if any).
If ${\mathbf{NINF}}>0$, OBJ is just the linear objective term ${c}^{\mathrm{T}}x$ (if any).
For FP problems, OBJ is set to zero.
Note that OBJ does not include contributions from the constant term OBJADD or the objective row, if any.
28:   CW(LENCW) – CHARACTER(8) arrayCommunication Array
29:   LENCW – INTEGERInput
On entry: the dimension of the array CW as declared in the (sub)program from which E04NQF is called.
Constraint: ${\mathbf{LENCW}}\ge 600$.
30:   IW(LENIW) – INTEGER arrayCommunication Array
31:   LENIW – INTEGERInput
On entry: the dimension of the array IW as declared in the (sub)program from which E04NQF is called.
Constraint: ${\mathbf{LENIW}}\ge 600$.
32:   RW(LENRW) – REAL (KIND=nag_wp) arrayCommunication Array
33:   LENRW – INTEGERInput
On entry: the dimension of the array RW as declared in the (sub)program from which E04NQF is called.
Constraint: ${\mathbf{LENRW}}\ge 600$.
34:   CUSER($*$) – CHARACTER(8) arrayUser Workspace
CUSER is not used by E04NQF, but is passed directly to QPHX and may be used to pass information to this routine as an alternative to using COMMON global variables.
35:   IUSER($*$) – INTEGER arrayUser Workspace
IUSER is not used by E04NQF, but is passed directly to QPHX and may be used to pass information to this routine as an alternative to using COMMON global variables.
36:   RUSER($*$) – REAL (KIND=nag_wp) arrayUser Workspace
RUSER is not used by E04NQF, but is passed directly to QPHX and may be used to pass information to this routine as an alternative to using COMMON global variables.
37:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ 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 parameters may be useful even if ${\mathbf{IFAIL}}\ne {\mathbf{0}}$ on exit, the recommended value is $-1$. When the value $-\mathbf{1}\text{​ or ​}1$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).
E04NQF returns with ${\mathbf{IFAIL}}={\mathbf{0}}$ if the reduced gradient (rgNorm; see Section 8.1) is negligible, the Lagrange multipliers (Lagr Mult; see Section 8.1) are optimal, $x$ satisfies the constraints to the accuracy requested by the value of the optional parameter Feasibility Tolerance and the reduced Hessian factor $R$ (see Section 10.2) is nonsingular.

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Note: E04NQF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
The initialization routine E04NPF has not been called or at least one of LENCW, LENIW and LENRW is less than $600$.
${\mathbf{IFAIL}}=2$
An input parameter is invalid.
${\mathbf{IFAIL}}=3$
The requested accuracy could not be achieved.
${\mathbf{IFAIL}}=4$
Weak QP solution found. The final $x$ is not unique.
This exit will occur when the following are true:
 (i) the problem is feasible; (ii) the reduced gradient is negligible; (iii) the Lagrange multipliers are optimal; and (iv) the reduced Hessian is singular or there are some very small multipliers.
This exit cannot occur if $H$ is positive definite (i.e., $f\left(x\right)$ is strictly convex).
${\mathbf{IFAIL}}=5$
The problem is infeasible. The general constraints cannot all be satisfied simultaneously to within the value of the optional parameter Feasibility Tolerance.
Feasibility is measured with respect to the upper and lower bounds on the variables and slacks. The message tells us that among all the points satisfying the general constraints $Ax-s=0$, there is apparently no point that satisfies the bounds on $x$ and $s$. Violations as small as the Feasibility Tolerance are ignored, but at least one component of $x$ or $s$ violates a bound by more than the tolerance.
Note:  although the objective function is the sum of infeasibilities (when ${\mathbf{NINF}}>0$), this sum will not necessarily have been minimized when ${\mathbf{Elastic Mode}}=1$.
If ${\mathbf{Elastic Mode}}\ne 0$, E04NQF will optimize the QP objective and the sum of infeasibilities, suitably weighted using the optional parameter Elastic Mode. The routine will tend to determine a ‘good’ infeasible point if the elastic weight is sufficiently large.
${\mathbf{IFAIL}}=6$
The problem is unbounded (or badly scaled). For a minimization problem, the objective function is not bounded below in the feasible region.
For linear problems, unboundedness is detected by the simplex method when a nonbasic variable can be increased or decreased by an arbitrary amount without causing a basic variable to violate a bound. Consider adding an upper or lower bound to the variable. Also, examine the constraints that have nonzeros in the associated column, to see if they have been formulated as intended.
Very rarely, the scaling of the problem could be so poor that numerical error will give an erroneous indication of unboundedness. Consider using the optional parameter Scale Option.
${\mathbf{IFAIL}}=7$
Too many iterations. The value of the optional parameter Iterations Limit is too small.
The Iterations limit was exceeded before the required solution could be found. Check the iteration log to be sure that progress was being made. If so, restart the run using a Basis file that was saved at the end of the run.
${\mathbf{IFAIL}}=8$
The value of the optional parameter Superbasics Limit is too small. The current set of basic and superbasic variables have been optimized as much as possible and a pricing operation is necessary to continue, but there are already Superbasics Limit superbasics (and no room for any more).
In general, raise the Superbasics Limit $s$ by a reasonable amount, bearing in mind the storage needed for reduced Hessian (see Section 10.2). (The Reduced Hessian Dimension $h$ will also increase to $s$ unless specified otherwise, and the associated storage will be about $\frac{1}{2}{s}^{2}$ words.) In some cases you may have to set $h to conserve storage, but beware that the rate of convergence will probably fall off severely.
${\mathbf{IFAIL}}=9$
The basis is singular after several attempts to factorize it (adding slacks where necessary). Either the problem is badly scaled or the value of the optional parameter LU Factor Tolerance is too large.
${\mathbf{IFAIL}}=10$
Numerical error in trying to satisfy the general constraints. The basis is very ill-conditioned.
An $LU$ factorization of the basis has just been obtained and used to recompute the basic variables ${x}_{B}$, given the present values of the superbasic and nonbasic variables. However, a row check has revealed that the resulting solution does not satisfy the current constraints $Ax-s=0$ sufficiently well.
This probably means that the current basis is very ill-conditioned. Request the Scale Option if there are any linear constraints and variables.
For certain highly structured basis matrices (notably those with band structure), a systematic growth may occur in the factor $U$. Consult the description of Umax, Umin and Growth in Section 12, and set the optional parameter LU Factor Tolerance to $2.0$ (or possibly even smaller, but not less than $1.0$).
${\mathbf{IFAIL}}=11$
An indefinite matrix was detected during the computation of the reduced Hessian factor $R$ (see Section 10.2). This may be caused by $H$ being indefinite. Check also that QPHX has been coded correctly and that all relevant elements of $Hx$ have been assigned their correct values. If QPHX is coded correctly and $H$ is positive semidefinite, the failure may be caused by ill conditioning. Try reducing the values of the optional parameters LU Factor Tolerance and LU Update Tolerance. If there are very large values in $H$, check the scaling of the variables and constraints.
${\mathbf{IFAIL}}=12$
${\mathbf{IFAIL}}=13$
${\mathbf{IFAIL}}=14$
An error has occurred in the basis package, perhaps indicating incorrect setup of arrays INDA and LOCA. Set the optional parameter Print File and examine the output carefully for further information.
${\mathbf{IFAIL}}=15$
An unexpected error has occurred. Set the optional parameter Print File and examine the output carefully for further information.

## 7  Accuracy

E04NQF implements a numerically stable active-set strategy and returns solutions that are as accurate as the condition of the problem warrants on the machine.

This section contains a description of the printed output.

### 8.1  Description of the Printed Output

If ${\mathbf{Print Level}}>0$, one line of information is output to the Print File every $k$th iteration, where $k$ is the specified Print Frequency. A heading is printed before the first such line following a basis factorization. The heading contains the items described below. In this description, a pricing operation is defined to be the process by which one or more nonbasic variables are selected to become superbasic (in addition to those already in the superbasic set). The variable selected will be denoted by jq. If the problem is purely linear, variable jq will usually become basic immediately (unless it should happen to reach its opposite bound and return to the nonbasic set).
If optional parameter Partial Price is in effect, variable jq is selected from ${A}_{\mathtt{pp}}$ or ${I}_{\mathtt{pp}}$, the ppth segments of the constraint matrix $\left(\begin{array}{cc}A& -I\end{array}\right)$.
 Label Description Itn is the iteration count. pp is the partial-price indicator. The variable selected by the last pricing operation came from the ppth partition of $A$ and $-I$. Note that pp is reset to zero whenever the basis is refactorized. dj is the value of the reduced gradient (or reduced cost) for the variable selected by the pricing operation at the start of the current iteration. Algebraically, dj is ${d}_{j}={g}_{j}-{\pi }^{\mathrm{T}}{a}_{j}$, for $j=\mathtt{jq}$, where ${g}_{j}$ is the gradient of the current objective function, $\pi$ is the vector of dual variables, and ${a}_{j}$ is the $j$th column of the constraint matrix $\left(\begin{array}{cc}A& -I\end{array}\right)$. Note that dj is the norm of the reduced-gradient vector at the start of the iteration, just after the pricing operation. +SBS is the variable jq selected by the pricing operation to be added to the superbasic set. -SBS is the variable chosen to leave the superbasic set. It has become basic if the entry under -B is nonzero, otherwise it becomes nonbasic. -BS is the variable removed from the basis to become nonbasic. Step is the value of the step length $\alpha$ taken along the current search direction $p$. The variables $x$ have just been changed to $x+\alpha p$. If a variable is made superbasic during the current iteration (i.e., +SBS is positive), Step will be the step to the nearest bound. During the optimality phase, the step can be greater than unity only if the reduced Hessian is not positive definite. Pivot is the $r$th element of a vector $y$ satisfying $By={a}_{q}$ whenever ${a}_{q}$ (the $q$th column of the constraint matrix $\left(\begin{array}{cc}A& -I\end{array}\right)$ replaces the $r$th column of the basis matrix $B$. Wherever possible, Step is chosen so as to avoid extremely small values of Pivot (since they may cause the basis to be nearly singular). In extreme cases, it may be necessary to increase the value of the optional parameter Pivot Tolerance to exclude very small elements of $y$ from consideration during the computation of Step. nInf is the number of violated constraints (infeasibilities) before the present iteration. This number will not increase unless iterations are in elastic mode. sInf is the sum of infeasibilities before the present iteration. It will usually decrease at each nonzero step, but if nInf decreases by $2$ or more, sInf may occasionally increase. However, in elastic mode it will decrease monotonically. Objective is the value of the current objective function after the present iteration. Note, if Elastic Mode is $2$, the heading is Composite Obj. L+U L is the number of nonzeros in the basis factor $L$. Immediately after a basis factorization $B=LU$, L contains lenL (see Section 12). Further nonzeros are added to L when various columns of $B$ are later replaced. (Thus, L increases monotonically.) U is the number of nonzeros in the basis factor $U$. Immediately after a basis factorization $B=LU$, U contains lenU (see Section 12). As columns of $B$ are replaced, the matrix $U$ is maintained explicitly (in sparse form). The value of U may fluctuate up or down; in general, it will tend to increase. ncp is the number of compressions required to recover workspace in the data structure for $U$. This includes the number of compressions needed during the previous basis factorization. Normally, ncp should increase very slowly.
The following will be output if the problem is QP or if the superbasic set is non-empty.
 Label Description rgNorm is the largest reduced-gradient among the superbasic variables after the current iteration. During the optimality phase, this will be approximately zero after a unit step. nS is the current number of superbasic variables. condHz is a lower bound on the condition number of the reduced Hessian (see Section 10.2). The larger this number, the more difficult the problem. Attention should be given to the scaling of the variables and the constraints to guard against high values of condHz.

## 9  Example

This example minimizes the quadratic function $f\left(x\right)={c}^{\mathrm{T}}x+\frac{1}{2}{x}^{\mathrm{T}}Hx$, where
 $c=-200.0,-2000.0,-2000.0,-2000.0,-2000.0,400.0,400.0T$
 $H= 2 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 2 2 0 0 0 0 0 2 2 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 2 2 0 0 0 0 0 2 2$
subject to the bounds
 $000≤x1≤0200 000≤x2≤2500 400≤x3≤0800 100≤x4≤0700 000≤x5≤1500 000≤x6≤1500 000≤x7≤1500$
and to the linear constraints
 $x1 + x2 + x3 + x4 + x5 + x6 + x7 = 2000 0.15x1 + 0.04x2 + 0.02x3 + 0.04x4 + 0.02x5 + 0.01x6 + 0.03x7 ≤ 60 0.03x1 + 0.05x2 + 0.08x3 + 0.02x4 + 0.06x5 + 0.01x6 + 0.03x7 ≤ 100 0.02x1 + 0.04x2 + 0.01x3 + 0.02x4 + 0.02x5 ≤ 40 0.02x1 + 0.03x2 + 0.01x5 ≤ 30 1500 ≤ 0.70x1 + 0.75x2 + 0.80x3 + 0.75x4 + 0.80x5 + 0.97x6 250 ≤ 0.02x1 + 0.06x2 + 0.08x3 + 0.12x4 + 0.02x5 + 0.01x6 + 0.97x7 ≤ 300$
The initial point, which is infeasible, is
 $x0=0.0,0.0,0.0,0.0,0.0,0.0,0.0T.$
The optimal solution (to five figures) is
 $x*=0.0,349.40,648.85,172.85,407.52,271.36,150.02T.$
One bound constraint and four linear constraints are active at the solution. Note that the Hessian matrix $H$ is positive semidefinite.

### 9.1  Program Text

Program Text (e04nqfe.f90)

### 9.2  Program Data

Program Data (e04nqfe.d)

### 9.3  Program Results

Program Results (e04nqfe.r)

Note: the remainder of this document is intended for more advanced users. Section 10 contains a detailed description of the algorithm which may be needed in order to understand Sections 11 and 12. Section 11 describes the optional parameters which may be set by calls to E04NRF, E04NSF, E04NTF and/or E04NUF. Section 12 describes the quantities which can be requested to monitor the course of the computation.

## 10  Algorithmic Details

This section contains a detailed description of the method used by E04NQF.

### 10.1  Overview

E04NQF is based on an inertia-controlling method that maintains a Cholesky factorization of the reduced Hessian (see below). The method is similar to that of Gill and Murray (1978), and is described in detail by Gill et al. (1991). Here we briefly summarise the main features of the method. Where possible, explicit reference is made to the names of variables that are parameters of the routine or appear in the printed output.
The method used has two distinct phases: finding an initial feasible point by minimizing the sum of infeasibilities (the feasibility phase), and minimizing the quadratic objective function within the feasible region (the optimality phase). The computations in both phases are performed by the same subroutines. The two-phase nature of the algorithm is reflected by changing the function being minimized from the sum of infeasibilities (the printed quantity sInf; see Section 8.1) to the quadratic objective function (the printed quantity Objective; see Section 8.1).
In general, an iterative process is required to solve a quadratic program. Given an iterate $\left(x,s\right)$ in both the original variables $x$ and the slack variables $s$, a new iterate $\left(\stackrel{-}{x},\stackrel{-}{s}\right)$ is defined by
 $x- s- = x s +αp,$ (3)
where the step length $\alpha$ is a non-negative scalar (the printed quantity Step; see Section 12), and $p$ is called the search direction. (For simplicity, we shall consider a typical iteration and avoid reference to the index of the iteration.) Once an iterate is feasible (i.e., satisfies the constraints), all subsequent iterates remain feasible.

### 10.2  Definition of the Working Set and Search Direction

At each iterate $\left(x,s\right)$, a working set of constraints is defined to be a linearly independent subset of the constraints that are satisfied ‘exactly’ (to within the value of the optional parameter Feasibility Tolerance). The working set is the current prediction of the constraints that hold with equality at a solution of the LP or QP problem. Let ${m}_{W}$ denote the number of constraints in the working set (including bounds), and let $W$ denote the associated ${m}_{W}$ by $\left(n+m\right)$ working set matrix consisting of the ${m}_{W}$ gradients of the working set constraints.
The search direction is defined so that constraints in the working set remain unaltered for any value of the step length. It follows that $p$ must satisfy the identity
 $Wp=0.$ (4)
This characterisation allows $p$ to be computed using any $n$ by ${n}_{Z}$ full-rank matrix $Z$ that spans the null space of $W$. (Thus, ${n}_{Z}=n-{m}_{W}$ and $WZ=0$.) The null space matrix $Z$ is defined from a sparse $LU$ factorization of part of $W$ (see (7) and (8)). The direction $p$ will satisfy (4) if
 $p=ZpZ,$ (5)
where ${p}_{Z}$ is any ${n}_{Z}$-vector.
The working set contains the constraints $Ax-s=0$ and a subset of the upper and lower bounds on the variables $\left(x,s\right)$. Since the gradient of a bound constraint ${x}_{j}\ge {l}_{j}$ or ${x}_{j}\le {u}_{j}$ is a vector of all zeros except for $±1$ in position $j$, it follows that the working set matrix contains the rows of $\left(\begin{array}{cc}A& -I\end{array}\right)$ and the unit rows associated with the upper and lower bounds in the working set.
The working set matrix $W$ can be represented in terms of a certain column partition of the matrix $\left(\begin{array}{cc}A& -I\end{array}\right)$ by (conceptually) partitioning the constraints $Ax-s=0$ so that
 $BxB+SxS+NxN=0,$ (6)
where $B$ is a square nonsingular basis and ${x}_{B}$, ${x}_{S}$ and ${x}_{N}$ are the basic, superbasic and nonbasic variables respectively. The nonbasic variables are equal to their upper or lower bounds at $\left(x,s\right)$, and the superbasic variables are independent variables that are chosen to improve the value of the current objective function. The number of superbasic variables is ${n}_{S}$ (the printed quantity nS; see Section 8.1). Given values of ${x}_{N}$ and ${x}_{S}$, the basic variables ${x}_{B}$ are adjusted so that $\left(x,s\right)$ satisfies (6).
If $P$ is a permutation matrix such that $\left(\begin{array}{cc}A& -I\end{array}\right)P=\left(\begin{array}{ccc}B& S& N\end{array}\right)$, then $W$ satisfies
 $WP= B S N 0 0 IN ,$ (7)
where ${I}_{N}$ is the identity matrix with the same number of columns as $N$.
The null space matrix $Z$ is defined from a sparse $LU$ factorization of part of $W$. In particular, $Z$ is maintained in ‘reduced gradient’ form, using the LUSOL package (see Gill et al. (1991)) to maintain sparse $LU$ factors of the basis matrix $B$ as the $BSN$ partition changes. Given the permutation $P$, the null space basis is given by
 $Z=P -B-1S I 0 .$ (8)
This matrix is used only as an operator, i.e., it is never computed explicitly. Products of the form $Zv$ and ${Z}^{\mathrm{T}}g$ are obtained by solving with $B$ or ${B}^{\mathrm{T}}$. This choice of $Z$ implies that ${n}_{Z}$, the number of ‘degrees of freedom’ at $\left(x,s\right)$, is the same as ${n}_{S}$, the number of superbasic variables.
Let ${g}_{Z}$ and ${H}_{Z}$ denote the reduced gradient and reduced Hessian of the objective function:
 $gZ=ZTg and HZ=ZTHZ,$ (9)
where $g$ is the objective gradient at $\left(x,s\right)$. Roughly speaking, ${g}_{Z}$ and ${H}_{Z}$ describe the first and second derivatives of an ${n}_{S}$-dimensional unconstrained problem for the calculation of ${p}_{Z}$. (The condition estimator of ${H}_{Z}$ is the quantity condHz in the monitoring file output; see Section 8.1.)
At each iteration, an upper triangular factor $R$ is available such that ${H}_{Z}={R}^{\mathrm{T}}R$. Normally, $R$ is computed from ${R}^{\mathrm{T}}R={Z}^{\mathrm{T}}HZ$ at the start of the optimality phase and then updated as the QP working set changes. For efficiency, the dimension of $R$ should not be excessive (say, ${n}_{S}\le 1000$). This is guaranteed if the number of nonlinear variables is ‘moderate’.
If the QP problem contains linear variables, $H$ is positive semidefinite and $R$ may be singular with at least one zero diagonal element. However, an inertia-controlling strategy is used to ensure that only the last diagonal element of $R$ can be zero. (See Gill et al. (1991) for a discussion of a similar strategy for indefinite quadratic programming.)
If the initial $R$ is singular, enough variables are fixed at their current value to give a nonsingular $R$. This is equivalent to including temporary bound constraints in the working set. Thereafter, $R$ can become singular only when a constraint is deleted from the working set (in which case no further constraints are deleted until $R$ becomes nonsingular).

### 10.3  Main Iteration

If the reduced gradient is zero, $\left(x,s\right)$ is a constrained stationary point on the working set. During the feasibility phase, the reduced gradient will usually be zero only at a vertex (although it may be zero elsewhere in the presence of constraint dependencies). During the optimality phase, a zero reduced gradient implies that $x$ minimizes the quadratic objective function when the constraints in the working set are treated as equalities. At a constrained stationary point, Lagrange multipliers $\lambda$ are defined from the equations
 $WTλ=gx.$ (10)
A Lagrange multiplier, ${\lambda }_{j}$, corresponding to an inequality constraint in the working set is said to be optimal if ${\lambda }_{j}\le \sigma$ when the associated constraint is at its upper bound, or if ${\lambda }_{j}\ge -\sigma$ when the associated constraint is at its lower bound, where $\sigma$ depends on the value of the optional parameter Optimality Tolerance. If a multiplier is nonoptimal, the objective function (either the true objective or the sum of infeasibilities) can be reduced by continuing the minimization with the corresponding constraint excluded from the working set. (This step is sometimes referred to as ‘deleting’ a constraint from the working set.) If optimal multipliers occur during the feasibility phase but the sum of infeasibilities is nonzero, there is no feasible point and the routine terminates immediately with ${\mathbf{IFAIL}}={\mathbf{3}}$.
The special form (7) of the working set allows the multiplier vector $\lambda$, the solution of (10), to be written in terms of the vector
 $d= g 0 - AT -I π= g-ATπ π ,$ (11)
where $\pi$ satisfies the equations ${B}^{\mathrm{T}}\pi ={g}_{B}$, and ${g}_{B}$ denotes the basic elements of $g$. The elements of $\pi$ are the Lagrange multipliers ${\lambda }_{j}$ associated with the equality constraints $Ax-s=0$. The vector ${d}_{N}$ of nonbasic elements of $d$ consists of the Lagrange multipliers ${\lambda }_{j}$ associated with the upper and lower bound constraints in the working set. The vector ${d}_{S}$ of superbasic elements of $d$ is the reduced gradient ${g}_{Z}$ in (9). The vector ${d}_{B}$ of basic elements of $d$ is zero, by construction. (The Euclidean norm of ${d}_{S}$ and the final values of ${d}_{S}$, $g$ and $\pi$ are the quantities rgNorm, Reduced Gradnt, Obj Gradient and Dual Activity in the monitoring file output; see Section 12.)
If the reduced gradient is not zero, Lagrange multipliers need not be computed and the search direction is given by $p=Z{p}_{Z}$ (see (8) and (12)). The step length is chosen to maintain feasibility with respect to the satisfied constraints.
There are two possible choices for ${p}_{Z}$, depending on whether or not ${H}_{Z}$ is singular. If ${H}_{Z}$ is nonsingular, $R$ is nonsingular and ${p}_{Z}$ in (5) is computed from the equations
 $RTRpZ=-gZ,$ (12)
where ${g}_{Z}$ is the reduced gradient at $x$. In this case, $\left(x,s\right)+p$ is the minimizer of the objective function subject to the working set constraints being treated as equalities. If $\left(x,s\right)+p$ is feasible, $\alpha$ is defined to be unity. In this case, the reduced gradient at $\left(\stackrel{-}{x},\stackrel{-}{s}\right)$ will be zero, and Lagrange multipliers are computed at the next iteration. Otherwise, $\alpha$ is set to ${\alpha }_{N}$, the step to the ‘nearest’ constraint along $p$. This constraint is then added to the working set at the next iteration.
If ${H}_{Z}$ is singular, then $R$ must also be singular, and an inertia-controlling strategy is used to ensure that only the last diagonal element of $R$ is zero. (See Gill et al. (1991) for a discussion of a similar strategy for indefinite quadratic programming.) In this case, ${p}_{Z}$ satisfies
 $pZT HZ pZ=0 and gZT pZ≤0,$ (13)
which allows the objective function to be reduced by any step of the form $\left(x,s\right)+\alpha p$, where $\alpha >0$. The vector $p=Z{p}_{Z}$ is a direction of unbounded descent for the QP problem in the sense that the QP objective is linear and decreases without bound along $p$. If no finite step of the form $\left(x,s\right)+\alpha p$ (where $\alpha >0$) reaches a constraint not in the working set, the QP problem is unbounded and the routine terminates immediately with ${\mathbf{IFAIL}}={\mathbf{6}}$. Otherwise, $\alpha$ is defined as the maximum feasible step along $p$ and a constraint active at $\left(x,s\right)+\alpha p$ is added to the working set for the next iteration.
E04NQF makes explicit allowance for infeasible constraints. Infeasible linear constraints are detected first by solving a problem of the form
 $minimize x,v,w eT v+w subject to ​ l ≤ x Gx-v+w ≤u, v≥0, w≥0,$ (14)
where ${e}^{\mathrm{T}}=\left(1,1,\dots ,1\right)$. This is equivalent to minimizing the sum of the general linear constraint violations subject to the simple bounds. (In the linear programming literature, the approach is often called elastic programming.)

### 10.4  Miscellaneous

If the basis matrix is not chosen carefully, the condition of the null space matrix $Z$ in (8) could be arbitrarily high. To guard against this, the routine implements a ‘basis repair’ feature in which the LUSOL package (see Gill et al. (1991)) is used to compute the rectangular factorization
 $B S T=LU,$ (15)
returning just the permutation $P$ that makes $PL{P}^{\mathrm{T}}$ unit lower triangular. The pivot tolerance is set to require ${\left|PL{P}^{\mathrm{T}}\right|}_{ij}\le 2$, and the permutation is used to define $P$ in (7). It can be shown that $‖Z‖$ is likely to be little more than unity. Hence, $Z$ should be well-conditioned regardless of the condition of $W$. This feature is applied at the beginning of the optimality phase if a potential $B-S$ ordering is known.
The EXPAND procedure (see Gill et al. (1989)) is used to reduce the possibility of cycling at a point where the active constraints are nearly linearly dependent. Although there is no absolute guarantee that cycling will not occur, the probability of cycling is extremely small (see Hall and McKinnon (1996)). The main feature of EXPAND is that the feasibility tolerance is increased at the start of every iteration. This allows a positive step to be taken at every iteration, perhaps at the expense of violating the bounds on $\left(x,s\right)$ by a small amount.
Suppose that the value of the optional parameter Feasibility Tolerance is $\delta$. Over a period of $K$ iterations (where $K$ is the value of the optional parameter Expand Frequency), the feasibility tolerance actually used by the routine (i.e., the working feasibility tolerance) increases from $0.5\delta$ to $\delta$ (in steps of $0.5\delta /K$).
At certain stages the following ‘resetting procedure’ is used to remove small constraint infeasibilities. First, all nonbasic variables are moved exactly onto their bounds. A count is kept of the number of nontrivial adjustments made. If the count is nonzero, the basic variables are recomputed. Finally, the working feasibility tolerance is reinitialized to $0.5\delta$.
If a problem requires more than $K$ iterations, the resetting procedure is invoked and a new cycle of iterations is started. (The decision to resume the feasibility phase or optimality phase is based on comparing any constraint infeasibilities with $\delta$.)
The resetting procedure is also invoked when the routine reaches an apparently optimal, infeasible or unbounded solution, unless this situation has already occurred twice. If any nontrivial adjustments are made, iterations are continued.
The EXPAND procedure not only allows a positive step to be taken at every iteration, but also provides a potential choice of constraints to be added to the working set. All constraints at a distance $\alpha$ (where $\alpha \le {\alpha }_{N}$) along $p$ from the current point are then viewed as acceptable candidates for inclusion in the working set. The constraint whose normal makes the largest angle with the search direction is added to the working set. This strategy helps keep the basis matrix $B$ well-conditioned.

## 11  Optional Parameters

Several optional parameters in E04NQF define choices in the problem specification or the algorithm logic. In order to reduce the number of formal parameters of E04NQF these optional parameters have associated default values that are appropriate for most problems. Therefore, you need only specify those optional parameters whose values are to be different from their default values.
The remainder of this section can be skipped if you wish to use the default values for all optional parameters.
The following is a list of the optional parameters available. A full description of each optional parameter is provided in Section 11.1.
Optional parameters may be specified by calling one, or any, of the routines E04NRF, E04NSF, E04NTF and E04NUF before a call to E04NQF, but after a call to E04NPF.
E04NRF reads options from an external options file, with Begin and End as the first and last lines respectively and each intermediate line defining a single optional parameter. For example,
```Begin
Print Level = 5
End
```
The call
``` CALL E04NRF (ISPECS, CW, IW, RW, IFAIL)
```
can then be used to read the file on unit ISPECS. IFAIL will be zero on successful exit. E04NRF should be consulted for a full description of this method of supplying optional parameters.
E04NSF, E04NTF or E04NUF can be called to supply options directly, one call being necessary for each optional parameter. E04NSF, E04NTF or E04NUF should be consulted for a full description of this method of supplying optional parameters.
All optional parameters not specified by you are set to their default values. Optional parameters specified by you are unaltered by E04NQF (unless they define invalid values) and so remain in effect for subsequent calls unless altered by you.

### 11.1  Description of the Optional Parameters

For each option, we give a summary line, a description of the optional parameter and details of constraints.
The summary line contains:
• the keywords, where the minimum abbreviation of each keyword is underlined (if no characters of an optional qualifier are underlined, the qualifier may be omitted);
• a parameter value, where the letters $a$, $i\text{​ and ​}r$ denote options that take character, integer and real values respectively;
• the default value is used whenever the condition $\left|i\right|\ge 100000000$ is satisfied and where the symbol $\epsilon$ is a generic notation for machine precision (see X02AJF);
• The variable $\mathit{bigbnd}$ holds the value of Infinite Bound Size.
Keywords and character values are case and white space insensitive.
 Check Frequency $i$ Default $\text{}=60$
Every $i$th iteration after the most recent basis factorization, a numerical test is made to see if the current solution $\left(x,s\right)$ satisfies the linear constraints $Ax-s=0$. If the largest element of the residual vector $r=Ax-s$ is judged to be too large, the current basis is refactorized and the basic variables recomputed to satisfy the constraints more accurately. If $i\le 0$, the value $i=99999999$ is used and effectively no checks are made.
${\mathbf{Check Frequency}}=1$ is useful for debugging purposes, but otherwise this option should not be needed.
 Crash Option $i$ Default $\text{}=3$
 Crash Tolerance $r$ Default $\text{}=0.1$
Note that these options do not apply when ${\mathbf{START}}=\text{'W'}$ (see Section 5).
If ${\mathbf{START}}=\text{'C'}$, an internal Crash procedure is used to select an initial basis from various rows and columns of the constraint matrix $\left(\begin{array}{cc}A& -I\end{array}\right)$. The value of $i$ determines which rows and columns of $A$ are initially eligible for the basis, and how many times the Crash procedure is called. Columns of $-I$ are used to pad the basis where necessary.
 $i$ Meaning $0$ The initial basis contains only slack variables: $B=I$. $1$ The Crash procedure is called once, looking for a triangular basis in all rows and columns of the matrix $A$. $2$ The Crash procedure is called once, looking for a triangular basis in rows. $3$ The Crash procedure is called twice, treating linear equalities and linear inequalities separately.
If $i\ge 1$, certain slacks on inequality rows are selected for the basis first. (If $i\ge 2$, numerical values are used to exclude slacks that are close to a bound.) The Crash procedure then makes several passes through the columns of $A$, searching for a basis matrix that is essentially triangular. A column is assigned to ‘pivot’ on a particular row if the column contains a suitably large element in a row that has not yet been assigned. (The pivot elements ultimately form the diagonals of the triangular basis.) For remaining unassigned rows, slack variables are inserted to complete the basis.
The Crash Tolerance allows the Crash procedure to ignore certain ‘small’ nonzero elements in each column of $A$. If ${a}_{\mathrm{max}}$ is the largest element in column $j$, other nonzeros ${a}_{ij}$ in the column are ignored if $\left|{a}_{ij}\right|\le {a}_{\mathrm{max}}×r$. (To be meaningful, $r$ should be in the range $0\le r<1$.)
When $r>0.0$, the basis obtained by the Crash procedure may not be strictly triangular, but it is likely to be nonsingular and almost triangular. The intention is to obtain a starting basis containing more columns of $A$ and fewer (arbitrary) slacks. A feasible solution may be reached sooner on some problems.
For example, suppose the first $m$ columns of $A$ form the matrix shown under LU Factor Tolerance; i.e., a tridiagonal matrix with entries $-1$, $4$, $-1$. To help the Crash procedure choose all $m$ columns for the initial basis, we would specify a Crash Tolerance of $r$ for some value of $r>0.5$.
 Defaults
This special keyword may be used to reset all optional parameters to their default values.
 Dump File ${i}_{1}$ Default $\text{}=0$
 Load File ${i}_{2}$ Default $\text{}=0$
Optional parameters Dump File and Load File are similar to optional parameters Punch File and Insert File, but they record solution information in a manner that is more direct and more easily modified. A full description of information recorded in optional parameters Dump File and Load File is given in Gill et al. (2005a).
If ${i}_{1}>0$, the last solution obtained will be output to the file with unit number $i$.
If ${i}_{2}>0$, the Load File containing basis information will be read. The file will usually have been output previously as a Dump File. The file will not be accessed if optional parameters Old Basis File or Insert File are specified.
 Elastic Mode $i$ Default $\text{}=1$
This parameter determines if (and when) elastic mode is to be started. Three elastic modes are available as follows:
 $i$ Meaning $0$ Elastic mode is never invoked. E04NQF will terminate as soon as infeasibility is detected. There may be other points with significantly smaller sums of infeasibilities. $1$ Elastic mode is invoked only if the constraints are found to be infeasible (the default). If the constraints are infeasible, continue in elastic mode with the composite objective determined by the values of the optional parameters Elastic Objective and Elastic Weight. $2$ The iterations start and remain in elastic mode. This option allows you to minimize the composite objective function directly without first performing Phase 1 iterations. The success of this option will depend critically on your choice of Elastic Weight. If Elastic Weight is sufficiently large and the constraints are feasible, the minimizer of the composite objective and the solution of the original problem are identical. However, if the Elastic Weight is not sufficiently large, the minimizer of the composite function may be infeasible, even if a feasible point exists.
 Elastic Objective $i$ Default $\text{}=1$
This determines the form of the composite objective $f\left(x\right)+\gamma \sum _{j}\phantom{\rule{0.25em}{0ex}}\left({v}_{j}+{w}_{j}\right)$ in Phase 2 ($\gamma$). Three types of composite objectives are available.
 $i$ Meaning $0$ Include only the true objective $f\left(x\right)$ in the composite objective. This option sets $\gamma =0$ in the composite objective and allows E04NQF to ignore the elastic bounds and find a solution that minimizes $f\left(x\right)$ subject to the non-elastic constraints. This option is useful if there are some ‘soft’ constraints that you would like to ignore if the constraints are infeasible. $1$ Use a composite objective defined with $\gamma$ determined by the value of Elastic Weight. This value is intended to be used in conjunction with ${\mathbf{Elastic Mode}}=2$. $2$ Include only the elastic variables in the composite objective. The elastics are weighted by $\gamma =1$. This choice minimizes the violations of the elastic variables at the expense of possibly increasing the true objective. This option can be used to find a point that minimizes the sum of the violations of a subset of constraints specified by the input array HELAST.
 Elastic Weight $r$ Default $\text{}=1.0$
This defines the value of $\gamma$ in the composite objective in Phase 2 ($\gamma$).
At each iteration of elastic mode, the composite objective is defined to be
 $minimize​ ​σ ​ ​ fx + γ ​ (sum of infeasibilities);$
where $\sigma =1$ for Minimize, $\sigma =-1$ for Maximize, and $f\left(x\right)$ is the quadratic objective.
Note that the effect of $\gamma$ is not disabled once a feasible point is obtained.
 Expand Frequency $i$ Default $\text{}=10000$
This option is part of an anti-cycling procedure (see Section 10.4) designed to allow progress even on highly degenerate problems.
The strategy is to force a positive step at every iteration, at the expense of violating the constraints by a small amount. Suppose that the value of the optional parameter Feasibility Tolerance is $\delta$. Over a period of $i$ iterations, the feasibility tolerance actually used by E04NQF (i.e., the working feasibility tolerance) increases from $0.5\delta$ to $\delta$ (in steps of $0.5\delta /i$).
Increasing the value of $i$ helps reduce the number of slightly infeasible nonbasic variables (most of which are eliminated during the resetting procedure). However, it also diminishes the freedom to choose a large pivot element (see the description of the optional parameter Pivot Tolerance).
If $i\le 0$, the value $i=99999999$ is used and effectively no anti-cycling procedure is invoked.
 Factorization Frequency $i$ Default $\text{}=100\left(\mathrm{LP}\right)$ or $50\left(\mathrm{QP}\right)$
If $i>0$, at most $i$ basis changes will occur between factorizations of the basis matrix.
For LP problems, the basis factors are usually updated at every iteration. Higher values of $i$ may be more efficient on problems that are extremely sparse and well scaled.
For QP problems, fewer basis updates will occur as the solution is approached. The number of iterations between basis factorizations will therefore increase. During these iterations a test is made regularly according to the value of optional parameter Check Frequency to ensure that the linear constraints $Ax-s=0$ are satisfied. Occasionally, the basis will be refactorized before the limit of $i$ updates is reached. If $i\le 0$, the default value is used.
 Feasibility Tolerance $r$ Default $\text{}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left\{{10}^{-6},\sqrt{\epsilon }\right\}$
A feasible problem is one in which all variables satisfy their upper and lower bounds to within the absolute tolerance $r$. (This includes slack variables. Hence, the general constraints are also satisfied to within $r$.)
E04NQF attempts to find a feasible solution before optimizing the objective function. If the sum of infeasibilities cannot be reduced to zero, the problem is assumed to be infeasible. Let sInf be the corresponding sum of infeasibilities. If sInf is quite small, it may be appropriate to raise $r$ by a factor of $10$ or $100$. Otherwise, some error in the data should be suspected.
Note that if sInf is not small and you have not asked E04NQF to minimize the violations of the elastic variables (i.e., you have not specified ${\mathbf{Elastic Objective}}=2$), there may be other points that have a significantly smaller sum of infeasibilities. E04NQF will not attempt to find the solution that minimizes the sum unless ${\mathbf{Elastic Objective}}=2$.
If the constraints and variables have been scaled (see the description of the optional parameter Scale Option), then feasibility is defined in terms of the scaled problem (since it is more likely to be meaningful).
 Infinite Bound Size $r$ Default $\text{}={10}^{20}$
If $r\ge 0$, $r$ defines the ‘infinite’ bound $\mathit{infbnd}$ in the definition of the problem constraints. Any upper bound greater than or equal to $\mathit{infbnd}$ will be regarded as $+\infty$ (and similarly any lower bound less than or equal to $-\mathit{infbnd}$ will be regarded as $-\infty$). If $r<0$, the default value is used.
 Iterations Limit $i$ Default $\text{}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left\{10000,10\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left\{m,n\right\}\right\}$
The value of $i$ specifies the maximum number of iterations allowed before termination. Setting $i=0$ and ${\mathbf{Print Level}}>0$ means that: the workspace needed to start solving the problem will be computed and printed; and feasibility and optimality will be checked. No iterations will be performed. If $i<0$, the default value is used.
 LU Density Tolerance ${r}_{1}$ Default $\text{}=0.6$
 LU Singularity Tolerance ${r}_{2}$ Default $\text{}={\epsilon }^{\frac{2}{3}}$
The density tolerance ${r}_{1}$ is used during $LU$ factorization of the basis matrix. Columns of $L$ and rows of $U$ are formed one at a time, and the remaining rows and columns of the basis are altered appropriately. At any stage, if the density of the remaining matrix exceeds ${r}_{1}$, the Markowitz strategy for choosing pivots is terminated. The remaining matrix is factored by a dense $LU$ procedure. Raising the density tolerance towards $1.0$ may give slightly sparser $LU$ factors, with a slight increase in factorization time.
If ${r}_{2}>0$, ${r}_{2}$ defines the singularity tolerance used to guard against ill-conditioned basis matrices. After $B$ is refactorized, the diagonal elements of $U$ are tested as follows. If $\left|{u}_{jj}\right|\le {r}_{2}$ or $\left|{u}_{jj}\right|<{r}_{2}\underset{i}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}\left|{u}_{ij}\right|$, the $j$th column of the basis is replaced by the corresponding slack variable. If ${r}_{2}\le 0$, the default value is used.
 LU Factor Tolerance ${r}_{1}$ Default $\text{}=100.0$
 LU Update Tolerance ${r}_{2}$ Default $\text{}=10.0$
The values of ${r}_{1}$ and ${r}_{2}$ affect the stability and sparsity of the basis factorization $B=LU$, during refactorization and updates respectively. The lower triangular matrix $L$ is a product of matrices of the form
 $1 0 μ 1$
where the multipliers $\mu$ will satisfy $\left|\mu \right|\le {r}_{i}$. The default values of ${r}_{1}$ and ${r}_{2}$ usually strike a good compromise between stability and sparsity. They must satisfy ${r}_{1}$, ${r}_{2}\ge 1.0$.
For large and relatively dense problems, ${r}_{1}=10.0\text{​ or ​}5.0$ (say) may give a useful improvement in stability without impairing sparsity to a serious degree.
For certain very regular structures (e.g., band matrices) it may be necessary to reduce ${r}_{1}\text{​ and/or ​}{r}_{2}$ in order to achieve stability. For example, if the columns of $A$ include a sub-matrix of the form
 $4 -1 -1 4 -1 -1 4 -1 … … … -1 4 -1 -1 4 ,$
one should set both ${r}_{1}$ and ${r}_{2}$ to values in the range $1.0\le {r}_{i}<4.0$.
 LU Partial Pivoting Default
 LU Complete Pivoting
 LU Rook Pivoting
The $LU$ factorization implements a Markowitz-type search for pivots that locally minimize the fill-in subject to a threshold pivoting stability criterion. The default option is to use threshold partial pivoting. The options LU Complete Pivoting and LU Rook Pivoting are more expensive but more stable and better at revealing rank, as long as the LU Factor Tolerance is not too large (say $<2.0$).
 Minimize Default
 Maximize
 Feasible Point
This option specifies the required direction of the optimization. It applies to both linear and nonlinear terms (if any) in the objective function. Note that if two problems are the same except that one minimizes $f\left(x\right)$ and the other maximizes $-f\left(x\right)$, their solutions will be the same but the signs of the dual variables ${\pi }_{i}$ and the reduced gradients ${d}_{j}$ (see Section 10.3) will be reversed.
The option Feasible Point means ‘ignore the objective function, while finding a feasible point for the linear constraints’. It can be used to check that the constraints are feasible without altering the call to E04NQF.
 New Basis File ${i}_{1}$ Default $\text{}=0$
 Backup Basis File ${i}_{2}$ Default $\text{}=0$
 Save Frequency ${i}_{3}$ Default $\text{}=100$
Optional parameters New Basis File and Backup Basis File are sometimes referred to as basis maps. They contain the most compact representation of the state of each variable. They are intended for restarting the solution of a problem at a point that was reached by an earlier run. For nontrivial problems, it is advisable to save basis maps at the end of a run, in order to restart the run if necessary.
If ${i}_{1}>0$, a basis map will be saved on file ${i}_{1}$ every ${i}_{3}$th iteration, where ${i}_{3}$ is the Save Frequency. The first record of the file will contain the word PROCEEDING if the run is still in progress. A basis map will also be saved at the end of a run, with some other word indicating the final solution status.
Use of ${i}_{2}>0$ is intended as a safeguard against losing the results of a long run. Suppose that a New Basis File is being saved every $100$ (Save Frequency) iterations, and that E04NQF is about to save such a basis at iteration $2000$. It is conceivable that the run may be interrupted during the next few milliseconds (in the middle of the save). In this case the Basis file will be corrupted and the run will have been essentially wasted.
To eliminate this risk, both a New Basis File and a Backup Basis File may be specified. The following would be suitable for the above example:
```
Backup Basis File 11
New Basis File 12```
The current basis will then be saved every $100$ iterations, first on File 12 and then immediately on File 11. If the run is interrupted at iteration $2000$ during the save on File 12, there will still be a usable basis on File 11 (corresponding to iteration $1900$).
Note that a new basis will be saved in New Basis File at the end of a run if it terminates normally, but it will not be saved in Backup Basis File. In the above example, if an optimum solution is found at iteration $2050$ (or if the iteration limit is $2050$), the final basis on File 12 will correspond to iteration $2050$, but the last basis saved on File 11 will be the one for iteration $2000$.
A full description of information recorded in New Basis File and Backup Basis File is given in Gill et al. (2005a).
 Nolist Default
 List
Normally each optional parameter specification is printed to unit Print File as it is supplied. Optional parameter Nolist may be used to suppress the printing and optional parameter List may be used to restore printing.
 Old Basis File $i$ Default $\text{}=0$
If $i>0$, the basis maps information will be obtained from this file. The file will usually have been output previously as a New Basis File or Backup Basis File. A full description of information recorded in New Basis File and Backup Basis File is given in Gill et al. (2005a).
The file will not be acceptable if the number of rows or columns in the problem has been altered.
 Optimality Tolerance $r$ Default $\text{}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left\{{10}^{-6},\sqrt{\epsilon }\right\}$
This is used to judge the size of the reduced gradients ${d}_{j}={g}_{j}-{a}_{j}^{\mathrm{T}}\pi$, where ${g}_{j}$ is the $j$th component of the gradient, ${a}_{j}$ is the associated column of the constraint matrix $\left(\begin{array}{cc}A& -I\end{array}\right)$, and $\pi$ is the set of dual variables.
By construction, the reduced gradients for basic variables are always zero. The problem will be declared optimal if the reduced gradients for nonbasic variables at their lower or upper bounds satisfy
 $dj / π ≥ -r or dj / π ≤ r$
respectively, and if $\left|{d}_{j}\right|/‖\pi ‖\le r$ for superbasic variables.
In the above tests, $‖\pi ‖$ is a measure of the size of the dual variables. It is included to make the tests independent of a scale factor on the objective function. The quantity $‖\pi ‖$ actually used is defined by
 $π=maxσ/m,1 , where ​ σ= ∑ i=1 m πi,$
so that only large scale factors are allowed for.
If the objective is scaled down to be very small, the optimality test reduces to comparing ${d}_{j}$ against $0.01r$.
 Partial Price $i$ Default $\text{}=10\left(\mathrm{LP}\right)$ or $1\left(\mathrm{QP}\right)$
This option is recommended for large FP or LP problems that have significantly more variables than constraints (i.e., $n\gg m$). It reduces the work required for each pricing operation (i.e., when a nonbasic variable is selected to enter the basis). If $i=1$, all columns of the constraint matrix $\left(\begin{array}{cc}A& -I\end{array}\right)$ are searched. If $i>1$, $A$ and $I$ are partitioned to give $i$ roughly equal segments ${A}_{\mathit{j}},{I}_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,i$ (modulo $i$). If the previous pricing search was successful on ${A}_{j-1},{I}_{j-1}$, the next search begins on the segments ${A}_{j}$ and ${I}_{j}$. If a reduced gradient is found that is larger than some dynamic tolerance, the variable with the largest such reduced gradient (of appropriate sign) is selected to enter the basis. If nothing is found, the search continues on the next segments ${A}_{j+1},{I}_{j+1}$, and so on. If $i\le 0$, the default value is used.
 Pivot Tolerance $r$ Default $\text{}={\epsilon }^{\frac{2}{3}}$
Broadly speaking, the pivot tolerance is used to prevent columns entering the basis if they would cause the basis to become almost singular.
When $x$ changes to $x+\alpha p$ for some search direction $p$, a ‘ratio test’ determines which component of $x$ reaches an upper or lower bound first. The corresponding element of $p$ is called the pivot element. Elements of $p$ are ignored (and therefore cannot be pivot elements) if they are smaller than the pivot tolerance $r$.
It is common for two or more variables to reach a bound at essentially the same time. In such cases, the optional parameter Feasibility Tolerance (say $t$) provides some freedom to maximize the pivot element and thereby improve numerical stability. Excessively small values of $t$ should therefore not be specified. To a lesser extent, the optional parameter Expand Frequency (say $f$) also provides some freedom to maximize the pivot element. Excessively large values of $f$ should therefore not be specified.
 Print File $i$ Default $\text{}=0$
If $i>0$, the following information is output to $i$ during the solution of each problem:
 – a listing of the optional parameters; – some statistics about the problem; – the amount of storage available for the $LU$ factorization of the basis matrix; – notes about the initial basis resulting from a Crash procedure or a Basis file; – the iteration log; – basis factorization statistics; – the exit IFAIL condition and some statistics about the solution obtained; – the printed solution, if requested.
The last four items are described in Sections 8 and 12. Further brief output may be directed to the Summary File.
 Print Frequency $i$ Default $\text{}=100$
If $i>0$, one line of the iteration log will be printed every $i$th iteration. A value such as $i=10$ is suggested for those interested only in the final solution. If $i\le 0$, the value of $i=99999999$ is used and effectively no checks are made.
 Print Level $i$ Default $\text{}=1$
This controls the amount of printing produced by E04NQF as follows.
 $i$ Meaning 0 No output except error messages. If you want to suppress all output, set ${\mathbf{Print File}}=0$. $=1$ The set of selected options, problem statistics, summary of the scaling procedure, information about the initial basis resulting from a Crash or a Basis file, a single line of output at each iteration (controlled by the optional parameter Print Frequency), and the exit condition with a summary of the final solution. $\ge 10$ Basis factorization statistics.
 Punch File ${i}_{1}$ Default $=0$
 Insert File ${i}_{2}$ Default $=0$
These files provide compatibility with commercial mathematical programming systems. The Punch File from a previous run may be used as an Insert File for a later run on the same problem. A full description of information recorded in Insert File and Punch File is given in Gill et al. (2005a).
If ${i}_{1}>0$, the final solution obtained will be output to file ${i}_{1}$. For linear programs, this format is compatible with various commercial systems.
If ${i}_{2}>0$, the Insert File containing basis information will be read. The file will usually have been output previously as a Punch File. The file will not be accessed if Old Basis File is specified.
 QPSolver Cholesky Default
 QPSolver CG
 QPSolver QN
Specifies the active-set algorithm used to solve the quadratic program in Phase 2 ($\gamma$). QPSolver Cholesky holds the full Cholesky factor $R$ of the reduced Hessian ${Z}^{\mathrm{T}}HZ$. As the QP iterations proceed, the dimension of $R$ changes with the number of superbasic variables. If the number of superbasic variables needs to increase beyond the value of Reduced Hessian Dimension, the reduced Hessian cannot be stored and the solver switches to QPSolver CG. The Cholesky solver is reactivated if the number of superbasics stabilizes at a value less than Reduced Hessian Dimension.
QPSolver QN solves the QP using a quasi-Newton method. In this case, $R$ is the factor of a quasi-Newton approximate Hessian.
QPSolver CG uses an active-set method similar to QPSolver QN, but uses the conjugate-gradient method to solve all systems involving the reduced Hessian.
The Cholesky QP solver is the most robust, but may require a significant amount of computation if there are many superbasics.
The quasi-Newton QP solver does not require computation of the exact $R$ at the start of Phase 2 ($\gamma$). It may be appropriate when the number of superbasics is large but relatively few iterations are needed to reach a solution (e.g., if E04NQF is called with a Warm Start).
The conjugate-gradient QP solver is appropriate for problems with many degrees of freedom (say, more than $2000$ superbasics).
 Reduced Hessian Dimension $i$ Default $=1\left(\mathrm{LP}\right)\text{​ or ​}\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(2000,{n}_{H}+1,n\right)\left(\mathrm{QP}\right)$
This specifies that an $i$ by $i$ triangular matrix $R$ (to define the reduced Hessian according to ${R}^{\mathrm{T}}R={Z}^{\mathrm{T}}HZ$). is to be available for use by the Cholesky QP solver.
 Scale Option $i$ Default $\text{}=2$
 Scale Tolerance $r$ Default $\text{}=0.9$
 Scale Print
Three scale options are available as follows:
 $i$ Meaning 0 No scaling. This is recommended if it is known that $x$ and the constraint matrix never have very large elements (say, larger than $100$). 1 The constraints and variables are scaled by an iterative procedure that attempts to make the matrix coefficients as close as possible to $1.0$ (see Fourer (1982)). This will sometimes improve the performance of the solution procedures. 2 The constraints and variables are scaled by the iterative procedure. Also, a certain additional scaling is performed that may be helpful if the right-hand side $b$ or the solution $x$ is large. This takes into account columns of $\left(\begin{array}{cc}A& -I\end{array}\right)$ that are fixed or have positive lower bounds or negative upper bounds.
Optional parameter Scale Tolerance affects how many passes might be needed through the constraint matrix. On each pass, the scaling procedure computes the ratio of the largest and smallest nonzero coefficients in each column:
 $ρj=maxj aij / mini aij aij ≠ 0 .$
If $\underset{j}{\mathrm{max}}\phantom{\rule{0.25em}{0ex}}{\rho }_{j}$ is less than $r$ times its previous value, another scaling pass is performed to adjust the row and column scales. Raising $r$ from $0.9$ to $0.99$ (say) usually increases the number of scaling passes through $A$. At most $10$ passes are made. The value of $r$ should lie in the range $0.
Scale Print causes the row scales $r\left(i\right)$ and column scales $c\left(j\right)$ to be printed to Print File, if System Information Yes has been specified. The scaled matrix coefficients are ${\stackrel{-}{a}}_{ij}={a}_{ij}c\left(j\right)/r\left(i\right)$, and the scaled bounds on the variables and slacks are ${\stackrel{-}{l}}_{j}={l}_{j}/c\left(j\right)$, ${\stackrel{-}{u}}_{j}={u}_{j}/c\left(j\right)$, where $c\left(j\right)=r\left(j-n\right)$ if $j>n$.
 Solution Yes Default
 Solution No
This option determines if the final obtained solution is to be output to the Print File. Note that the Solution File option operates independently.
 Solution File $i$ Default $\text{}=0$
If $i>0$, the final solution will be output to file $i$ (whether optimal or not).
To see more significant digits in the printed solution, it will sometimes be useful to make $i$ refer to the system Print File.
 Summary File ${i}_{1}$ Default $\text{}=0$
 Summary Frequency ${i}_{2}$ Default $\text{}=100$
If ${i}_{1}>0$, the Summary File is output to file ${i}_{1}$, including a line of the iteration log every ${i}_{2}$th iteration. In an interactive environment, it is useful to direct this output to the terminal, to allow a run to be monitored online. (If something looks wrong, the run can be manually terminated.) Further details are given in Section 12. If ${i}_{2}\le 0$, the value of ${i}_{2}=99999999$ is used and effectively no checks are made.
 Superbasics Limit $i$ Default $\text{}=1\left(\mathrm{LP}\right)\text{​ or ​}\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left\{{n}_{H}+1,n\right\}\left(\mathrm{QP}\right)$
This places a limit on the storage allocated for superbasic variables. Ideally, $i$ should be set slightly larger than the ‘number of degrees of freedom’ expected at an optimal solution.
For linear programs, an optimum is normally a basic solution with no degrees of freedom. (The number of variables lying strictly between their bounds is no more than $m$, the number of general constraints.) The default value of $i$ is therefore $1$.
For quadratic problems, the number of degrees of freedom is often called the ‘number of independent variables’. Normally, $i$ need not be greater than ${n}_{H}+1$, where ${n}_{H}$ is the number of leading nonzero columns of $H$. For many problems, $i$ may be considerably smaller than ${n}_{H}$. This will save storage if ${n}_{H}$ is very large.
 Suppress Parameters
Normally E04NQF prints the options file as it is being read, and then prints a complete list of the available keywords and their final values. The optional parameter Suppress Parameters tells E04NQF not to print the full list.
 System Information No Default
 System Information Yes
This option prints additional information on the progress of major and minor iterations, and Crash statistics. See Section 12.
 Timing Level $i$ Default $\text{}=0$
If $i>0$, some timing information will be output to the Print file, if ${\mathbf{Print File}}>0$.
 Unbounded Step Size $r$ Default $\text{}=\mathit{infbnd}$
If $r>0$, $r$ specifies the magnitude of the change in variables that will be considered a step to an unbounded solution. (Note that an unbounded solution can occur only when the Hessian is not positive definite.) If the change in $x$ during an iteration would exceed the value of $r$, the objective function is considered to be unbounded below in the feasible region. If $r\le 0$, the default value is used. See Infinite Bound Size for the definition of $\mathit{infbnd}$.

## 12  Description of Monitoring Information

This section describes the intermediate printout and final printout which constitutes the monitoring information produced by E04NQF. (See also the description of the optional parameters Print File and Print Level.) You can control the level of printed output.

### 12.1  Crash Statistics

When ${\mathbf{Print Level}}\ge 10$, ${\mathbf{Print File}}>0$ and System Information Yes has been specified, the following lines of intermediate printout (less than $120$ characters) are produced on the unit number specified by optional parameter Print File whenever ${\mathbf{START}}=\text{'C'}$ (see Section 5). They refer to the number of columns selected by the Crash procedure during each of several passes through $A$, whilst searching for a triangular basis matrix.
 Label Description Slacks is the number of slacks selected initially. Free cols is the number of free columns in the basis, including those whose bounds are rather far apart. Preferred is the number of ‘preferred’ columns in the basis (i.e., ${\mathbf{HS}}\left(j\right)=3$ for some $j\le n$). It will be a subset of the columns for which ${\mathbf{HS}}\left(j\right)=3$ was specified. Unit is the number of unit columns in the basis. Double is the number of double columns in the basis. Triangle is the number of triangular columns in the basis. Pad is the number of slacks used to pad the basis (to make it a nonsingular triangle).

### 12.2  Basis Factorization Statistics

When ${\mathbf{Print Level}}\ge 10$ and ${\mathbf{Print File}}>0$, the first seven items of intermediate printout in the list below are produced on the unit number specified by optional parameter Print File whenever the matrix $B$ or ${B}_{S}={\left(\begin{array}{cc}B& S\end{array}\right)}^{\mathrm{T}}$ is factorized. Gaussian elimination is used to compute an $LU$ factorization of $B$ or ${B}_{S}$, where $PL{P}^{\mathrm{T}}$ is a lower triangular matrix and $PUQ$ is an upper triangular matrix for some permutation matrices $P$ and $Q$. The factorization is stabilized in the manner described under the optional parameter LU Factor Tolerance. In addition, if System Information Yes has been specified, the entries from Elems onwards are also output.
Label Description
Factor the number of factorizations since the start of the run.
Demand a code giving the reason for the present factorization, as follows:
 Code Meaning 0 First $LU$ factorization. 1 The number of updates reached the Factorization Frequency. 2 The nonzeros in the updated factors have increased significantly. 7 Not enough storage to update factors. 10 Row residuals are too large (see the description of the optional parameter Check Frequency). 11 Ill-conditioning has caused inconsistent results.
Itn is the current minor iteration number.
Nonlin is the number of nonlinear variables in the current basis $B$.
Linear is the number of linear variables in $B$.
Slacks is the number of slack variables in $B$.
B, BR, BS or BT factorize is the type of $LU$ factorization.
 B periodic factorization of the basis $B$. BR more careful rank-revealing factorization of $B$ using threshold rook pivoting. This occurs mainly at the start, if the first basis factors seem singular or ill-conditioned. Followed by a normal B factorize. BS ${B}_{S}$ is factorized to choose a well-conditioned $B$ from the current . Followed by a normal B factorize. BT same as BS except the current $B$ is tried first and accepted if it appears to be not much more ill-conditioned than after the previous BS factorize.
m is the number of rows in $B$ or ${B}_{S}$.
n is the number of columns in $B$ or ${B}_{S}$. Preceded by ‘=’ or ‘>’ respectively.
Elems is the number of nonzero elements in $B$ or ${B}_{S}$.
Amax is the largest nonzero in $B$ or ${B}_{S}$.
Density is the percentage nonzero density of $B$ or ${B}_{S}$.
Merit/MerRP/MerCP Merit is the average Markowitz merit count for the elements chosen to be the diagonals of $PUQ$. Each merit count is defined to be $\left(c-1\right)\left(r-1\right)$ where $c$ and $r$ are the number of nonzeros in the column and row containing the element at the time it is selected to be the next diagonal. Merit is the average of n such quantities. It gives an indication of how much work was required to preserve sparsity during the factorization. If LU Complete Pivoting or LU Rook Pivoting has been selected, this heading is changed to MerCP, respectively MerRP.
lenL is the number of nonzeros in $L$.
L+U is the number of nonzeros representing the basis factors $L$ and $U$. Immediately after a basis factorization $B=LU$, this is lenL+lenU, the number of subdiagonal elements in the columns of a lower triangular matrix and the number of diagonal and superdiagonal elements in the rows of an upper-triangular matrix. Further nonzeros are added to L when various columns of $B$ are later replaced. As columns of $B$ are replaced, the matrix $U$ is maintained explicitly (in sparse form). The value of L will steadily increase, whereas the value of U may fluctuate up or down. Thus the value of L+U may fluctuate up or down (in general, it will tend to increase).
Cmpressns is the number of times the data structure holding the partially factored matrix needed to be compressed to recover unused storage. Ideally this number should be zero. If it is more than $3$ or $4$, the amount of workspace available to E04NQF should be increased for efficiency.
Incres is the percentage increase in the number of nonzeros in $L$ and $U$ relative to the number of nonzeros in $B$ or ${B}_{S}$.
Utri is the number of triangular rows of $B$ or ${B}_{S}$ at the top of $U$.
lenU the number of nonzeros in $U$, including its diagonals.
Ltol is the largest subdiagonal element allowed in $L$. This is the specified LU Factor Tolerance or a smaller value that is currently being used for greater stability.
Umax the maximum nonzero element in $U$.
Ugrwth is the ratio $\mathtt{Umax}/\mathtt{Amax}$, which ideally should not be substantially larger than $10.0$ or $100.0$. If it is orders of magnitude larger, it may be advisable to reduce the LU Factor Tolerance to $5.0$, $4.0$, $3.0$ or $2.0$, say (but bigger than $1.0$).
As long as Lmax is not large (say $5.0$ or less), $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(\mathtt{Amax},\mathtt{Umax}\right)/\mathtt{DUmin}$ gives an estimate of the condition number $B$. If this is extremely large, the basis is nearly singular. Slacks are used to replace suspect columns of $B$ and the modified basis is refactored.
Ltri is the number of triangular columns of $B$ or ${B}_{S}$ at the left of $L$.
dense1 is the number of columns remaining when the density of the basis matrix being factorized reached $0.3$.
Lmax is the actual maximum subdiagonal element in $L$ (bounded by Ltol).
Akmax is the largest nonzero generated at any stage of the $LU$ factorization. (Values much larger than Amax indicate instability.) Akmax is not printed if LU Partial Pivoting is selected.
Agrwth is the ratio $\mathtt{Akmax}/\mathtt{Amax}$. Values much larger than $100$ (say) indicate instability. Agrwth is not printed if LU Partial Pivoting is selected.
bump is the size of the block to be factorized nontrivially after the triangular rows and columns of $B$ or ${B}_{S}$ have been removed.
dense2 is the number of columns remaining when the density of the basis matrix being factorized reached $0.6$. (The Markowitz pivot strategy searches fewer columns at that stage.)
DUmax is the largest diagonal of $PUQ$.
DUmin is the smallest diagonal of $PUQ$.
condU the ratio $\mathtt{DUmax}/\mathtt{DUmin}$, which estimates the condition number of $U$ (and of $B$ if Ltol is less than $5.0$, say).

### 12.3  Basis Map

When ${\mathbf{Print Level}}\ge 10$ and ${\mathbf{Print File}}>0$, the following lines of intermediate printout (less than $80$ characters) are produced on the unit number specified by optional parameter Print File. They refer to the elements of the NAMES array (see Section 5).
 Label Description Name gives the name for the problem (blank if problem unnamed). Infeasibilities gives the number of infeasibilities. Printed only if the final point is infeasible. Objective Value gives the objective value at the final point (or the value of the sum of infeasibilities). Printed only if the final point is feasible. Status gives the exit status for the problem (i.e., Optimal soln, Weak soln, Unbounded, Infeasible, Excess itns, Error condn or Feasble soln) followed by details of the direction of the optimization (i.e., (Min) or (Max)). Iteration gives the iteration number when the file was created. Superbasics gives the number of superbasic variables. Objective gives the name of the free row for the problem (blank if objective unnamed). RHS gives the name of the constraint right-hand side for the problem (blank if objective unnamed). Ranges gives the name of the ranges for the problem (blank if objective unnamed). Bounds gives the name of the bounds for the problem (blank if objective unnamed).

### 12.4  Solution Output

At the end of a run, the final solution will be output to the Print file. Some header information appears first to identify the problem and the final state of the optimization procedure. A ROWS section and a COLUMNS section then follow, giving one line of information for each row and column.

#### 12.4.1  The ROWS section

General constraints take the form $l\le Ax\le u$. The $i$th constraint is therefore of the form
 $α ≤ νi x ≤ β ,$
where ${\nu }_{i}$ is the $i$th row of $A$.
Internally, the constraints take the form $Ax-s=0$, where $s$ is the set of slack variables (which happen to satisfy the bounds $l\le s\le u$). For the $i$th constraint, the slack variable ${s}_{i}$ is directly available, and it is sometimes convenient to refer to its state. It should satisfy $\alpha \le {s}_{i}\le \beta$. A fullstop (.) is printed for any numerical value that is exactly zero.
Label Description
Number is the value of $n+i$. (This is used internally to refer to ${s}_{i}$ in the intermediate output.)
Row gives the name of ${\nu }_{i}$.
State the state of ${\nu }_{i}$ (the state of ${s}_{i}$ relative to the bounds $\alpha$ and $\beta$). The various states possible are as follows:
 LL ${s}_{i}$ is nonbasic at its lower limit, $\alpha$. UL ${s}_{i}$ is nonbasic at its upper limit, $\beta$. EQ ${s}_{i}$ is nonbasic and fixed at the value $\alpha =\beta$. FR ${s}_{i}$ is nonbasic and currently zero, even though it is free to take any value between its bounds $\alpha$ and $\beta$. BS ${s}_{i}$ is basic. SBS ${s}_{i}$ is superbasic.
A key is sometimes printed before State. Note that unless the optional parameter ${\mathbf{Scale Option}}=0$ is specified, the tests for assigning a key are applied to the variables of the scaled problem.
 A Alternative optimum possible. The variable is nonbasic, but its reduced gradient is essentially zero. This means that if the variable were allowed to start moving away from its bound, there would be no change in the value of the objective function. The values of the other free variables might change, giving a genuine alternative solution. However, if there are any degenerate variables (labelled D), the actual change might prove to be zero, since one of them could encounter a bound immediately. In either case, the values of the Lagrange multipliers might also change. D Degenerate. The variable is basic or superbasic, but it is equal (or very close) to one of its bounds. I Infeasible. The variable is basic or superbasic and is currently violating one of its bounds by more than the value of the Feasibility Tolerance. N Not precisely optimal. If the slack is superbasic, the dual variable ${\pi }_{i}$ is not sufficiently small, as measured by the Optimality Tolerance. If the slack is nonbasic, ${\pi }_{i}$ is not sufficiently positive or negative. If a loose Optimality Tolerance has been used, or if iterations were terminated before optimality, this key might be helpful in deciding whether or not to restart the run.
Activity is the value of ${\nu }_{i}x$ at the final iterate.
Slack Activity is the value by which the row differs from its nearest bound. (For the free row (if any), it is set to Activity.)
Lower Limit is $\alpha$, the lower bound specified for the variable ${s}_{i}$. None indicates that ${\mathbf{BL}}\left(j\right)\le -\mathit{infbnd}$.
Upper Limit is $\beta$, the upper bound specified for the variable ${s}_{i}$. None indicates that ${\mathbf{BU}}\left(j\right)\ge \mathit{infbnd}$.
Dual Activity is the value of the dual variable ${\pi }_{i}$ (the Lagrange multiplier for ${\nu }_{i}$; see Section 10.3). For FP problems, ${\pi }_{i}$ is set to zero.
i gives the index $i$ of the $i$th row.

#### 12.4.2  The COLUMNS Section

Let the $j$th component of $x$ be the variable ${x}_{j}$ and assume that it satisfies the bounds $\alpha \le {x}_{j}\le \beta$. A fullstop (.) is printed for any numerical value that is exactly zero.
Label Description
Number is the column number $j$. (This is used internally to refer to ${x}_{j}$ in the intermediate output.)
Column gives the name of ${x}_{j}$.
State the state of ${x}_{j}$ relative to the bounds $\alpha$ and $\beta$. The various states possible are as follows:
 LL ${x}_{j}$ is nonbasic at its lower limit, $\alpha$. UL ${x}_{j}$ is nonbasic at its upper limit, $\beta$. EQ ${x}_{j}$ is nonbasic and fixed at the value $\alpha =\beta$. FR ${x}_{j}$ is nonbasic and currently zero, even though it is free to take any value between its bounds $\alpha$ and $\beta$. BS ${x}_{j}$ is basic. SBS ${x}_{j}$ is superbasic.
A key is sometimes printed before State. Note that unless the optional parameter ${\mathbf{Scale Option}}=0$ is specified, the tests for assigning a key are applied to the variables of the scaled problem.
 A Alternative optimum possible. The variable is nonbasic, but its reduced gradient is essentially zero. This means that if the variable were allowed to start moving away from its bound, there would be no change in the value of the objective function. The values of the other free variables might change, giving a genuine alternative solution. However, if there are any degenerate variables (labelled D), the actual change might prove to be zero, since one of them could encounter a bound immediately. In either case, the values of the Lagrange multipliers might also change. D Degenerate. The variable is basic or superbasic, but it is equal (or very close) to one of its bounds. I Infeasible. The variable is basic or superbasic and is currently violating one of its bounds by more than the value of the Feasibility Tolerance. N Not precisely optimal. If the slack is superbasic, the dual variable ${\pi }_{i}$ is not sufficiently small, as measured by the Optimality Tolerance. If the slack is nonbasic, ${\pi }_{i}$ is not sufficiently positive or negative. If a loose Optimality Tolerance has been used, or if iterations were terminated before optimality, this key might be helpful in deciding whether or not to restart the run.
Activity is the value of ${x}_{j}$ at the final iterate.
Obj Gradient is the value of ${g}_{j}$ at the final iterate. For FP problems, ${g}_{j}$ is set to zero.
Lower Limit is the lower bound specified for the variable. None indicates that ${\mathbf{BL}}\left(j\right)\le -\mathit{infbnd}$.
Upper Limit is the upper bound specified for the variable. None indicates that ${\mathbf{BU}}\left(j\right)\ge \mathit{infbnd}$.
Reduced Gradnt is the value of ${d}_{j}$ at the final iterate (see Section 10.3). For FP problems, ${d}_{j}$ is set to zero.
m + j is the value of $m+j$.
Note:  if two problems are the same except that one minimizes $f\left(x\right)$ and the other maximizes $-f\left(x\right)$, their solutions will be the same but the signs of the dual variables ${\pi }_{i}$ and the reduced gradients ${d}_{j}$ will be reversed.

### 12.5  The Solution File

If a positive Solution File is specified, the information contained in a printed solution may also be output to the relevant file (which may be the Print file if so desired). Infinite Upper and Lower limits appear as $±{10}^{20}$ rather than None. Other real values are output with format 1pe16.6. The maximum line length is $111$ characters, including what would be the carriage-control character if the file were printed.
A Solution file is intended to be read from disk by a self-contained program that extracts and saves certain values as required for possible further computation. Typically the first $14$ lines would be ignored. Each subsequent line may be read using
```FORMAT (i8, 2x, 2a4, 1x, a1, 1x, a3, 5e16.6, i7)
```
adapted to suit the occasion. The end of the ROWS section is marked by a line that starts with a $1$ and is otherwise blank. If this and the next $4$ lines are skipped, the COLUMNS section (see Section 12.4.2) can then be read under the same format. (There should be no need to use any BACKSPACE statements.)

### 12.6  The Summary File

If Summary File $f$ is specified with $f>0$, certain brief information will be output to unit $f$. When E04NQF is run interactively, unit $f$ will usually be the terminal. For batch jobs a disk file should be used, to retain a concise log of each run if desired. (A Summary File is more easily perused than the associated Print file).
A Summary file (like the Print file) is not rewound after a problem has been processed. The maximum line length is $72$ characters, including a carriage-control character in column 1.
The following information is included:
1. The optional parameters supplied via the option setting routines, if any;
2. The Basis file loaded, if any;
3. The status of the solution after each basis factorization (whether feasible; the objective value; the number of function calls so far);
4. The same information every $k$th iteration, where $k$ is the specified Summary Frequency;
5. Warnings and error messages;
6. The exit condition and a summary of the final solution.
Item 4. is preceded by a blank line, but item 5. is not.
The meaning of the printout for linear constraints is the same as that given above for variables, with ‘variable’ replaced by ‘constraint’, $n$ replaced by $m$, ${\mathbf{NAMES}}\left(j\right)$ replaced by ${\mathbf{NAMES}}\left(n+j\right)$, ${\mathbf{BL}}\left(j\right)$ and ${\mathbf{BU}}\left(j\right)$ are replaced by ${\mathbf{BL}}\left(n+j\right)$ and ${\mathbf{BU}}\left(n+j\right)$ respectively, and with the following change in the heading:
 Constrnt gives the name of the linear constraint.
Note that movement off a constraint (as opposed to a variable moving away from its bound) can be interpreted as allowing the entry in the Residual column to become positive.
Numerical values are output with a fixed number of digits; they are not guaranteed to be accurate to this precision.