NAG Library Routine Document
e04mwf
(miqp_mps_write)
1
Purpose
e04mwf writes data for sparse linear programming, mixed integer linear programming, quadratic programming or mixed integer quadratic programming problems to a file in MPS format.
2
Specification
Fortran Interface
Subroutine e04mwf ( |
outfile,
n,
m,
nnzc,
nnza,
ncolh,
nnzh,
lintvar,
idxc,
c,
iobj,
a,
irowa,
iccola,
bl,
bu,
pnames,
nname,
crname,
h,
irowh,
iccolh,
minmax,
intvar,
ifail) |
Integer, Intent (In) | :: |
outfile,
n,
m,
nnzc,
nnza,
ncolh,
nnzh,
lintvar,
idxc(nnzc),
iobj,
irowa(nnza),
iccola(n+1),
nname,
irowh(nnzh),
iccolh(ncolh+1),
minmax,
intvar(lintvar) | Integer, Intent (Inout) | :: |
ifail | Real (Kind=nag_wp), Intent (In) | :: |
c(nnzc),
a(nnza),
bl(n+m),
bu(n+m),
h(nnzh) | Character (8), Intent (In) | :: |
pnames(5),
crname(nname) |
|
C Header Interface
#include nagmk26.h
void |
e04mwf_ (
const Integer *outfile,
const Integer *n,
const Integer *m,
const Integer *nnzc,
const Integer *nnza,
const Integer *ncolh,
const Integer *nnzh,
const Integer *lintvar,
const Integer idxc[],
const double c[],
const Integer *iobj,
const double a[],
const Integer irowa[],
const Integer iccola[],
const double bl[],
const double bu[],
const char pnames[],
const Integer *nname,
const char crname[],
const double h[],
const Integer irowh[],
const Integer iccolh[],
const Integer *minmax,
const Integer intvar[],
Integer *ifail,
const Charlen length_pnames,
const Charlen length_crname) |
|
3
Description
e04mwf writes data for linear programming (LP) or quadratic programming (QP) problems (or their mixed integer variants) from an optimization problem to a MPS output file, see
Section 3.1 in
e04mxf for the format description. The problem is expected in the form
Where
is the number of variables,
is the number of general linear constraints,
is the linear constraint matrix with dimension
by
, the vectors
and
are the lower and upper bounds, respectively.
is the Hessian matrix with dimension
by
, however, only leading
ncolh columns might contain nonzero elements and the rest is assumed to be zero.
Note that the linear term of the objective function
might be supplied either as
c or via
iobj. If
c is supplied then
idxc contains the indices of the nonzero elements of sparse vector
, whereas if
iobj is supplied (
), row
iobj of matrix
is a free row storing the nonzero elements of
.
Note: that this routine uses fixed MPS format, see
IBM (1971).
4
References
IBM (1971) MPSX – Mathematical programming system Program Number 5734 XM4 IBM Trade Corporation, New York
5
Arguments
- 1: – IntegerInput
-
On entry: the ID of the file to store the problem data as
associated
by a call to
x04acf.
Constraint:
.
- 2: – IntegerInput
-
On entry: , the number of variables in the problem.
Constraint:
.
- 3: – IntegerInput
-
On entry:
, the number of constraints in the problem. This is the number of rows in the linear constraint matrix
, including the free row (if any; see
iobj).
Constraint:
.
- 4: – IntegerInput
-
On entry: the number of nonzero elements in the sparse vector
.
If
, the vector
is considered empty and the arrays
idxc and
c will not be referenced. In this case the linear term of the objective function, if any, might be provided via
iobj.
Constraints:
- ;
- if , .
- 5: – IntegerInput
-
On entry: the number of nonzero elements in matrix
.
If
, matrix
is considered empty, arrays
a and
irowa will not be referenced, and
iccola should be the array of
.
Constraint:
.
- 6: – IntegerInput
-
On entry: the number of leading nonzero columns of the Hessian matrix
.
If
, the quadratic term
of the objective function is considered zero (e.g., LP problems), and arrays
h,
irowh and
iccolh will not be referenced.
Constraint:
.
- 7: – IntegerInput
-
On entry: the number of nonzero elements of the Hessian matrix .
Constraints:
- if , ;
- otherwise .
- 8: – IntegerInput
-
On entry: the number of integer variables in the problem.
If
, all variables are considered continuous and array
intvar will not be referenced.
Constraint:
.
- 9: – Integer arrayInput
- 10: – Real (Kind=nag_wp) arrayInput
-
On entry: the nonzero elements of sparse vector
.
must contain the index of
in the vector, for
.
The elements are stored in ascending order.
Constraints:
- , for ;
- , for .
- 11: – IntegerInput
-
On entry: if
, row
iobj of
is a free row containing the nonzero coefficients of the linear terms of the objective function. In this case
nnzc is set to
.
If
, there is no free row in
, and the linear terms might be supplied in array
c.
Constraint:
if , .
- 12: – Real (Kind=nag_wp) arrayInput
- 13: – Integer arrayInput
- 14: – Integer arrayInput
-
On entry: the nonzero elements of matrix
in compressed column storage (see
Section 2.1.3 in the F11 Chapter Introduction).
Arrays
irowa and
a store the row indices and the values of the nonzero elements, respectively. The elements are sorted by columns and within each column in nondecreasing order. Duplicate entries are not allowed.
iccola contains the (one-based) indices to the beginning of each column in
a and
irowa.
If
,
a and
irowa are not referenced.
Constraints:
- , for ;
- ;
- , for ;
- .
- 15: – Real (Kind=nag_wp) arrayInput
- 16: – Real (Kind=nag_wp) arrayInput
-
On entry:
bl and
bu contains the lower bounds
and the upper bounds
, respectively.
The first
n elements refer to the bounds for the variables
and the rest to the bounds for the linear constraints (including the objective row
iobj if present).
To specify a nonexistent lower bound (i.e., ), set ; to specify a nonexistent upper bound, set .
Constraints:
- , for ;
- , for ;
- , for ;
- if , and .
- 17: – Character(8) arrayInput
-
On entry: a set of names associated with the MPSX form of the problem.
The names can be composed only from ‘printable’ characters (ASCII codes between and ).
If any of the names are blank, the default name is used.
- Contains the name of the problem.
- Contains the name of the objective row if the objective is provided in c instead of iobj and all names crname are given. The name must be nonempty and unique. In all other cases is not used.
- Contains the name of the RHS set.
- Contains the name of the RANGE.
- Contains the name of the BOUNDS.
- 18: – IntegerInput
-
On entry: the number of column (i.e., variable) and row names supplied in the array
crname.
If
, the names are automatically generated and the array
crname is not referenced.
Constraint:
or .
- 19: – Character(8) arrayInput
-
On entry: the names of all the variables and constraints in the problem in that order.
The names can be composed only from 'printable' characters and must be unique.
- 20: – Real (Kind=nag_wp) arrayInput
- 21: – Integer arrayInput
- 22: – Integer arrayInput
-
On entry: the nonzero elements of the Hessian matrix
in compressed column storage (see
Section 2.1.3 in the F11 Chapter Introduction). The Hessian matrix,
, is symmetric and its elements are stored in a lower triangular matrix.
Arrays
irowh and
h store the row indices and the values of the nonzero elements, respectively. The elements are sorted by columns and within each column in nondecreasing order. Duplicate entries are not allowed.
iccolh contains the (one-based) indices to the beginning of each column in
h and
irowh.
If
,
h is not referenced.
Constraints:
- , for ;
- ;
- , for ;
- .
- 23: – IntegerInput
-
On entry:
minmax defines the direction of optimization problem.
- Minimization.
- Maximization.
Constraint:
or .
- 24: – Integer arrayInput
-
On entry:
intvar contains the indices
of variables
which are defined as integers. Duplicate indices are not allowed.
If
,
intvar is not referenced.
Constraint:
, for .
- 25: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
-
On entry, .
Constraint: .
On entry, .
Constraint: .
-
On entry, .
Constraint: .
On entry, , and .
Constraint: or .
On entry, .
Constraint: .
On entry, .
Constraint: .
-
On entry, and .
Constraint: .
On entry, and .
Constraint: if , .
On entry, and .
Constraint: if , .
-
On entry, , and .
Constraint: .
On entry, , and .
Constraint: .
-
On entry, .
Constraint: or .
-
On entry, and .
Constraint: .
On entry,
and
.
Constraint: at most one of
iobj or
nnzc may be nonzero.
-
On entry, , and , if the bounds must be infinite.
Constraints: , .
On entry, , and , the integer variable requires at least one bound finite.
Constraint: at least one of the following conditions must be met for integer variable j: , .
On entry, , and are incorrect.
Constraint: .
On entry, and , is incorrect.
Constraint: .
On entry, and , is incorrect.
Constraint: .
-
On entry,
for
has been already used.
Constraint: the names in
crname must be unique.
On entry,
for
is incorrect.
Constraint: the names in
crname must consist only of printable characters.
On entry,
for
is incorrect.
Constraint: the names in
pnames must consist only of printable characters.
The name specified in
is empty or has been already used among row names.
Constraint: the names in
must be unique and nonempty if
crname is provided and
.
-
On entry,
.
Constraint: all entries in
intvar must be unique.
On entry, , and .
Constraint: .
-
On entry, , and .
Constraint: .
On entry, more than one element of
a has row index
and column index
.
Constraint: each element of
a must have a unique row and column index.
-
On entry, .
Constraint: .
On entry, and .
Constraint: .
On entry,
,
and
, the values of
iccola must be nondecreasing.
Constraint:
.
-
On entry, , , and
Constraint: (within the lower triangle).
On entry, more than one element of
h has row index
and column index
.
Constraint: each element of
h must have a unique row and column index.
-
On entry, .
Constraint: .
On entry, and .
Constraint: .
On entry,
,
and
, the values of
iccolh must be nondecreasing.
Constraint:
.
-
An error occurred when writing to file.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
Not applicable.
8
Parallelism and Performance
e04mwf is not threaded in any implementation.
None.
10
Example
This example shows how to store an optimization problem to a file in MPS format after it has been solved by
e04nqf. The problem is a minimization of the quadratic function
, where
subject to the bounds
and to the linear constraints
The initial point, which is infeasible, is
The optimal solution (to five figures) is
The generated file is called e04mwfe.mps.
10.1
Program Text
Program Text (e04mwfe.f90)
10.2
Program Data
Program Data (e04mwfe.d)
10.3
Program Results
Program Results (e04mwfe.r)