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.

Initializing arraysYou can initialize arrays:♦Externally♦Internally♦In preprocessing instructions♦As generic arrays♦As generic indexed arraysExternallyArrays can be initialized by external data, in which case the declaration has the form:int a[1..2] [1..3] = ...;and the actual initialization is given in a data source, which is a separate .dat file in<strong>ILOG</strong> <strong>OPL</strong>.Listing valuesThis is how arrays are initialized in most of the examples presented so far. Multidimensionalarrays in <strong>OPL</strong> are, in fact, arrays of arrays and must be initialized accordingly. For example,the declaration:/* .mod file */int a[1..2][1..3] = ...;/* .dat file */a = [[10, 20, 30],[40, 50, 60]];initializes a two-dimensional array by giving initializations for the one-dimensional arrays ofits first dimension. It is easy to see how to generalize this initialization to any number ofdimensions.Specifying pairsAn array can also be initialized by specifying pairs (index, value), as in the declaration:/* .mod file */int a[Days] = ...;42I 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!