ILOG CPLEX 10.1 User's Manual > Discrete Optimization > Logical Constraints in Optimization > What Can Be Extracted from a Model with Logical Constraints?

Much the same logical constraints are available in these APIs of ILOG CPLEX.

For similar facilities in the Callable Library, see Using Indicator Constraints.

Logical Constraints in the C++ API

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.

Logical Constraints in the Java API

Of course, because the Java programming language does not support the overloading of operators as C++ does, overloaded logical operators are not supported in the Java API of Concert Technology. However, the Java class IloCplexModeler offers logical modeling facilities through methods, such as:

Moreover, like their C++ counterparts, those extractable Java 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 Java application.

Logical Constraints in the .NET API

Similarly, the .NET API of Concert Technology supports logical constraints, though not operator overloading. The .NET class Cplex offers these overloaded logical methods:

Again, those extractable .NET objects accept other linear constraints or logical constraints as their arguments, thus making it possible for you to combine linear constraints with logical constraints in expressions in your .NET applications.