> Discrete Optimization > Logical Constraints in Optimization > What Does CPLEX Transform? |
What Does CPLEX Transform? |
INDEX PREVIOUS NEXT |
In ILOG CPLEX with ILOG Concert Technology for C++ users, logical constraints and logical expressions are transformed at extraction, meaning that IloCplex
transforms them into an equivalent set of constraints that may introduce additional discrete variables to the formulation along with integrality restrictions.
For example, look again at the constraint that you saw in the scheduling problem of two jobs with durations that must not overlap, and consider it in the context of an application that exports the model to a file in LP format, like this:
After you execute that application, the file logic_example.lp
contains this model:
Minimize obj: Subject To id10: x1 - x2 - 2100 b >= -2000 id12: - x1 + x2 + 2030 b >= 30 Bounds 0 <= x1 <= 2000 0 <= x2 <= 2000 0 <= b <= 1 Generals b End |
You can see in that file that a binary variable b
has been introduced to express the logical constraint, and two linear constraints have been added. When b = 0
, the constraint x2 >= x1 + 30
is satisfied, thanks to the linear constraint id12
. If b = 1
, then the constraint x1 >= x2 + 100
is satisfied, thanks to the linear constraint id10
.
ILOG CPLEX uses this kind of transformation for every logical constraint and every logical term.
To get an idea of how cardinality (counting how many) is transformed, look again at the cardinality constraint in the problem of three products of differing quantities, where a good solution entails quantities greater than 20 for at least two of the three products.
IloNumVarArray x(env, 3, 0, 1000); model.add((x[0] >= 20) + (x[1] >= 20) + (x[2] >= 20) >= 2); |
The exported model of that constraint in LP format looks like this:
That model shows how ILOG CPLEX transforms logical terms: it introduces three binary variables, one for each constraint. When the value of a binary variable is 1, then the corresponding constraint x[i] >= 20
must be satisfied as well.
Copyright © 1987-2003 ILOG, S.A. All rights reserved. Legal terms. | PREVIOUS NEXT |