naginterfaces.library.mip.ilp_mpsx¶
- naginterfaces.library.mip.ilp_mpsx(infile, maxn, maxm, optim, xbldef, xbudef, maxdpt, msglvl, liwork, lrwork, comm, io_manager=None)[source]¶
ilp_mpsx
solves linear or integer programming problems specified in MPSX input format. It is not intended for large sparse problems.For full information please refer to the NAG Library document for h02bf
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/h/h02bff.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) in the problem.
- optimstr, length 3
Specifies the direction of the optimization. must be set to ‘MIN’ for minimization and to ‘MAX’ for maximization.
- 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 IP 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 IP problem would normally be set to ‘infinity’ (i.e., ).
- maxdptint
For an IP problem, must specify the maximum depth of the branch and bound tree.
- msglvlint
The amount of printout produced by
opt.lp_solve
orilp_dense()
, as indicated below. For a description of the printed output see Further Comments or Description of Printed Output for ilp_dense (as appropriate). All output is written to the file object associated with the advisory I/O unit (seeFileObjManager
).For an LP problem (
opt.lp_solve
):Value
Definition
No output.
The final solution only.
One line of output for each iteration (no printout of the final solution).
The final solution and one line of output for each iteration.
For an IP problem (
ilp_dense()
):Value
Definition
No output.
The final IP solution only.
One line of output for each node investigated and the final IP solution.
The original LP solution (first node) with dummy names for the rows and columns, one line of output for each node investigated and the final IP solution with MPSX names for the rows and columns.
- liworkint
The dimension of the array .
- lrworkint
The dimension of the array .
- commdict, communication object, modified in place
Communication structure.
This argument must have been initialized by a prior call to
opt.nlp1_init
with .- 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.
- xfloat, ndarray, shape
The solution to the problem, stored in . is the value of the variable whose MPSX name is stored in , for .
- crnamestr, length 8, ndarray, shape
The first elements contain the MPSX names for the variables in the problem.
- iworkint, ndarray, shape
The first () elements contain ISTATE (the status of the constraints in the working set at the solution). Further details can be found in Parameters for opt.lp_solve and Parameters for ilp_info (as appropriate).
- rworkfloat, ndarray, shape
The first () elements contain BL (the lower bounds), the next () elements contain BU (the upper bounds) and the next () elements contain CLAMDA (the Lagrange-multipliers). Further details can be found in Parameters for opt.lp_solve and Parameters for ilp_info (as appropriate). Note that for an IP problem the contents of BL and BU may not be the same as those originally specified in the MPSX data file and/or via the arguments and .
- Raises
- NagValueError
- (errno )
Either and/or are too small or the MPSX data file is nonstandard and/or corrupt.
- (errno )
The LP solution is unbounded.
- (errno )
The LP does not have a feasible solution.
- (errno )
Iteration limit reached without finding a solution.
- (errno )
On entry, not enough real workspace to solve problem: must be at least .
- (errno )
On entry, not enough integer workspace to solve problem: must be at least .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, not enough real workspace to read data file: .
- (errno )
On entry, not enough integer workspace to read data file: .
- (errno )
On entry, .
Constraint: or .
- (errno )
On entry, and .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
A serious error has occurred. Check all function calls and array dimensions.
- (errno )
Increase and rerun
ilp_mpsx
.- (errno )
is too small to solve the problem: .
- (errno )
The IP solution returned is the best solution for the number of nodes investigated in the branch and bound tree.
- (errno )
No feasible solution was found for the number of nodes investigated in the branch and bound tree.
- (errno )
Not enough workspace to solve problem.
- Warns
- NagAlgorithmicWarning
- (errno )
Weak LP solution.
- (errno )
The problem does not have a feasible integer solution.
- (errno )
Search of a branch was terminated due to iteration limit.
- Notes
No equivalent traditional C interface for this routine exists in the NAG Library.
ilp_mpsx
solves Linear Programming (LP) or integer programming (IP) problems specified in MPSX (see IBM (1971)) input format. It calls eitheropt.lp_solve
(to solve an LP problem) orilp_dense()
andilp_info()
(to solve an IP problem); these functions are designed to solve problems of the formwhere is an -element vector and is an matrix (i.e., there are variables and general linear constraints).
ilp_dense()
is used if at least one of the variables is restricted to take an integer value at the optimum solution. The document forilp_mpsx_convert()
should be consulted for a detailed description of the MPSX format.In the MPSX data file the first free row, that is a row defined with the row type , is taken as the objective row. Similarly, if there are more than one RHS, RANGES or BOUNDS sets, then the first set is used for the optimization.
ilp_mpsx
also prints the solution to the problem using the row and column names specified in the MPSX data file (by callingilp_print()
).
- References
IBM, 1971, MPSX – Mathematical programming system, Program Number 5734 XM4, IBM Trade Corporation, New York