PDF version (NAG web site
, 64bit version, 64bit version)
NAG Toolbox: nag_opt_miqp_mps_read (e04mx)
Purpose
nag_opt_miqp_mps_read (e04mx) reads data for sparse linear programming, mixed integer linear programming, quadratic programming or mixed integer quadratic programming problems from an external file which is in standard or compatible MPS input format.
Syntax
[
n,
m,
nz,
ncolh,
nnzh,
lintvar,
iobj,
a,
irowa,
iccola,
bl,
bu,
pnames,
nname,
crname,
h,
irowh,
iccolh,
minmax,
intvar,
ifail] = e04mx(
infile,
maxn,
maxm,
maxnnz,
maxncolh,
maxnnzh,
maxlintvar,
mpslst,
pnames)
[
n,
m,
nz,
ncolh,
nnzh,
lintvar,
iobj,
a,
irowa,
iccola,
bl,
bu,
pnames,
nname,
crname,
h,
irowh,
iccolh,
minmax,
intvar,
ifail] = nag_opt_miqp_mps_read(
infile,
maxn,
maxm,
maxnnz,
maxncolh,
maxnnzh,
maxlintvar,
mpslst,
pnames)
Description
nag_opt_miqp_mps_read (e04mx) reads data for linear programming (LP) or quadratic programming (QP) problems (or their mixed integer variants) from an external file which is prepared in standard or compatible MPS (see
IBM (1971)) input format. It then initializes
$n$ (the number of variables),
$m$ (the number of general linear constraints), the
$m$ by
$n$ matrix
$A$, the vectors
$l$,
$u$,
$c$ (stored in row
iobj of
$A$) and the
$n$ by
$n$ Hessian matrix
$H$ for use with
nag_opt_qpconvex1_sparse_solve (e04nk) and
nag_opt_qpconvex2_sparse_solve (e04nq).
These functions are
designed to solve problems of the form
MPS input format
The input file of data may only contain two types of lines:
1. 
Indicator lines (specifying the type of data which is to follow). 
2. 
Data lines (specifying the actual data). 
A
section is a combination of an indicator line and its corresponding data line(s). Any characters beyond column 80 are ignored. Indicator lines must not contain leading blank characters (in other words they must begin in column 1). The following displays the order in which the indicator lines must appear in the file:
NAME 
usersupplied name 
(optional) 
OBJSENSE 
(optional) 

data line 
OBJNAME 
(optional) 

data line 
ROWS 

data line(s) 
COLUMNS 

data line(s) 
RHS 

data line(s) 
RANGES 
(optional) 

data line(s) 
BOUNDS 
(optional) 

data line(s) 
QUADOBJ 
(optional) 

data line(s) 
ENDATA 
A data line follows a fixed format, being made up of fields as defined below. The contents of the fields may have different significance depending upon the section of data in which they appear.

