# 3 Employing Linear Programming Solvers

## 3.1 The Module `LP`

The module `LP` is provided as contribution (being part of the Mozart Oz 3 distribution1) and can be accessed either by

`declare [LP] = {Module.link ['x-oz://contrib/LP']}`

or by

`import RI at 'x-oz://contrib/LP'`

as part of a functor definition.

`{LP.solve ``\$RIs`` ``+ObjFn`` ``+Constrs`` ``?OptSol`` ``?RetVal``}`

Invoke the LP solver. Use `LP.config` for configuring the solver.

 VECTOR_OF(X) ::= tuple of X | record of X | list of X

 RIs ::= VECTOR_OF(RI)

 RI ::= float | real interval variable

The first parameter is a vector of real-interval variables. The current bounds of the real-intervals are used as bound constraints by the LP solver. The second parameter determines the objective function:

 ObjFn ::= `objfn(row: ` `      opt: min | max)`

The value at `opt` stands for minimize (`min`) resp. maximize (`max`). The third parameter introduces the constraints to the LP solver.

 Constrs ::= VECTOR_OF(Constr)

 Constr ::= `constr(row:  ` `       type: '=<' | '==' | '>="` `       rhs:  ` float `)`

The fourth parameter `OptSol` is constrained to the optimal solution. In case it is already constrained to a real-interval variable, the LP solver derives an additional constraint which makes sure that no greater (minimize) resp. smaller (maximize) solution is found. The last parameter indicates the success of the LP solvers.

 RetVal ::= `optimal` | `infeasable` | `unbounded` | `failure`

`{LP.config ``+put`` ``+ConfigDirection``}`

Set configuration of module `LP`. One can set `mode` and `solver`.

`{LP.config ``+get`` ``?CurrentConfig``}`

Read current configuration of module `LP`.

 CurrentConfig ::= `config(avail:  ` | `       mode:   ` | `       solver: ``)`

Note that <SOLVER> takes a value out of <AVAIL_SOLVERS>. The solvers available depend on your local installation. The solver LP_SOLVE (`lpsolve`) is the default solver.

 AVAIL_SOLVERS ::= `lpsolve` | `cplex_primopt` | `cplex_dualopt`

The solver may run in two modes:

 MODES ::= `quiet` | `verbose`

The `verbose` mode is intended for debugging and outputs whether an optimal was found (resp. if not what was the problem) and if so the optimal solution.

1. The module `LP` is not provided on any Windows platform.

Tobias Müller
Version 1.4.0 (20080702)