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.

Using IloModelerIloModeler defines an interface for building optimization models. This interface definesmethods for constructing variable, constraint, and objective function objects.Modeling VariablesA modeling variable in Concert Technology is represented by an object of type IloNumVaror one of its extensions. You can choose from a variety of methods defined in IloModelerand IloMPModeler to create one or multiple modeling variable objects. An example of themethod is:IloNumVar x = cplex.numVar(lb, ub, IloNumVarType.Float, "xname");This constructor method allows you to set all the attributes of a variable: its lower and upperbounds, its type, and its name. Names are optional in the sense that null strings areconsidered to be valid as well.The other constructor methods for variables are provided mainly for ease of use. Forexample, because names are not frequently assigned to variables, all variable constructorscome in pairs, where one variant requires a name string as the last parameter and the otherone does not (defaulting to a null string).Integer variables can be created by the intVar methods, and do not require the typeIloNumVarType.Int to be passed, as this is implied by the method name. The boundparameters are also specified more consistently as integers. These methods return objects oftype IloIntVar, an extension of interface IloNumVar that allows you to query and setbounds consistently using integers, rather than doubles as used for IloNumVar.Frequently, integer variables with 0/1 bounds are used as decision variables. To help createsuch variables, the boolVar methods are provided. In the Boolean type, 0 (zero) and 1 (one)are implied, so these methods do not need to accept any bound values.For all these constructive methods, there are also equivalent methods for creating a completearray of modeling variables at one time. These methods are called numVarArray,intVarArray, and boolVarArray.ExpressionsModeling variables are typically used in expressions that define constraints or objectivefunctions. Expressions are represented by objects of type IloNumExpr. They are built usingmethods such as sum, prod, diff, negative, and square. For example, the expressionx1 + 2*x2where x1 and x2 are IloNumVar objects, is constructed by calling:IloNumExpr expr = cplex.sum(x1, cplex.prod(2.0, x2));It follows that a single variable is a special case of an expression, since IloNumVar is anextension of IloNumExpr.76 <strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL

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

Saved successfully!

Ooh no, something went wrong!