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.

{Edge} Edges = {, , };int a[Edges] = [10,20,30];defines an integer array, a, indexed by a finite set of tuples. Its elements are a[],a[], and a[]. Tuples are described in detail in Tuples.Multidimensional arrays<strong>OPL</strong> supports the declaration of multidimensional arrays (see Data initialization about theellipsis syntax). For example, the declaration:int a[1..2][1..3] = ...;declares a two-dimensional array, a, indexed by two integer ranges. Indexed sets of differenttypes can of course be combined, as inint a[Days][1..3] = ...;which is a two-dimensional array whose elements are of the form a[Monday][1]. It isinteresting to contrast multidimensional and one-dimensional arrays of tuples.Consider the declaration:{string} Warehouses = ...;{string} Customers = ...;int transp[Warehouses,Customers] = ...;that declares a two-dimensional array transp. This array may represent the units shippedfrom a warehouse to a customer. In large-scale applications, it is likely that a given warehousedelivers only to a subset of the customers. The array transp is thus likely to be sparse, i.e.it will contain many zero values.The sparsity can be exploited by declarations of the form:{string} Warehouses ...;{string} Customers ...;tuple Route {string w;string c;}{Route} routes = ...;int transp[routes] = ... ;This declaration specifies a set, routes, that contains only the relevant pairs (warehouse,customer). The array transp can then be indexed by this set, exploiting the sparsity presentI 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 L25

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

Saved successfully!

Ooh no, something went wrong!