Field 1 
Field 2 
Field 3 
Field 4 
Field 5 
Field 6 
Columns 
$2\u20133$ 
$5\u201312$ 
$15\u201322$ 
$25\u201336$ 
$40\u201347$ 
$50\u201361$ 
Contents 
Code 
Name 
Name 
Value 
Name 
Value 
Each name and code must consist of ‘printable’ characters only; names and codes supplied must match the case used in the following descriptions. Values are read using a field width of $12$. This allows values to be entered in several equivalent forms. For example, $1.2345678$, $1.2345678$, $\text{123.45678e\u22122}$ and $\text{12345678e\u221207}$ all represent the same number. It is safest to include an explicit decimal point.
Lines with an asterisk ($*$) in column $1$ will be considered comment lines and will be ignored by the function.
Columns outside the six fields must be blank, except for columns 72–80, whose contents are ignored by the function. A nonblank character outside the predefined six fields and columns 72–80 is considered to be a major error (
${\mathbf{ifail}}={\mathbf{16}}$; see
Error Indicators and Warnings), unless it is part of a comment.
NAME Section (optional)
The NAME section is the only section where the data must be on the same line as the indicator. The ‘usersupplied name’ must be in field
$3$ but may be blank.
Field 
Required 
Description 
$3$ 
No 
Name of the problem 
OBJSENSE Section (optional)
The data line in this section can be used to specify the sense of the objective function. If this section is present it must contain only one data line. If the section is missing or empty, minimization is assumed.
Field 
Required 
Description 
$2$ 
No 
Sense of the objective function 
Field 2 may contain either MIN, MAX, MINIMIZE or MAXIMIZE.
OBJNAME Section (optional)
The data line in this section can be used to specify the name of a free row (see
ROWS Section) that should be used as the objective function. If this section is present it must contain only one data line. If the section is missing or is empty, the first free row will be chosen instead. Alternatively, OBJNAME can be overridden by setting nonempty
${\mathbf{pnames}}\left(2\right)$ (see
Arguments).
Field 
Required 
Description 
$2$ 
No 
Row name to be used as the objective function 
Field 2 must contain a valid row name.
ROWS Section
The data lines in this section specify unique row (constraint) names and their inequality types (i.e., unconstrained,
$=$,
$\ge $ or
$\le $).
Field 
Required 
Description 
$1$ 
Yes 
Inequality key 
$2$ 
Yes 
Row name 
The inequality key specifies each row's type. It must be
E,
G,
L or
N and can be in either column
$2$ or
$3$.
Inequality Key 
Description 
$\mathit{l}$ 
$\mathit{u}$ 
N 
Free row 
$\infty $ 
$\infty $ 
G 
Greater than or equal to 
finite 
$\infty $ 
L 
Less than or equal to 
$\infty $ 
finite 
E 
Equal to 
finite 
$l$ 
Row type
N stands for ‘Not binding’. It can be used to define the objective row. The objective row is a free row that specifies the vector
$c$ in the linear objective term
${c}^{\mathrm{T}}x$. If there is more than one free row, the first free row is chosen, unless another free row name is specified by OBJNAME (see
OBJNAME Section (optional)) or
${\mathbf{pnames}}\left(2\right)$ (see
Arguments). Note that
$c$ is assumed to be zero if either the chosen row does not appear in the COLUMNS section (i.e., has no nonzero elements) or there are no free rows defined in the ROWS section.
COLUMNS Section
Data lines in this section specify the names to be assigned to the variables (columns) in the general linear constraint matrix
$A$, and define, in terms of column vectors, the actual values of the corresponding matrix elements.
Field 
Required 
Description 
$2$ 
Yes 
Column name 
$3$ 
Yes 
Row name 
$4$ 
Yes 
Value 
$5$ 
No 
Row name 
$6$ 
No 
Value 
Each data line in the COLUMNS section defines the nonzero elements of $A$ or $c$. Any elements of $A$ or $c$ that are undefined are assumed to be zero. Nonzero elements of $A$ must be grouped by column, that is to say that all of the nonzero elements in the jth column of $A$ must be specified before those in the $\mathit{j}+1$th column, for $\mathit{j}=1,2,\dots ,n1$. Rows may appear in any order within the column.
Integer Markers
For backward compatibility
nag_opt_miqp_mps_read (e04mx) allows you to define the integer variables within the COLUMNS section using integer markers, although this is not recommended as markers can be treated differently by different MPS readers; you should instead define any integer variables in the BOUNDS section (see below). Each marker line must have the following format:
Field 
Required 
Description 
$2$ 
No 
Marker ID 
$3$ 
Yes 
Marker tag 
$5$ 
Yes 
Marker type 
The marker tag must be ${}^{\prime}$MARKER${}^{\prime}$. The marker type must be ${}^{\prime}$INTORG${}^{\prime}$ to start reading integer variables and ${}^{\prime}$INTEND${}^{\prime}$ to finish reading integer variables. This implies that a row cannot be named ${}^{\prime}$MARKER${}^{\prime}$, ${}^{\prime}$INTORG${}^{\prime}$ or ${}^{\prime}$INTEND${}^{\prime}$. Please note that both marker tag and marker type comprise of $8$ characters as a ${}^{\prime}$ is the mandatory first and last character in the string. You may wish to have several integer marker sections within the COLUMNS section, in which case each marker section must begin with an ${}^{\prime}$INTORG${}^{\prime}$ marker and end with an ${}^{\prime}$INTEND${}^{\prime}$ marker and there should not be another marker between them.
Field 2 is ignored by nag_opt_miqp_mps_read (e04mx). When an integer variable is declared it will keep its default bounds unless they are changed in the BOUNDS section. This may vary between different MPS readers.
RHS Section
This section specifies the righthand side values (if any) of the general linear constraint matrix
$A$.
Field 
Required 
Description 
$2$ 
Yes 
RHS name 
$3$ 
Yes 
Row name 
$4$ 
Yes 
Value 
$5$ 
No 
Row name 
$6$ 
No 
Value 
The MPS file may contain several RHS sets distinguished by RHS name. If an RHS name is defined in
${\mathbf{pnames}}\left(3\right)$ (see
Arguments) then
nag_opt_miqp_mps_read (e04mx) will read in only that RHS vector, otherwise the first RHS set will be used.
Only the nonzero RHS elements need to be specified. Note that if an RHS is given to the objective function it will be ignored by nag_opt_miqp_mps_read (e04mx). An RHS given to the objective function is dealt with differently by different MPS readers, therefore it is safer to not define an RHS of the objective function in your MPS file. Note that this section may be empty, in which case the RHS vector is assumed to be zero.
RANGES Section (optional)
Ranges are used to modify the interpretation of constraints defined in the ROWS section (see
ROWS Section) to the form
$l\le Ax\le u$, where both
$l$ and
$u$ are finite. The range of the constraint is
$r=ul$.
Field 
Required 
Description 
$2$ 
Yes 
Range name 
$3$ 
Yes 
Row name 
$4$ 
Yes 
Value 
$5$ 
No 
Row name 
$6$ 
No 
Value 
The range of each constraint implies an upper and lower bound dependent on the inequality key of each constraint, on the RHS
$b$ of the constraint (as defined in the RHS section), and on the range
$r$.
Inequality Key 
Sign of $\text{}\mathit{r}$ 
$\mathit{l}$ 
$\mathit{u}$ 
E 
$+$ 
$b$ 
$b+r$ 
E 
$$ 
$b+r$ 
$b$ 
G 
$+/$ 
$b$ 
$b+\leftr\right$ 
L 
$+/$ 
$b\leftr\right$ 
$b$ 
N 
$+/$ 
$\infty $ 
$+\infty $ 
If a range name is defined in
${\mathbf{pnames}}\left(4\right)$ (see
Arguments) then the function will read in only the range set of that name, otherwise the first set will be used.
BOUNDS Section (optional)
These lines specify limits on the values of the variables (the quantities
$l$ and
$u$ in
$l\le x\le u$). If a variable is not specified in the bound set then it is automatically assumed to lie between
$0$ and
$+\infty $.
Field 
Required 
Description 
$1$ 
Yes 
Bound type identifier 
$2$ 
Yes 
Bound name 
$3$ 
Yes 
Column name 
$4$ 
Yes/No 
Value 
Note: field 4 is required only if the bound type identifier is one of UP, LO, FX, UI or LI in which case it gives the value $k$ below. If the bound type identifier is FR, MI, PL or BV, field 4 is ignored and it is recommended to leave it blank.
The table below describes the acceptable bound type identifiers and how each determines the variables' bounds.
Bound Type Identifier 
$\mathit{l}$ 
$\mathit{u}$ 
Integer Variable? 
UP 
unchanged 
$k$ 
No 
LO 
$k$ 
unchanged 
No 
FX 
$k$ 
$k$ 
No 
FR 
$\infty $ 
$\infty $ 
No 
MI 
$\infty $ 
unchanged 
No 
PL 
unchanged 
$\infty $ 
No 
BV 
$0$ 
$1$ 
Yes 
UI 
unchanged 
$k$ 
Yes 
LI 
$k$ 
unchanged 
Yes 
If a bound name is defined in
${\mathbf{pnames}}\left(5\right)$ (see
Arguments) then the function will read in only the bound set of that name, otherwise the first set will be used.
QUADOBJ Section (optional)
The QUADOBJ section defines nonzero elements of the upper or lower triangle of the Hessian matrix
$H$.
Field 
Required 
Description 
$2$ 
Yes 
Column name (HColumn Index) 
$3$ 
Yes 
Column name (HRow Index) 
$4$ 
Yes 
Value 
$5$ 
No 
Column name (HRow Index) 
$6$ 
No 
Value 
Each data line in the QUADOBJ section defines one (or optionally two) nonzero elements
${H}_{ij}$ of the matrix
$H$. Each element
${H}_{ij}$ is given as a triplet of row index
$i$, column index
$j$ and a value. The column names (as defined in the COLUMNS section) are used to link the names of the variables and the indices
$i$ and
$j$. More precisely, the matrix
$H$ on output will have a nonzero element
where index
$j$ belongs to HColumn Index and index
$i$ to one of the HRow Indices such that
 ${\mathbf{crname}}\left(j\right)=\text{Column name (HColumn Index)}$ and
 ${\mathbf{crname}}\left(i\right)=\text{Column name (HRow Index)}$.
