NAG Library Routine Document

e04mwf  (miqp_mps_write)

 Contents

    1  Purpose
    7  Accuracy

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
minimize x cTx+12xTHx   subject to  l x Ax u.  
Where n is the number of variables, m is the number of general linear constraints, A is the linear constraint matrix with dimension m by n, the vectors l and u are the lower and upper bounds, respectively. H is the Hessian matrix with dimension n by n, 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 c 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 c, whereas if iobj is supplied (iobj>0), row iobj of matrix A is a free row storing the nonzero elements of c.
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:     outfile – IntegerInput
On entry: the ID of the file to store the problem data as associated by a call to x04acf.
Constraint: outfile0.
2:     n – IntegerInput
On entry: n, the number of variables in the problem.
Constraint: n1.
3:     m – IntegerInput
On entry: m, the number of constraints in the problem. This is the number of rows in the linear constraint matrix A, including the free row (if any; see iobj).
Constraint: m0.
4:     nnzc – IntegerInput
On entry: the number of nonzero elements in the sparse vector c.
If nnzc=0, the vector c 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:
  • nnzc0;
  • if nnzc>0, iobj=0.
5:     nnza – IntegerInput
On entry: the number of nonzero elements in matrix A.
If nnza=0, matrix A is considered empty, arrays a and irowa will not be referenced, and iccola should be the array of 1.
Constraint: nnza0.
6:     ncolh – IntegerInput
On entry: the number of leading nonzero columns of the Hessian matrix H.
If ncolh=0, the quadratic term H of the objective function is considered zero (e.g., LP problems), and arrays h, irowh and iccolh will not be referenced.
Constraint: 0ncolhn.
7:     nnzh – IntegerInput
On entry: the number of nonzero elements of the Hessian matrix H.
Constraints:
  • if ncolh>0, nnzh>0;
  • otherwise nnzh=0.
8:     lintvar – IntegerInput
On entry: the number of integer variables in the problem.
If lintvar=0, all variables are considered continuous and array intvar will not be referenced.
Constraint: lintvar0.
9:     idxcnnzc – Integer arrayInput
10:   cnnzc – Real (Kind=nag_wp) arrayInput
On entry: the nonzero elements of sparse vector c. idxci must contain the index of ci in the vector, for i=1,2,,nnzc.
The elements are stored in ascending order.
Constraints:
  • 1idxcin, for i=1,2,,nnzc;
  • idxci<idxci+1, for i=1,2,,nnzc.
11:   iobj – IntegerInput
On entry: if iobj>0, row iobj of A is a free row containing the nonzero coefficients of the linear terms of the objective function. In this case nnzc is set to 0.
If iobj=0, there is no free row in A, and the linear terms might be supplied in array c.
Constraint: if iobj>0, nnzc=0.
12:   annza – Real (Kind=nag_wp) arrayInput
13:   irowannza – Integer arrayInput
14:   iccolan+1 – Integer arrayInput
On entry: the nonzero elements of matrix A 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 nnza=0, a and irowa are not referenced.
Constraints:
  • 1irowaim, for i=1,2,,nnza;
  • iccola1=1;
  • iccolaiiccolai+1, for i=1,2,,n;
  • iccolan+1=nnza+1.
15:   bln+m – Real (Kind=nag_wp) arrayInput
16:   bun+m – Real (Kind=nag_wp) arrayInput
On entry: bl and bu contains the lower bounds l and the upper bounds u, respectively.
The first n elements refer to the bounds for the variables x 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., lj=-inf), set blj-1020; to specify a nonexistent upper bound, set buj1020.
Constraints:
  • bljbuj, for j=1,2,,n+m;
  • blj<1020, for j=1,2,,n+m;
  • buj>-1020, for j=1,2,,n+m;
  • if iobj>0, bliobj+n-1020 and buiobj+n1020.
17:   pnames5 – 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 32 and 126).
If any of the names are blank, the default name is used.
pnames1
Contains the name of the problem.
pnames2
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 pnames2 is not used.
pnames3
Contains the name of the RHS set.
pnames4
Contains the name of the RANGE.
pnames5
Contains the name of the BOUNDS.
18:   nname – IntegerInput
On entry: the number of column (i.e., variable) and row names supplied in the array crname.
If nname=0, the names are automatically generated and the array crname is not referenced.
Constraint: nname=0 or n+m.
19:   crnamenname – 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:   hnnzh – Real (Kind=nag_wp) arrayInput
21:   irowhnnzh – Integer arrayInput
22:   iccolhncolh+1 – Integer arrayInput
On entry: the nonzero elements of the Hessian matrix H in compressed column storage (see Section 2.1.3 in the F11 Chapter Introduction). The Hessian matrix, H, 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 ncolh=0, h is not referenced.
Constraints:
  • 1irowhincolh, for i=1,2,,nnzh;
  • iccolh1=1;
  • iccolhiiccolhi+1, for i=1,2,,ncolh;
  • iccolhncolh+1=nnzh+1.
