ILOG CPLEX 11.0 User's Manual > Discrete Optimization > Logical Constraints in Optimization > What Can Be Extracted from a Model with Logical Constraints? > Logical Constraints in the C++ API |
Logical Constraints in the C++ API |
INDEX PREVIOUS NEXT |
In C++ applications, the class IloCplex
can extract modeling objects to solve a wide variety of MIPs, as you see in Solving the Model, summarized in Table 1.1. In fact, the C++ class IloCplex
can extract logical constraints as well as some logical expressions. The logical constraints that IloCplex
can extract are these:
Among those extractable objects, IloAnd
IloOr
, IloNot
, and IloDiff
can also be represented in your application by means of the overloaded C++ operators:
All those extractable objects accept as their arguments other linear constraints or logical constraints, so you can combine linear constraints with logical constraints in complicated expressions in your application.
For example, to express the idea that two jobs with starting times x1
and x2
and with duration d1
and d2
must not overlap, you can either use overloaded C++ operators, like this:
model.add((x1 >= x2 + d2) || (x2 >= x1 + d1)); |
or you can express the same idea, like this:
IloOr or(env) or.add(x1 >= x2 + d2); or.add(x2 >= x1 + d1); model.add(or); |
Since IloCplex
can also extract logical constraints embedded in other logical constraints, you can also write logical constraints like this:
IloIfThen(env, (x >= y && x >= z), IloNot(x <= 300 || y >= 700)) |
where x
, y
, and z
are variables in your application.
Copyright © 1987-2007 ILOG S.A. All rights reserved. Legal terms. | PREVIOUS NEXT |