It is only necessary to define either the upper or lower triangle of the $H$ matrix; either will suffice. Any elements that have been defined in the upper triangle of the matrix will be moved to the lower triangle of the matrix, then any repeated nonzeros will be summed.
Note: it is much more efficient for
nag_opt_qpconvex1_sparse_solve (e04nk) and
nag_opt_qpconvex2_sparse_solve (e04nq)
to have the
$H$ matrix defined by the first
ncolh column names. If the nonzeros of
$H$ are defined by any columns that are not in the first
ncolh of
n then
nag_opt_miqp_mps_read (e04mx) will rearrange the matrices
$A$ and
$H$ so that they are.
Query Mode
nag_opt_miqp_mps_read (e04mx) offers a ‘query mode’ to quickly give upper estimates on the sizes of user arrays. In this mode any expensive checks of the data and of the file format are skipped, providing a prompt count of the number of variables, constraints and matrix nonzeros. This might be useful in the common case where the size of the problem is not known in advance.
You may activate query mode by setting any of the following:
${\mathbf{maxn}}<1$,
${\mathbf{maxm}}<1$,
${\mathbf{maxnnz}}<1$,
${\mathbf{maxncolh}}<0$ or
${\mathbf{maxnnzh}}<0$. If no major formatting error is detected in the data file,
${\mathbf{ifail}}={\mathbf{0}}$ is returned and the upper estimates are given as stated in
Table 1. Alternatively, the function switches to query mode while the file is being read if it is discovered that the provided space is insufficient (that is, if
${\mathbf{n}}>{\mathbf{maxn}}$,
${\mathbf{m}}>{\mathbf{maxm}}$,
${\mathbf{nz}}>{\mathbf{maxnnz}}$,
${\mathbf{ncolh}}>{\mathbf{maxncolh}}$,
${\mathbf{nnzh}}>{\mathbf{maxnnzh}}$ or
${\mathbf{lintvar}}>{\mathbf{maxlintvar}}$). In this case
${\mathbf{ifail}}={\mathbf{2}}$ is returned.
The recommended practice is shown in
Example, where the function is invoked twice. The first call queries the array lengths required, after which the data arrays are allocated to be of these sizes. The second call reads the data using the sufficientlysized arrays.
References
IBM (1971) MPSX – Mathematical programming system Program Number 5734 XM4 IBM Trade Corporation, New York
Parameters
Compulsory Input Parameters
 1:
$\mathrm{infile}$ – int64int32nag_int scalar

