naginterfaces.library.opt.miqp_mps_write¶
- naginterfaces.library.opt.miqp_mps_write(outfile, n, m, ncolh, iobj, bl, bu, pnames, crname, minmax, idxc=None, c=None, a=None, irowa=None, iccola=None, h=None, irowh=None, iccolh=None, intvar=None, io_manager=None)[source]¶
miqp_mps_write
writes data for sparse linear programming, mixed integer linear programming, quadratic programming or mixed integer quadratic programming problems to a file in MPS format.For full information please refer to the NAG Library document for e04mw
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/e04/e04mwf.html
- Parameters
- outfileint
The ID of the file to store the problem data as associated by a call to the
FileObjManager
methodunit_from_fileobj()
.- nint
, the number of variables in the problem.
- mint
, 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 ).
- ncolhint
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 , and will not be referenced.
- iobjint
If , row of is a free row containing the nonzero coefficients of the linear terms of the objective function. In this case is set to .
If , there is no free row in , and the linear terms might be supplied in array .
- blfloat, array-like, shape
and contains the lower bounds and the upper bounds , respectively.
The first elements refer to the bounds for the variables and the rest to the bounds for the linear constraints (including the objective row if present).
To specify a nonexistent lower bound (i.e., ), set ; to specify a nonexistent upper bound, set .
- bufloat, array-like, shape
and contains the lower bounds and the upper bounds , respectively.
The first elements refer to the bounds for the variables and the rest to the bounds for the linear constraints (including the objective row if present).
To specify a nonexistent lower bound (i.e., ), set ; to specify a nonexistent upper bound, set .
- pnamesstr, length 8, array-like, shape
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 instead of and all names 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.
- crnamestr, length 8, array-like, shape
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.
- minmaxint
defines the direction of optimization problem.
Minimization.
Maximization.
- idxcNone or int, array-like, shape , optional
The nonzero elements of sparse vector . must contain the index of in the vector, for .
The elements are stored in ascending order.
- cNone or float, array-like, shape , optional
The nonzero elements of sparse vector . must contain the index of in the vector, for .
The elements are stored in ascending order.
- aNone or float, array-like, shape , optional
The nonzero elements of matrix in compressed column storage (see the F11 Introduction). Arrays and 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. contains the (one-based) indices to the beginning of each column in and .
If , and are not referenced.
- irowaNone or int, array-like, shape , optional
The nonzero elements of matrix in compressed column storage (see the F11 Introduction). Arrays and 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. contains the (one-based) indices to the beginning of each column in and .
If , and are not referenced.
- iccolaNone or int, array-like, shape , optional
Note: the required length for this argument is determined as follows: if : ; otherwise: .
The nonzero elements of matrix in compressed column storage (see the F11 Introduction). Arrays and 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. contains the (one-based) indices to the beginning of each column in and .
If , and are not referenced.
- hNone or float, array-like, shape , optional
The nonzero elements of the Hessian matrix in compressed column storage (see the F11 Introduction). The Hessian matrix, , is symmetric and its elements are stored in a lower triangular matrix.
Arrays and 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. contains the (one-based) indices to the beginning of each column in and .
If , is not referenced.
- irowhNone or int, array-like, shape , optional
The nonzero elements of the Hessian matrix in compressed column storage (see the F11 Introduction). The Hessian matrix, , is symmetric and its elements are stored in a lower triangular matrix.
Arrays and 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. contains the (one-based) indices to the beginning of each column in and .
If , is not referenced.
- iccolhNone or int, array-like, shape , optional
Note: the required length for this argument is determined as follows: if : ; otherwise: .
The nonzero elements of the Hessian matrix in compressed column storage (see the F11 Introduction). The Hessian matrix, , is symmetric and its elements are stored in a lower triangular matrix.
Arrays and 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. contains the (one-based) indices to the beginning of each column in and .
If , is not referenced.
- intvarNone or int, array-like, shape , optional
contains the indices of variables which are defined as integers. Duplicate indices are not allowed.
If , is not referenced.
- io_managerFileObjManager, optional
Manager for I/O in this routine.
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, , and .
Constraint: or .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, and .
Constraint: if , .
- (errno )
On entry, and .
Constraint: if , .
- (errno )
On entry, , and .
Constraint: .
- (errno )
On entry, , and .
Constraint: .
- (errno )
On entry, .
Constraint: or .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, and .
Constraint: at most one of or may be nonzero.
- (errno )
On entry, , and are incorrect.
Constraint: .
- (errno )
On entry, and , is incorrect.
Constraint: .
- (errno )
On entry, and , is incorrect.
Constraint: .
- (errno )
On entry, , and , if the bounds must be infinite.
Constraints: , .
- (errno )
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: , .
- (errno )
On entry, for is incorrect.
Constraint: the names in must consist only of printable characters.
- (errno )
On entry, for is incorrect.
Constraint: the names in must consist only of printable characters.
- (errno )
On entry, for has been already used.
Constraint: the names in must be unique.
- (errno )
The name specified in is empty or has been already used among row names.
Constraint: the names in must be unique and nonempty if is provided and .
- (errno )
On entry, , and .
Constraint: .
- (errno )
On entry, .
Constraint: all entries in must be unique.
- (errno )
On entry, , and .
Constraint: .
- (errno )
On entry, more than one element of has row index and column index .
Constraint: each element of must have a unique row and column index.
- (errno )
On entry, , and , the values of must be nondecreasing.
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, , , and
Constraint: (within the lower triangle).
- (errno )
On entry, more than one element of has row index and column index .
Constraint: each element of must have a unique row and column index.
- (errno )
On entry, , and , the values of must be nondecreasing.
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, and .
Constraint: .
- (errno )
An error occurred when writing to file.
- Notes
miqp_mps_write
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 MPS Input Format for miqp_mps_read for the format description. The problem is expected in the formWhere is the number of variables, is the number of general linear constraints, is the linear constraint matrix with dimension , the vectors and are the lower and upper bounds, respectively. is the Hessian matrix with dimension , however, only leading 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 or via . If is supplied then contains the indices of the nonzero elements of sparse vector , whereas if is supplied (), row of matrix is a free row storing the nonzero elements of .
Note: that this function uses fixed MPS format, see IBM (1971).
- References
IBM, 1971, MPSX – Mathematical programming system, Program Number 5734 XM4, IBM Trade Corporation, New York