12.07.2015 Views

ILOG CPLEX 11.0 User's Manual

ILOG CPLEX 11.0 User's Manual

ILOG CPLEX 11.0 User's Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Logical Constraints for CountingIn many cases it is even unnecessary to allocate binary variables explicitly in order to gainthe benefit of linear constraints within logical expressions. For example, optimizing howmany items appear in a solution is often an issue in practical problems. Questions ofcounting (how many?) can be represented formally as cardinality constraints.Suppose that your application includes three variables, each representing a quantity of one ofthree products, and assume further that a good solution to the problem means that thequantity of at least two of the three products must be greater than 20. Then you can representthat idea in your application, like this:IloNumVarArray x(env, 3, 0, 1000);model.add((x[0] >= 20) + (x[1] >= 20) + (x[2] >= 20) >= 2);Logical Constraints as Binary VariablesLinear or logical constraints can appear as terms in numeric expressions. A linear constraintappearing as a term in a numeric expression behaves like a binary value. For example, givenx and y as variables, you can write the following lines to get the truth value of x ≥ y in abinary value:IloIntVar b(env, 0, 1);model.add(b == (x >= y));It is important to note here that only linear constraints can appear as arguments of logicalconstraints extracted by IloCplex. That is, quadratic constraints are not handled in logicalconstraints. Similarly, quadratic terms cannot appear as arguments of logical expressionssuch as IloMin, IloMax, IloAbs, and IloPiecewiseLinear.How Are Logical Constraints Extracted?Logical constraints are transformed automatically into equivalent linear formulations whenthey are extracted by an <strong>ILOG</strong> <strong>CPLEX</strong> algorithm. This transformation involves automaticcreation by <strong>ILOG</strong> <strong>CPLEX</strong> of new variables and constraints. The transformation entailsindicators as discussed in Using Indicator Constraints on page 355.<strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL 353

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!