The ID of the MPSX data file to be read as returned by a call to
nag_file_open (x04ac).
Constraint:
${\mathbf{infile}}\ge 0$.
 2:
$\mathrm{maxn}$ – int64int32nag_int scalar

An upper limit for the number of variables in the problem.
If
${\mathbf{maxn}}<1$,
nag_opt_miqp_mps_read (e04mx) will start in query mode (see
Query Mode).
 3:
$\mathrm{maxm}$ – int64int32nag_int scalar

An upper limit for the number of general linear constraints (including the objective row) in the problem.
If
${\mathbf{maxm}}<1$,
nag_opt_miqp_mps_read (e04mx) will start in query mode (see
Query Mode).
 4:
$\mathrm{maxnnz}$ – int64int32nag_int scalar

An upper limit for the number of nonzeros (including the objective row) in the problem.
If
${\mathbf{maxnnz}}<1$,
nag_opt_miqp_mps_read (e04mx) will start in query mode (see
Query Mode).
 5:
$\mathrm{maxncolh}$ – int64int32nag_int scalar

An upper limit for the dimension of the matrix
$H$.
If
${\mathbf{maxncolh}}<0$,
nag_opt_miqp_mps_read (e04mx) will start in query mode (see
Query Mode).
 6:
$\mathrm{maxnnzh}$ – int64int32nag_int scalar

An upper limit for the number of nonzeros of the matrix
$H$.
If
${\mathbf{maxnnzh}}<0$,
nag_opt_miqp_mps_read (e04mx) will start in query mode (see
Query Mode).
 7:
$\mathrm{maxlintvar}$ – int64int32nag_int scalar

If
${\mathbf{maxlintvar}}\ge 0$, an upper limit for the number of integer variables.
If ${\mathbf{maxlintvar}}<0$, nag_opt_miqp_mps_read (e04mx) will treat all integer variables in the file as continuous variables.
 8:
$\mathrm{mpslst}$ – int64int32nag_int scalar

If
${\mathbf{mpslst}}\ne 0$, summary messages are sent to
the current advisory message unit (as defined by
nag_file_set_unit_advisory (x04ab))
as
nag_opt_miqp_mps_read (e04mx) reads through the data file. This can be useful for debugging the file. If
${\mathbf{mpslst}}=0$, then no summary is produced.
 9:
$\mathrm{pnames}\left(5\right)$ – cell array of strings

A set of names associated with the MPSX form of the problem.
 ${\mathbf{pnames}}\left(1\right)$
 Must either contain the name of the problem or be blank.
 ${\mathbf{pnames}}\left(2\right)$
 Must either be blank or contain the name of the objective row (in which case it overrides OBJNAME section and the default choice of the first objective free row).
 ${\mathbf{pnames}}\left(3\right)$
 Must either contain the name of the RHS set to be used or be blank (in which case the first RHS set is used).
 ${\mathbf{pnames}}\left(4\right)$
 Must either contain the name of the RANGE set to be used or be blank (in which case the first RANGE set (if any) is used).
 ${\mathbf{pnames}}\left(5\right)$
 Must either contain the name of the BOUNDS set to be used or be blank (in which case the first BOUNDS set (if any) is used).
Optional Input Parameters
None.
Output Parameters
 1:
$\mathrm{n}$ – int64int32nag_int scalar

If
nag_opt_miqp_mps_read (e04mx) was run in query mode (see
Query Mode), or returned with
${\mathbf{ifail}}={\mathbf{2}}$, an upper estimate of the number of variables of the problem. Otherwise,
$n$, the actual number of variables in the problem.
 2:
$\mathrm{m}$ – int64int32nag_int scalar

If
nag_opt_miqp_mps_read (e04mx) was run in query mode (see
Query Mode), or returned with
${\mathbf{ifail}}={\mathbf{2}}$, an upper estimate of the number of general linear constraints in the problem (including the objective row). Otherwise
$m$, the actual number of general linear constaints of the problem.
 3:
$\mathrm{nz}$ – int64int32nag_int scalar

If
nag_opt_miqp_mps_read (e04mx) was run in query mode (see
Query Mode), or returned with
${\mathbf{ifail}}={\mathbf{2}}$, an upper estimate of the number of nonzeros in the problem (including the objective row). Otherwise the actual number of nonzeros in the problem (including the objective row).
 4:
$\mathrm{ncolh}$ – int64int32nag_int scalar

If
nag_opt_miqp_mps_read (e04mx) was run in query mode (see
Query Mode), or returned with
${\mathbf{ifail}}={\mathbf{2}}$, an upper estimate of
the value of
ncolh required by
nag_opt_qpconvex1_sparse_solve (e04nk) and
nag_opt_qpconvex2_sparse_solve (e04nq).
In this context
ncolh is the number of leading nonzero columns of the Hessian matrix
$H$. Otherwise, the actual dimension of the matrix
$H$.
 5:
$\mathrm{nnzh}$ – int64int32nag_int scalar

If
nag_opt_miqp_mps_read (e04mx) was run in query mode (see
Query Mode), or returned with
${\mathbf{ifail}}={\mathbf{2}}$, an upper estimate of the number of nonzeros of the matrix
$H$. Otherwise, the actual number of nonzeros of the matrix
$H$.
 6:
$\mathrm{lintvar}$ – int64int32nag_int scalar

