12.07.2015 Views

ILOG OPL Development Studio Language Reference Manual

ILOG OPL Development Studio Language Reference Manual

ILOG OPL Development Studio Language Reference 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.

Decision variablesShows how to declare and use decision variables in the <strong>OPL</strong> language.A decision variable is an unknown in an optimization problem. It has a domain, which is acompact representation of the set of all possible values for the variable. Decision variabletypes are references to objects whose exact nature depends on the underlying optimizer of amodel. A decision variable can be instantiated only in the context of a given model instance.The purpose of an <strong>OPL</strong> model is to find values for the decision variables such that allconstraints are satisfied or, in optimization problems, to find values for the variables thatsatisfy all constraints and optimize a specific objective function. Variables in <strong>OPL</strong> are thusessentially decision variables and differ fundamentally from variables in programminglanguages such as Java, and <strong>ILOG</strong> Script.Note: <strong>OPL</strong> decision variables are noted with the dvar keyword while the keyword var denotes<strong>ILOG</strong> Script variables.A decision variable declaration in <strong>OPL</strong> specifies the type and set of possible values for thevariable. Once again, decision variables can be of different types (integer, float) and it ispossible to define multidimensional arrays of decision variables. The declarationdvar int transp[Orig][Dest] in 0..100;declares a two-dimensional array of integer variables. The decision variables are constrainedto take their values in the range 0..100 ; i.e., any solution to the model containing thisdeclaration must assign values between 0 and 100 to these variables. Note that all integervariables need a finite range in <strong>OPL</strong>. Arrays of decision variables can be constructed usingthe same index sets as arrays of data. In particular, it is also possible, and desirable for largerproblems, to index arrays of decision variables by finite sets. For example, the excerpt:tuple Route {City orig;City dest}{Route} routes = ...:dvar int transp[routes] in 0..100;declares an array of decision variables transp that is indexed by the finite set of tuplesroutes. Genericity can be used to initialize the domain of the variables. For example, theexcerpt:80I L O G O P L D E V E L O P M E N T S T U D I O L A N G U A G ER E F E R E N C E M A N U A L

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

Saved successfully!

Ooh no, something went wrong!