Next: Interface for CLP-Integration
Up: EPLEX: The ECLiPSe/CPLEX Interface
Previous: Ranged and Typed Variables
  Index
Subsections
One possible use of this library is to use ECLiPSejust as a
modeling language and let the external solver do all the solving.
For that purpose, a high-level interface is provided. It consists
of primitives for setting up linear constraints and a single
optimization primitive to invoke the external solver on these constraints.
The constraints provided are equalities and inequalities over
linear expressions.
Their operational behaviour is as follows:
- When they contain no variables, they simply succeed or fail.
- When they contain exactly one variable, they are translated into
a bound update on that variable, which may in turn fail, succeed,
or even instantiate the variable.
Note that if the variable's type is integer, the bound will be adjusted
to the next suitable integral value.
- Otherwise, the constraint delays until it
is later transferred to the external solver.
This mechanism makes it possible to interface to a non-incremental
black-box solver that requires all constraints at once,
or to send constraints to the solver in batches
X is equal to Y. X and Y are linear expressions.
X is greater or equal to Y. X and Y are linear expressions.
X is less or equal to Y. X and Y are linear expressions.
The following arithmetic expression can be used inside the constraints:
- X
- Variables. If X is not yet a ranged variable, it is turned into one
via an implicit declaration X :: -inf..inf.
- 123, 3.4
- Integer or floating point constants.
- +Expr
- Identity.
- -Expr
- Sign change.
- E1+E2
- Addition.
- sum(ListOfExpr)
- Equivalent to the sum of all list elements.
- E1-E2
- Subtraction.
- E1*E2
- Multiplication.
- ListOfExpr1*ListOfExpr2
- Scalar product: The sum of the products of the corresponding
elements in the two lists. The lists must be of equal length.
After setting up the constraints with the primitives described above,
the external solver's MIP optimizer can be invoked as a black box using
optimize(+Objective, -Cost)
Objective is either min(Expr) or max(Expr) where Expr is a linear
expression.
This calls the external solver's optimizer and succeeds if it finds an optimum.
In this case the problem variables get instantiated to the
solution values, and Cost gets bound to the cost of this solution.
Note that this will find at most one solution, ie. you won't get
alternative optima on backtracking.
In section 8.6.6 we will later show how optimize/2 is
built on top of the lower level functionality.
Here is a simple linear program.
As long as the optimizer is not invoked, the constraints just delay:
[eclipse 2]: X+Y $>= 3, X-Y $= 0.
X = X
Y = Y
Delayed goals:
X + Y$>=3
X - Y$=0
yes.
Now a call to
optimize/2 is added
in order to trigger the solver:
[eclipse 3]: X+Y $>= 3, X-Y $= 0, optimize(min(X), C).
Y = 1.5
X = 1.5
C = 1.5
(Note that X and Y have not been explicitly declared.
They default to reals ranging from -infinity to +infinity.)
By declaring one variable as integer, we obtain a Mixed Integer Problem:
[eclipse 4]: integers([X]), X+Y $>= 3, X-Y $= 0, optimize(min(X), C).
Y = 2.0
X = 2
C = 2.0
yes.
Next: Interface for CLP-Integration
Up: EPLEX: The ECLiPSe/CPLEX Interface
Previous: Ranged and Typed Variables
  Index
1999-08-06