If on entry
${\mathbf{maxlintvar}}<0$, all integer variables are treated as continuous and
${\mathbf{lintvar}}=1$.
If
nag_opt_miqp_mps_read (e04mx) was run in query mode (see
Query Mode), or returned with
${\mathbf{ifail}}={\mathbf{2}}$, an upper estimate of the number of integer variables of the problem. Otherwise, the actual number of integer variables of the problem.
 7:
$\mathrm{iobj}$ – int64int32nag_int scalar

If
${\mathbf{iobj}}>0$, row
iobj of
$A$ is a free row containing the nonzero coefficients of the vector
$c$.
If ${\mathbf{iobj}}=0$, the coefficients of $c$ are assumed to be zero.
If
nag_opt_miqp_mps_read (e04mx) is run in query mode (see
Query Mode)
iobj is not referenced.
 8:
$\mathrm{a}\left({\mathbf{maxnnz}}\right)$ – double array

The nonzero elements of
$A$, ordered by increasing column index.
If
nag_opt_miqp_mps_read (e04mx) is run in query mode (see
Query Mode),
a is not referenced.
 9:
$\mathrm{irowa}\left({\mathbf{maxnnz}}\right)$ – int64int32nag_int array

The row indices of the nonzero elements stored in
a.
If
nag_opt_miqp_mps_read (e04mx) is run in query mode (see
Query Mode),
irowa is not referenced.
 10:
$\mathrm{iccola}\left({\mathbf{maxn}}+1\right)$ – int64int32nag_int array

A set of pointers to the beginning of each column of
$A$. More precisely,
${\mathbf{iccola}}\left(\mathit{i}\right)$ contains the index in
a of the start of the
$\mathit{i}$th column, for
$\mathit{i}=1,2,\dots ,{\mathbf{n}}$. Note that
${\mathbf{iccola}}\left(1\right)=1$ and
${\mathbf{iccola}}\left({\mathbf{n}}+1\right)={\mathbf{nz}}+1$.
If
nag_opt_miqp_mps_read (e04mx) is run in query mode (see
Query Mode),
iccola is not referenced.
 11:
$\mathrm{bl}\left({\mathbf{maxn}}+{\mathbf{maxm}}\right)$ – double array
 12:
$\mathrm{bu}\left({\mathbf{maxn}}+{\mathbf{maxm}}\right)$ – double array

bl contains the vector
$l$ (the lower bounds) and
bu contains the vector
$u$ (the upper bounds), for all the variables and constraints in the following order. The first
n elements of each array contains the bounds on the variables
$x$ and the next
m elements contains the bounds for the linear objective term
${c}^{\mathrm{T}}x$ and for the general linear constraints
$Ax$ (if any). Note that an ‘infinite’ lower bound is indicated by
${\mathbf{bl}}\left(j\right)=\text{1.0e+20}$ and an ‘infinite’ upper bound by
${\mathbf{bu}}\left(j\right)=+\text{1.0e+20}$. In other words, any element of
$u$ greater than or equal to
${10}^{20}$ will be regarded as
$+\infty $ (and similarly any element of
$l$ less than or equal to
${10}^{20}$ will be regarded as
$\infty $). If this value is deemed to be ‘inappropriate’,
before calling
nag_opt_qpconvex1_sparse_solve (e04nk) or
nag_opt_qpconvex2_sparse_solve (e04nq)
you are recommended to reset the value of its optional parameter
nag_opt_qpconvex1_sparse_solve (e04nk) and
nag_opt_qpconvex2_sparse_solve (e04nq)
and make any necessary changes to
bl and/or
bu.
If
nag_opt_miqp_mps_read (e04mx) is run in query mode (see
Query Mode),
bl and
bu are not referenced.
 13:
$\mathrm{pnames}\left(5\right)$ – cell array of strings

A set of names associated with the problem as defined in the MPSX data file as follows:
 ${\mathbf{pnames}}\left(1\right)$
 Contains the name of the problem (or blank if none).
 ${\mathbf{pnames}}\left(2\right)$
 Contains the name of the objective row (or blank if none).
 ${\mathbf{pnames}}\left(3\right)$
 Contains the name of the RHS set (or blank if none).
 ${\mathbf{pnames}}\left(4\right)$
 Contains the name of the RANGE set (or blank if none).
 ${\mathbf{pnames}}\left(5\right)$
 Contains the name of the BOUNDS set (or blank if none).
If
nag_opt_miqp_mps_read (e04mx) is run in query mode (see
Query Mode),
pnames is not referenced.
 14:
$\mathrm{nname}$ – int64int32nag_int scalar

$n+m$, the total number of variables and constraints in the problem (including the objective row).
If
nag_opt_miqp_mps_read (e04mx) was run in query mode (see
Query Mode), or returned with
${\mathbf{ifail}}={\mathbf{2}}$,
nname is not set.
 15:
$\mathrm{crname}\left({\mathbf{maxn}}+{\mathbf{maxm}}\right)$ – cell array of strings

The MPS names of all the variables and constraints in the problem in the following order. The first
n elements contain the MPS names for the variables and the next
m elements contain the MPS names for the objective row and general linear constraints (if any). Note that the MPS name for the objective row is stored in
${\mathbf{crname}}\left({\mathbf{n}}+{\mathbf{iobj}}\right)$.
If
nag_opt_miqp_mps_read (e04mx) is run in query mode (see
Query Mode),
crname is not referenced.
 16:
$\mathrm{h}\left(\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(0,{\mathbf{maxnnzh}}\right)\right)$ – double array

The
nnzh nonzero elements of
$H$, arranged by increasing column index.
If
nag_opt_miqp_mps_read (e04mx) is run in query mode (see
Query Mode),
h is not referenced.
 17:
$\mathrm{irowh}\left(\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(0,{\mathbf{maxnnzh}}\right)\right)$ – int64int32nag_int array

The
nnzh row indices of the elements stored in
$H$.
If
nag_opt_miqp_mps_read (e04mx) is run in query mode (see
Query Mode),
irowh is not referenced.
 18:
$\mathrm{iccolh}\left({\mathbf{maxncolh}}+1\right)$ – int64int32nag_int array

A set of pointers to the beginning of each column of
$H$. More precisely,
${\mathbf{iccolh}}\left(\mathit{i}\right)$ contains the index in
$H$ of the start of the
$\mathit{i}$th column, for
$\mathit{i}=1,2,\dots ,{\mathbf{ncolh}}$. Note that
${\mathbf{iccolh}}\left(1\right)=1$ and
${\mathbf{iccolh}}\left({\mathbf{ncolh}}+1\right)={\mathbf{nnzh}}+1$.
If
nag_opt_miqp_mps_read (e04mx) is run in query mode (see
Query Mode),
iccolh is not referenced.
 19:
$\mathrm{minmax}$ – int64int32nag_int scalar

minmax defines the direction of the optimization as read from the MPS file. By default the function assumes the objective function should be minimized and will return
${\mathbf{minmax}}=1$. If the function discovers in the OBJSENSE section that the objective function should be maximized it will return
${\mathbf{minmax}}=1$. If the function discovers that there is neither the linear objective term
$c$ (the objective row) nor the Hessian matrix
$H$, the problem is considered as a feasible point problem and
${\mathbf{minmax}}=0$ is returned.
If
nag_opt_miqp_mps_read (e04mx) was run in query mode (see
Query Mode), or returned with
${\mathbf{ifail}}={\mathbf{2}}$,
minmax is not set.
 20:
$\mathrm{intvar}\left(\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(0,{\mathbf{maxlintvar}}\right)\right)$ – int64int32nag_int array

If
${\mathbf{maxlintvar}}>0$ on entry,
intvar contains pointers to the columns that are defined as integer variables. More precisely,
${\mathbf{intvar}}\left(\mathit{i}\right)=k$, where
$k$ is the index of a column that is defined as an integer variable, for
$\mathit{i}=1,2,\dots ,{\mathbf{lintvar}}$.
If
${\mathbf{maxlintvar}}\le 0$ on entry, or
nag_opt_miqp_mps_read (e04mx) was run in query mode (see
Query Mode), or it returned with
${\mathbf{ifail}}={\mathbf{2}}$,
intvar is not set.
 21:
$\mathrm{ifail}$ – int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see
Error Indicators and Warnings).
Note that if any of the relevant arguments are accidentally set to zero, or not set and assume zero values, then the function will have executed in query mode. In this case only the size of the problem is returned and other arguments are not set. See
Query Mode.
Error Indicators and Warnings
Errors or warnings detected by the function:
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
 W ${\mathbf{ifail}}=1$

Warning: MPS file not strictly fixed format, although the problem was read anyway. The data may have been read incorrectly. You should set ${\mathbf{mpslst}}=1$ and repeat the call to nag_opt_miqp_mps_read (e04mx) for more details.
 ${\mathbf{ifail}}=2$

At least one of
maxm,
maxn,
maxnnz,
maxnnzh,
maxncolh or
maxlintvar is too small.
At least one of
maxm,
maxn,
maxnnz,
maxnnzh,
maxncolh or
maxlintvar is too small. Suggested values are returned in
m,
n,
nz,
nnzh,
ncolh and
lintvar respectively.
 ${\mathbf{ifail}}=3$

Incorrect ordering of indicator lines.
OBJNAME indicator line found after ROWS indicator line.
 ${\mathbf{ifail}}=4$

Incorrect ordering of indicator lines.
COLUMNS indicator line found before ROWS indicator line.
 ${\mathbf{ifail}}=5$

Incorrect ordering of indicator lines.
RHS indicator line found before COLUMNS indicator line.
 ${\mathbf{ifail}}=6$

Incorrect ordering of indicator lines.
RANGES indicator line found before RHS indicator line.
 ${\mathbf{ifail}}=7$

Incorrect ordering of indicator lines.
BOUNDS indicator line found before COLUMNS indicator line.
 ${\mathbf{ifail}}=8$

Incorrect ordering of indicator lines.
QUADOBJ indicator line found before BOUNDS indicator line.
 ${\mathbf{ifail}}=9$

Incorrect ordering of indicator lines.
QUADOBJ indicator line found before COLUMNS indicator line.
 ${\mathbf{ifail}}=10$

Unknown indicator line ‘$\_$’.
 ${\mathbf{ifail}}=12$

Indicator line ‘$\_$’ has been found more than once in the MPS file.
 ${\mathbf{ifail}}=13$

