naginterfaces.library.opt.qpconvex1_sparse_mps¶
- naginterfaces.library.opt.qpconvex1_sparse_mps(infile, maxn, maxm, maxnnz, xbldef, xbudef, mpslst, names, io_manager=None)[source]¶
qpconvex1_sparse_mps
reads data for a sparse linear programming or quadratic programming problem from an external file which is in standard or compatible MPSX input format.Deprecated since version 26.2.0.0:
qpconvex1_sparse_mps
is deprecated. Please usemiqp_mps_read()
instead. See also the Replacement Calls document.For full information please refer to the NAG Library document for e04mz
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/e04/e04mzf.html
- Parameters
- infileint
The unit number (see
unit_from_fileobj()
) associated with the MPSX data file.- maxnint
An upper limit for the number of variables in the problem.
- maxmint
An upper limit for the number of constraints (including the objective row) in the problem.
- maxnnzint
An upper limit for the number of nonzeros (including the objective row) in the problem.
- xbldeffloat
The default lower bound to be used for the variables in the problem when none is specified in the BOUNDS section of the MPSX data file. For a standard LP or QP problem would normally be set to zero.
- xbudeffloat
The default upper bound to be used for the variables in the problem when none is specified in the BOUNDS section of the MPSX data file. For a standard LP or QP problem would normally be set to ‘infinity’ (i.e., ).
- mpslstbool
If , a listing of the input data is sent to the file object associated with the advisory I/O unit (see
FileObjManager
). This can be useful for debugging the MPSX data file. If , no listing is produced.- namesstr, length 8, array-like, shape
A set of names associated with the MPSX form of the problem.
Must contain either the name of the problem or be blank.
Must contain either the name of the objective row or be blank (in which case the first objective free row is used).
Must contain either the name of the RHS set to be used or be blank (in which case the first RHS set is used).
Must contain either the name of the RANGE set to be used or be blank (in which case the first RANGE set (if any) is used).
Must contain either the name of the BOUNDS set to be used or be blank (in which case the first BOUNDS set (if any) is used).
- io_managerFileObjManager, optional
Manager for I/O in this routine.
- Returns
- nint
, the actual number of variables in the problem.
- mint
, the actual number of general linear constraints in the problem (including the objective row).
- nnzint
The actual number of nonzeros in the problem (including the objective row).
- iobjint
If , row of is a free row containing the nonzero coefficients of the vector .
If , the coefficients of are assumed to be zero.
If , no such row was found and the function terminates with = 4 or 5 (see Exceptions).
- ncolhint
. For QP problems, is the number of leading nonzero columns of the Hessian matrix and must, therefore, be set before calling
qpconvex1_sparse_solve()
.- afloat, ndarray, shape
The nonzero elements of , ordered by increasing column index.
- haint, ndarray, shape
The row indices of the nonzero elements stored in .
- kaint, ndarray, shape
A set of pointers to the beginning of each column of . More precisely, contains the index in of the start of the th column, for . Note that and .
- blfloat, ndarray, shape
contains the vector (the lower bounds) for all the variables and constraints
- bufloat, ndarray, shape
contains the vector (the upper bounds) for all the variables and constraints
- startstr, length 1
and an internal Crash procedure will be used by
qpconvex1_sparse_solve()
to choose an initial basis.- namesstr, length 8, ndarray, shape
A set of names associated with the problem as defined in the MPSX data file as follows:
Contains the name of the problem (or blank if none).
Contains the name of the objective row (or blank if none).
Contains the name of the RHS set (or blank if none).
Contains the name of the RANGE set (or blank if none).
Contains the name of the BOUNDS set (or blank if none).
- nnameint
, the total number of variables and constraints in the problem.
- crnamestr, length 8, ndarray, shape
The MPSX names of all the variables and constraints in the problem in the following order. The first elements contain the MPSX names for the variables and the next elements contain the MPSX names for the objective row and general linear constraints (if any). Note that the MPSX name for the objective row is stored in .
- xsfloat, ndarray, shape
A set of initial values for the variables and constraints in the problem. More precisely, , for .
- istateint, ndarray, shape
A set of initial states for the variables and constraints in the problem. More precisely, if and otherwise, for .
- Raises
- NagValueError
- (errno )
Too many rows. Limit is , but the actual number required is .
- (errno )
Too many columns. Limit is , but the actual number required is .
- (errno )
Too many nonzeros. Limit is , but the actual number required is .
- (errno )
No objective row found.
- (errno )
Objective row name is not defined in the ROWS section.
- (errno )
No rows specified.
- (errno )
Illegal constraint type .
- (errno )
Row name with leading blank or non-alphanumeric character: .
- (errno )
Column name with leading blank or non-alphanumeric character: .
- (errno )
Illegal bound type .
- (errno )
Column name is not defined in the COLUMNS section.
- (errno )
The last line must be the ENDATA indicator line.
- (errno )
Line is not a comment nor a valid line.
- (errno )
Row name is not defined in the ROWS section.
- (errno )
No columns specified.
- (errno )
BOUNDS name was not found.
- (errno )
RANGES name was not found.
- (errno )
RHS name was not found.
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- Notes
In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.
qpconvex1_sparse_mps
reads Linear Programming (LP) or Quadratic Programming (QP) problem data from an external file which is prepared in standard or compatible MPSX (see IBM (1971)) input format and then initializes (the number of variables), (the number of general linear constraints), the matrix , and the vectors , and (stored in row of ) for use withqpconvex1_sparse_solve()
, which is designed to solve problems of the formFor LP problems, . For QP problems, you must set (see Parameters) and provide a function to
qpconvex1_sparse_solve()
to compute for any given vector . The option ‘Maximize’ may be used to specify an alternative problem in which the objective function is maximized (see Other Parameters for qpconvex1_sparse_solve).MPSX input format
The input file of data may only contain two types of lines:
Indicator lines (specifying the type of data which is to follow).
Data lines (specifying the actual data).
The input file must not contain any blank lines. 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
user-supplied name
ROWS
data line(s)
COLUMNS
data line(s)
RHS
data line(s)
RANGES
(optional)
data line(s)
BOUNDS
(optional)
data line(s)
ENDATA
The ‘user-supplied name’ specifies a name for the problem and must occupy columns . The name can either be blank or up to a maximum of characters.
A data line follows the same fixed format made up of fields 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
Contents
Code
Name
Name
Value
Name
Value
The names and codes consist of ‘alphanumeric’ characters (i.e., a–z, A–Z, –, , , , blank (), :, $ or full stop (.) only) and the names must not contain leading blank characters. Values are read using Fortran format . This allows values to be entered in several equivalent forms. For example, , , and all represent the same number. It is safest to include an explicit decimal point.
Note that in order to ensure numeric values are interpreted as intended, they should be right-justified in the -character field, with no trailing blanks. This is because in some situations trailing blanks may be interpreted as zeros and this can dramatically affect the interpretation of the value. This is relevant if the value contains an exponent, or if it contains neither an exponent nor an explicit decimal point. For example, the fields
%%%%1.23e-2% %%%%%%%123%%
may be interpreted as and respectively (where
%
denotes a blank). The actual behaviour is system-dependent.Comment lines are allowed in the data file. These must have an asterisk (
*
) in column 1 and any characters in columns 2–80. In any data line, a dollar sign ($
) as the first character in Field 3 or 5 indicates that the information from that point through column 80 consists of comments.Columns outside the six fields must be blank, except for columns 72–80, whose contents are ignored by the function. These columns may be used to enter a sequence number. A non-blank character outside the predefined six fields and columns 72–80 is considered to be a major error ( = 13; see Exceptions), unless it is part of a comment.
ROWS Data Lines
These lines specify row (constraint) names and their inequality types (i.e., , or ).
Field 1:
defines the constraint type. It may be in column 2 or column 3.
N
free row, that is no constraint. It may be used to define the objective row.
G
greater than or equal to (i.e., ).
L
less than or equal to (i.e., ).
E
exactly equal to (i.e., ).
Field 2:
defines the row name.
Row type
N
stands for ‘Not binding’, also known as ‘Free’. It can be used to define the objective row. The objective row is a free row that specifies the vector in the linear objective term . It is taken to be the first free row, unless some other free row name is specified by the array (see Parameters). Note that is assumed to be zero if (for example) the line%N%%DUMMYROW
(where
%
denotes a blank) appears in the ROWS section of the MPSX data file, and the row nameDUMMYROW
is omitted from the COLUMNS section.COLUMNS Data Lines
These lines specify the names to be assigned to the variables (columns) in the general linear constraint matrix , and define, in terms of column vectors, the actual values of the corresponding matrix elements.
Field 1:
blank (ignored).
Field 2:
gives the name of the column associated with the elements specified in the following fields.
Field 3:
contains the name of a row.
Field 4:
used in conjunction with Field 3 contains the value of the matrix element.
Field 5:
is optional (may be used like Field 3).
Field 6:
is optional (may be used like Field 4).
Note that only the nonzero elements of and need to be specified in the COLUMNS section, as any zero elements of are removed and any unspecified elements of are assumed to be zero. In addition, any nonzero elements in the th column of must be grouped together before those in the th column, for . Nonzero elements within a column may however appear in any order.
RHS Data Lines
This section specifies the right-hand side values of the general linear constraint matrix (if any). The lines specify the name to be given to the right-hand side (RHS) vector along with the numerical values of the elements of the vector, which may appear in any order. The data lines have exactly the same format as the COLUMNS data lines, except that the column name is replaced by the RHS name. Only the nonzero elements need be specified. Note that this section may be empty, in which case the RHS vector is assumed to be zero.
RANGES Data Lines (optional)
Ranges are used for constraints of the form , where both and are finite. The range of the constraint is . Either or must be specified in the RHS section and must be defined in this section. The data lines have exactly the same format as the COLUMNS data lines, except that the column name is replaced by the RANGES name.
BOUNDS Data Lines (optional)
These lines specify limits on the values of the variables ( and in ). If the variable is not specified in the bound set then it is automatically assumed to lie between default lower and upper bounds (usually and ). Like an RHS column which is given a name, the set of variables in one bound set is also given a name.
Field 1:
LO
lower bound
UP
upper bound
FX
fixed variable
FR
free variable ( to )
MI
lower bound is
PL
upper bound is . This is the default variable type.
Field 2:
identifies a name for the bound set.
Field 3:
identifies the column name of the variable belonging to this set.
Field 4:
identifies the value of the bound; this has a numerical value only in association with LO, UP, FX in Field 1, otherwise it is blank.
Field 5:
is blank and ignored.
Field 6:
is blank and ignored.
Note that if RANGES and BOUNDS sections are both present, the RANGES section must appear first.
- References
IBM, 1971, MPSX – Mathematical programming system, Program Number 5734 XM4, IBM Trade Corporation, New York