E04MWF (PDF version)
E04 Chapter Contents
E04 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

E04MWF

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.

 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

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  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), IFAIL
REAL (KIND=nag_wp)  C(NNZC), A(NNZA), BL(N+M), BU(N+M), H(NNZH)
CHARACTER(8)  PNAMES(5), CRNAME(NNAME)

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)


E04MWF (PDF version)
E04 Chapter Contents
E04 Chapter Introduction
NAG Library Manual

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