End of file found before ENDATA indicator line.
 ${\mathbf{ifail}}=14$

No indicator line found in file. It may be an empty file.
 ${\mathbf{ifail}}=15$

At least one mandatory section not found in MPS file.
 ${\mathbf{ifail}}=16$

An illegal line was detected in ‘$\_$’ section.
This is neither a comment nor a valid data line.
 ${\mathbf{ifail}}=17$

Unknown inequality key ‘$\_$’ in ROWS section.
Expected ‘N’, ‘G’, ‘L’ or ‘E’.
 ${\mathbf{ifail}}=18$

Empty ROWS section.
Neither the objective row nor the constraints were defined.
 ${\mathbf{ifail}}=19$

The supplied name, in ${\mathbf{pnames}}\left(2\right)$ or in OBJNAME, of the objective row was not found among the free rows in the ROWS section.
 ${\mathbf{ifail}}=20$

The supplied name, in ${\mathbf{pnames}}\left(5\right)$, of the BOUNDS set to be used was not found in the BOUNDS section.
 ${\mathbf{ifail}}=21$

The supplied name, in ${\mathbf{pnames}}\left(3\right)$, of the RHS set to be used was not found in the RHS section.
 ${\mathbf{ifail}}=22$

The supplied name, in ${\mathbf{pnames}}\left(4\right)$, of the RANGES set to be used was not found in the RANGES section.
 ${\mathbf{ifail}}=23$

Illegal row name.
Row names must consist of printable characters only.
 ${\mathbf{ifail}}=24$

Illegal column name.
Column names must consist of printable characters only.
 ${\mathbf{ifail}}=25$

Row name ‘$\_$’ has been defined more than once in the ROWS section.
 ${\mathbf{ifail}}=26$

Column ‘
$\_$’ has been defined more than once in the COLUMNS section. Column definitions must be continuous. (See
COLUMNS Section).
 ${\mathbf{ifail}}=27$

Found ‘INTORG’ marker within ‘INTORG’ to ‘INTEND’ range.
 ${\mathbf{ifail}}=28$

Found ‘INTEND’ marker without previous marker being ‘INTORG’.
 ${\mathbf{ifail}}=29$

Found ‘INTORG’ but not ‘INTEND’ before the end of the COLUMNS section.
 ${\mathbf{ifail}}=30$

Illegal marker type ‘$\_$’.
Should be either ‘INTORG’ or ‘INTEND’.
 ${\mathbf{ifail}}=31$

Unknown row name ‘$\_$’ in $\_$ section.
All row names must be specified in the ROWS section.
 ${\mathbf{ifail}}=32$

Unknown column name ‘$\_$’ in $\_$ section.
All column names must be specified in the COLUMNS section.
 ${\mathbf{ifail}}=33$

Unknown bound type ‘$\_$’ in BOUNDS section.
 ${\mathbf{ifail}}=34$

More than one nonzero of
a has row name ‘
$\_$’ and column name ‘
$\_$’ in the COLUMNS section.
 ${\mathbf{ifail}}=35$

Field
$\_$ did not contain a number (see
Description).
 ${\mathbf{ifail}}=36$

Constraint: ${\mathbf{infile}}\ge 0$.
 ${\mathbf{ifail}}=99$
An unexpected error has been triggered by this routine. Please
contact
NAG.
 ${\mathbf{ifail}}=399$
Your licence key may have expired or may not have been installed correctly.
 ${\mathbf{ifail}}=999$
