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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The special case of linear expressions is represented by objects of typeIloLinearNumExpr. Such expressions are editable, which is especially convenient whenbuilding up linear expressions in a loop, like this:IloLinearNumExpr lin = cplex.linearNumExpr();for (int i = 0; i < num; ++i)lin.addTerm(value[i], variable[i]);It should be noted that the special case of the scalar product of an array of values with anarray of variables is directly supported through the method scalProd. Thus the above loopcan be rewritten as:IloLinearNumExpr lin = cplex.scalProd(value, variable);It is recommended that you build expressions in terms of data that is either integer ordouble-precision (64 bit) floating-point. Single-precision (32 bit) floating-point data shouldbe avoided as it can result in unnecessarily ill-conditioned problems. For more information,refer to Numeric Difficulties on page 185.Ranged ConstraintsRanged constraints are constraints of the form: lb ≤ expression ≤ ub and arerepresented in Concert Technology by objects of type IloRange. The most generalconstructor is:IloRange rng = cplex.range(lb, expr, ub, name);where lb and ub are double values, expr is of type IloNumExpr, and name is a string.By choosing the range bounds appropriately, ranged constraints can be used to model any ofthe more commonly found constraints of the form:expr relation rhs,where relation is the relation =, ≤, or ≥. The following table shows how to choose lb andub for modeling these relations:relation lb ub method= rhs rhs eq≤ -Double.MAX_VALUE rhs le≥ rhs Double.MAX_VALUE geThe last column contains the method provided with IloModeler to use directly to createthe appropriate ranged constraint, when you specify the expression and righthand side(RHS). For example, the constraint expr ≤ 1.0 is created by callingIloRange le = cplex.le(expr, 1.0);Again, all constructors for ranged constraints come in pairs, one constructor with and onewithout a name parameter.<strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL 77

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

Saved successfully!

Ooh no, something went wrong!