23:   minmax – IntegerInput
On entry: minmax defines the direction of optimization problem.
minmax=-1
Minimization.
minmax=1
Maximization.
Constraint: minmax=-1 or 1.
24:   intvarlintvar – Integer arrayInput
On entry: intvar contains the indices k of variables xk which are defined as integers. Duplicate indices are not allowed.
If lintvar=0, intvar is not referenced.
Constraint: 1intvarjn, for j=1,2,,lintvar.
25:   ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1​ or ​1. 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 -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, outfile=value.
Constraint: outfile0.
ifail=2
On entry, m=value.
Constraint: m0.
On entry, n=value.
Constraint: n1.
ifail=3
On entry, lintvar=value.
Constraint: lintvar0.
On entry, nname=value, n=value and m=value.
Constraint: nname=0 or n+m.
On entry, nnza=value.
Constraint: nnza0.
On entry, nnzc=value.
Constraint: nnzc0.
ifail=4
On entry, ncolh=value and n=value.
Constraint: 0ncolhn.
On entry, ncolh=value and nnzh=value.
Constraint: if ncolh>0, nnzh>0.
On entry, ncolh=value and nnzh=value.
Constraint: if ncolh=0, nnzh=0.
ifail=5
On entry, j=value, idxcj=value and idxcj+1=value.
Constraint: idxcj<idxcj+1.
On entry, j=value, idxcj=value and n=value.
Constraint: 1idxcjn.
ifail=6
On entry, minmax=value.
Constraint: minmax=-1 or 1.
ifail=7
On entry, iobj=value and m=value.
Constraint: 0iobjm.
On entry, iobj=value and nnzc=value.
Constraint: at most one of iobj or nnzc may be nonzero.
ifail=8
On entry, iobj=value, blj=value and buj=value, if iobj>0 the bounds must be infinite.
Constraints: blj-1E+20, buj1E+20.
On entry, j=value, blj=value and buj=value, the integer variable j requires at least one bound finite.
Constraint: at least one of the following conditions must be met for integer variable j: blj>−1E+20, buj<1E+20.
On entry, j=value, blj=value and buj=value are incorrect.
Constraint: bljbuj.
On entry, j=value and blj=value, blj is incorrect.
Constraint: blj<1E+20.
On entry, j=value and buj=value, buj is incorrect.
Constraint: buj>-1E+20.
ifail=9
On entry, crnamej for j=value has been already used.
Constraint: the names in crname must be unique.
On entry, crnamej for j=value is incorrect.
Constraint: the names in crname must consist only of printable characters.
On entry, pnamesj for j=value is incorrect.
Constraint: the names in pnames must consist only of printable characters.
The name specified in pnames2 is empty or has been already used among row names.
Constraint: the names in pnames2 must be unique and nonempty if crname is provided and nnzc>0.
ifail=10
On entry, intvarvalue=intvarvalue= value.
Constraint: all entries in intvar must be unique.
On entry, j=value, intvarj=value and lintvar=value.
Constraint: 1intvarjlintvar.
ifail=11
On entry, i=value, irowai=value and m=value.
Constraint: 1irowaim.
On entry, more than one element of a has row index value and column index value.
Constraint: each element of a must have a unique row and column index.
ifail=12
On entry, iccola1=value.
Constraint: iccola1=1.
On entry, iccolan+1=value and nnza=value.
Constraint: iccolan+1=nnza+1.
On entry, j=value, iccolaj=value and iccolaj+1=value, the values of iccola must be nondecreasing.
Constraint: iccolajiccolaj+1.
ifail=13
On entry, j=value, i=value, ncolh=value and irowhi=value
Constraint: jirowhincolh (within the lower triangle).
On entry, more than one element of h has row index value and column index value.
Constraint: each element of h must have a unique row and column index.
ifail=14
On entry, iccolh1=value.
Constraint: iccolh1=1.
On entry, iccolhncolh+1=value and nnzh=value.
Constraint: iccolhncolh+1=nnzh+1.
On entry, j=value, iccolhj=value and iccolhj+1=value, the values of iccolh must be nondecreasing.
Constraint: iccolhjiccolhj+1.
ifail=15
An error occurred when writing to file.
ifail=-99
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.
ifail=-399
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.
ifail=-999
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.

9
Further Comments

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 fx=cTx+12xTHx, 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
000x10200 000x22500 400x30800 100x40700 000x51500 000x61500 000x71500  
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 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.  
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)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017