Dynamic memory allocation failed.
Accuracy
Not applicable.
Further Comments
None.
Example
This example solves the quadratic programming problem
where
The optimal solution (to five figures) is
Three bound constraints and two general linear constraints are active at the solution. Note that, although the Hessian matrix is only positive semidefinite, the point ${x}^{*}$ is unique.
Open in the MATLAB editor:
e04mx_example
e04mx.opt
NAME E04MX.EX
ROWS
L ..ROW1..
L ..ROW2..
L ..ROW3..
N ..COST..
COLUMNS
...X1... ..ROW1.. 1.0 ..ROW2.. 1.0
...X1... ..ROW3.. 1.0 ..COST.. 4.0
...X2... ..ROW1.. 1.0 ..ROW2.. 2.0
...X2... ..ROW3.. 1.0 ..COST.. 1.0
...X3... ..ROW1.. 1.0 ..ROW2.. 3.0
...X3... ..ROW3.. 1.0 ..COST.. 1.0
...X4... ..ROW1.. 1.0 ..ROW2.. 4.0
...X4... ..ROW3.. 1.0 ..COST.. 1.0
...X5... ..ROW1.. 1.0 ..ROW2.. 2.0
...X5... ..ROW3.. 1.0 ..COST.. 1.0
...X6... ..ROW1.. 1.0 ..ROW2.. 1.0
...X6... ..ROW3.. 1.0 ..COST.. 1.0
...X7... ..ROW1.. 1.0 ..ROW2.. 1.0
...X7... ..ROW3.. 1.0 ..COST.. 1.0
...X8... ..ROW1.. 1.0 ..ROW2.. 1.0
...X8... ..ROW3.. 1.0 ..COST.. 0.1
...X9... ..ROW1.. 4.0 ..ROW2.. 1.0
...X9... ..ROW3.. 1.0 ..COST.. 0.3
RHS
RHS1 ..ROW1.. 1.5
RHS1 ..ROW2.. 1.5
RHS1 ..ROW3.. 4.0
RHS1 ..COST.. 1000.0
RANGES
RANGE1 ..ROW1.. 3.5
RANGE1 ..ROW2.. 3.5
RANGE1 ..ROW3.. 6.0
BOUNDS
LO BOUND ...X1... 2.0
LO BOUND ...X2... 2.0
LO BOUND ...X3... 2.0
LO BOUND ...X4... 2.0
LO BOUND ...X5... 2.0
LO BOUND ...X6... 2.0
LO BOUND ...X7... 2.0
LO BOUND ...X8... 2.0
LO BOUND ...X9... 2.0
UP BOUND ...X1... 2.0
UP BOUND ...X2... 2.0
UP BOUND ...X3... 2.0
UP BOUND ...X4... 2.0
UP BOUND ...X5... 2.0
UP BOUND ...X6... 2.0
UP BOUND ...X7... 2.0
UP BOUND ...X8... 2.0
UP BOUND ...X9... 2.0
QUADOBJ
...X1... ...X1... 2.00000000E0 ...X2... 1.00000000E0
...X1... ...X3... 1.00000000E0 ...X4... 1.00000000E0
...X1... ...X5... 1.00000000E0
...X2... ...X2... 2.00000000E0 ...X3... 1.00000000E0
...X2... ...X4... 1.00000000E0 ...X5... 1.00000000E0
...X3... ...X3... 2.00000000E0 ...X4... 1.00000000E0
...X3... ...X5... 1.00000000E0
...X4... ...X4... 2.00000000E0 ...X5... 1.00000000E0
...X5... ...X5... 2.00000000E0
ENDATA
function e04mx_example
fprintf('e04mx example results\n\n');
nin = int64(7);
mode = int64(0);
[ifail] = x04ac(nin, 'e04mx.opt', mode);
n = int64(0);
m = int64(0);
nz = int64(0);
ncolh = int64(0);
nnzh = int64(0);
lintvar = int64(1);
mpslst = int64(0);
pnames = {' ', ' ', ' ', ' ', ' '};
[n, m, nz, ncolh, nnzh, lintvar, iobj, a, irowa, iccola, bl, bu, pnames, ...
nname, crname, h, irowh, iccolh, minmax, intvar, ifail] = ...
e04mx(...
nin, n, m, nz, ncolh, nnzh, lintvar, mpslst, pnames);
[ifail] = x04ad(nin);
[ifail] = x04ac(nin, 'e04mx.opt', mode);
maxm = m;
maxn = n;
maxnnz = nz;
maxnnzh = nnzh;
maxncolh = ncolh;
[n, m, nz, ncolh, nnzh, lintvar, iobj, a, irowa, iccola, bl, bu, pnames, ...
nname, crname, h, irowh, iccolh, minmax, intvar, ifail] = ...
e04mx(...
nin, n, m, nz, ncolh, nnzh, lintvar, mpslst, pnames);
[ifail] = x04ad(nin);
[cw, iw, rw, ifail] = e04np;
[cw, iw, rw, ifail] = e04ns('NoList', cw, iw, rw);
[cw, iw, rw, ifail] = e04ns('Print Level = 0', cw, iw, rw);
lenc = int64(0);
objadd = 0;
start = 'c';
c = zeros(lenc, 1);
helast = zeros(n+m, 1, 'int64');
hs = zeros(n+m, 1, 'int64');
x = zeros(n+m, 1);
for i=1:n+m
x(i) = min(max(0, bl(i)),bu(i));
end
ns = int64(0);
user = {h, iccolh, irowh};
[hs, x, pi, rc, ns, ninf, sinf, obj, user, cw, iw, rw, ifail] = ...
e04nq(...
start, @qphx, m, n, lenc, ncolh, iobj, objadd, pnames{1}, a, irowa, ...
iccola, bl, bu, c, crname, helast, hs, x, ns, cw, iw, rw, 'user', user);
fprintf('Number of variables : %9d\n',n);
fprintf('Number of contraints: %9d\n',3);
fprintf('Minimum value : %9.4f\n\n',obj);
fprintf('Variable values at minimum:\n');
fprintf(' %9.4f %9.4f %9.4f\n',x(1:n));
fprintf('Linear contrained values:\n');
fprintf(' %9.4f %9.4f %9.4f\n',x(n+1:n+3));
function [hx, user] = qphx(ncolh, x, nstate, user)
hx = zeros(ncolh, 1);
h = user{1};
iccolh = user{2};
irowh = user{3};
for icol = 1:ncolh
start = iccolh(icol);
endd = iccolh(icol+1)1;
for idx = start:endd
irow = irowh(idx);
hx(irow) = hx(irow) + x(icol)*h(idx);
if irow ~= icol
hx (icol) = hx(icol) + x(irow)*h(idx);
end
end
end
e04mx example results
Number of variables : 9
Number of contraints: 3
Minimum value : 8.0678
Variable values at minimum:
2.0000 0.2333 0.2667
0.3000 0.1000 2.0000
2.0000 1.7778 0.4556
Linear contrained values:
1.5000 1.5000 3.9333
PDF version (NAG web site
, 64bit version, 64bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015