mmxprs
The mmxprs module provides access to FICO® Xpress Optimizer from within a Mosel model and as such it requires the Xpress Optimizer library (XPRS) to be installed on the system. To use this module, the following line must be included in the header of the Mosel model file:
uses 'mmxprs'
A large number of optimization-related routines are provided, ranging from those for finding a solution to the problem, to those for setting callbacks and cut manager functions. Whilst a description of their usage is provided in this manual, further details relating to the usage of these may be found by consulting the Xpress Optimizer Reference Manual.
New functionality for the Mosel language
The problem type mpproblem.xprs
This module exposes its functionality through an extension to the mpproblem problem type. As a consequence, all routines presented here are executed in the context of the current problem. In particular, the setting of a control parameter is applied only to the current problem and each problem has its own set of settings and solution information. However, when a new problem instance is created, the value of the control parameters XPRS_colorder, XPRS_enummaxsol, XPRS_enumduplpol, XPRS_loadnames and XPRS_verbose are initialised with the settings of the main problem.
The type basis
The module mmxprs defines the type basis to represent solution basis in the Mosel Language. This new type is used to store a basis computed by the optimizer during its solution process (savebasis). A basis can then be loaded again into the optimiser with loadbasis, inspected (by getting the basis status of each variable/constraint it includes with getbstat) or modified (by changing this basis status using setbstat). The type basis supports assignment and test of equality. This comparison only checks whether two basis contain the same information, it does not indicate whether the basis are equivalent.
The type mpsol
The type mpsol characterises a solution of an MP problem by associating a value to each decision variable (type mpvar) of the problem. Initialising such an object can be achieved by saving the current solution found by the optimiser (savesol or savemipsol) or by building it one variable at a time (setsol). Various routines requiring solution information support the solution object. For instance getsol may be used to evaluate an expression on a specific solution; loadmipsol and addmipsol accept this object as input. A solution might be saved into a file using writesol and the resulting file can be loaded into the optimiser with readsol. The type mpsol supports assignment and test of equality.
The type logctr
The type logctr represents either a logical expression over linear constraints or an indicator constraint (see indicator). Logical expressions can be built using standard operators (and, or, not) or with the help of the dedicated functions implies and xor. These logical constructs are handled like linear constraints: they are associated to the current problem, can be (re)defined via assignments and hidden using sethidden. Note however that logical constructs are not shown by exportprob although the mmxprs routine writeprob will report them.
If logical expressions are employed in a model, the loading of the problem into the optimizer requires the use of the helper package "advmod":
uses 'advmod'
This package is not necessary when a model uses only indicator constraints directly.
Control parameters
This module extends the getparam function and the setparam procedure in order to access all the control and problem parameters of Optimizer (for example the problem attribute LPSTATUS is mapped to the mmxprs control parameter XPRS_lpstatus). In addition to these, the following control parameters are also defined:
XPRS_colorder |
Reorder matrix columns before loading the problem.
|
XPRS_enumduplpol |
Handling of duplicate solutions during an enumeration.
|
XPRS_enummaxsol |
Maximum number of solutions to be saved during an enumeration.
|
XPRS_enumsols |
Number of solutions found during the last enumeration.
|
XPRS_fullversion |
Optimizer version number.
|
XPRS_loadnames |
Enable/disable loading of MPS names into the Optimizer.
|
XPRS_problem |
Optimizer problem pointers.
|
XPRS_probname |
Read/set the problem name used by the Optimizer.
|
XPRS_verbose |
Enable/disable message printing by the Optimizer.
|
setparam("XPRS_verbose", true) ! Turn on message printing pstat:= getparam("XPRS_lpstatus") ! Get the problem LP optimization status writeln("Best bound=", getparam("XPRS_bestbound")) ! Display the best bound value
Procedures and functions
This section lists in alphabetical order the functions and procedures that are provided by the mmxprs module.
addmipsol |
Add a MIP solution to the optimizer.
|
basisstability |
Get basis stability information.
|
calcsolinfo |
Calculates a property of an mpsol solution.
|
clearmipdir |
Delete all defined MIP directives.
|
clearmodcut |
Delete all defined model cuts.
|
command |
Execute an Optimizer command.
|
copysoltoinit |
Copy solution values to initial values of an NL problem.
|
defdelayedrows |
Define the set of constraints to be treated as delayed rows.
|
defsecurevecs |
Define the variables and constraints to be preserved.
|
estimatemarginals |
Estimate better marginal values for variables and constraints for degenerate problems.
|
fixglobal |
Fix values of global entitites.
|
getbstat |
Get the status of a variable or constraint in a basis.
|
getdualray |
Get a dual ray for an infeasible problem.
|
getiis |
Compute then get the Irreductible Infeasible Sets (IIS).
|
getiissense |
Decode the sense part of an IIS bound type information.
|
getiistype |
Decode the type part of an IIS bound type information.
|
getinfcause |
Returns the variable or constraint causing infeasibility.
|
getinfeas |
Returns sets of infeasible primal and dual variables.
|
getlb |
Get the lower bound of a variable.
|
getloadedlinctrs |
Get the linear constraints loaded into the optimiser.
|
getloadedmpvars |
Get the decision variables loaded into the optimiser.
|
getname |
Get the name of a decision variable or constraint.
|
getprimalray |
Get a primal ray for an unbounded problem.
|
getprobstat |
Get the Optimizer problem status.
|
getrange |
Get a range value for a variable or constraint.
|
getsensrng |
Get sensivity ranges for objective or RHS function coefficients.
|
getsize |
Get the size of a solution.
|
getsol |
Get the solution value of an expression from a solution object.
|
getub |
Get the upper bound of a variable.
|
getvars |
Get the set of variables of a solution.
|
hasfeature |
Check if a specific feature is supported by the currently used license.
|
implies |
Create an implies expression.
|
indicator |
Create an indicator constraint.
|
isiisvalid |
Check whether an IIS number exists.
|
isintegral |
Check whether a solution value is integral.
|
loadbasis |
Load a previously saved basis.
|
loadmipsol |
Load a MIP solution into the optimizer.
|
loadprob |
Load a problem into the optimizer.
|
maximize, minimize |
Maximize/minimize the current problem.
|
postsolve |
Postsolve the current matrix.
|
readbasis |
Read a basis from a file.
|
readdirs |
Read directives from a file.
|
readsol |
Read a solution from a file.
|
refinemipsol |
Executes the MIP solution refiner on an mpsol solution.
|
rejectintsol |
Reject a PREINTSOL solution.
|
repairinfeas |
Relaxing bounds to repair infeasibility.
|
resetbasis |
Reset a basis.
|
resetiis |
Reset the search for IIS.
|
resetsol |
Reset a solution.
|
savebasis |
Save the current basis.
|
savemipsol |
Save the current solution into the provided array or solution object.
|
savesol |
Save the current solution into a solution object.
|
savestate |
Save current state of the Optimizer to a file.
|
selectsol |
Select one of the solutions found by solution enumerator.
|
setarchconsistency |
Sets the optimizer architecture control.
|
setbstat |
Set the status of a variable or constraint in a basis.
|
setcallback |
Set optimizer callback functions and procedures.
|
setcbcutoff |
Set cutoff for PREINTSOL callback.
|
setgndata |
Update data for GAPNOTIFY callback.
|
setlb |
Set the lower bound of a variable.
|
setmipdir |
Set a directive on a variable or Special Ordered Set.
|
setmodcut |
Mark a constraint as a model cut.
|
setsol |
Define the value associated to a decision variabe in a solution object.
|
setub |
Set the upper bound of a variable.
|
setucbdata |
Update data for CHGBRANCH callback.
|
stopoptimize |
Interrupt the optimizer algorithms.
|
unloadprob |
Unload the problem held in the optimizer.
|
writebasis |
Write the current basis to a file.
|
writedirs |
Write current directives to a file.
|
writeprob |
Write the current problem to a file.
|
writesol |
Write a solution to a file.
|
xor |
Create an exclusive or expression.
|
Cut Pool Manager
This section contains the functions and procedures of the Xpress Optimizer cut manager. For a detailed description of the cut manager and its functionality the user is referred to the Xpress Optimizer Reference Manual. To run the cut manager from Mosel, it may be necessary to (re)set certain control parameters of the optimizer. For example, switching off presolve and automatic cut generation, and reserving space for extra rows in the matrix may be useful:
setparam("XPRS_presolve", 0); /* Switch presolve off... */ setparam("XPRS_presolveops", 2270); /* ...or use secure setting for presolve */ setparam("XPRS_cutstrategy", 0); /* Switch automatic cut generation off */ setparam("XPRS_extrarows", 5000); /* Reserve space for 5000 extra rows in the matrix*/
The callback functions and procedures that are relevant to the cut manager are initialized with function setcallback, in common with the other Optimizer callbacks.
It should be noted that cuts are not stored by Mosel but sent immediately to the Optimizer. Consequently, if a problem is reloaded into the Optimizer, any previously defined cuts will be lost. In Mosel, cuts are defined by specifying a linear expression (i.e. an unbounded constraint) and the operator sign (inequality/equality). If instead of a linear expression a constraint is given, it will also be added to the system as an additional constraint.
addcut |
Add a cut to the problem in the optimizer.
|
addcuts |
Add an array of cuts to the problem in the optimizer.
|
delcuts |
Delete cuts from the problem in the optimizer.
|
dropcuts |
Drop a set of cuts from the cut pool.
|
getcnlist |
Get the set of cuts active at the current node.
|
getcplist |
Get a set of cut indices from the cut pool.
|
loadcuts |
Load a set of cuts into the problem in the optimizer.
|
storecut |
Store a cut into the cut pool.
|
storecuts |
Store an array of cuts into the cut pool.
|