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.

The all syntaxThen, the all syntax allows you to dynamically collect some decision variables or constantsinto an array. The syntax is similar to sum and forall, it contains a series of possiblegenerators (an index and a set or a range in which this index is to be contained), some possiblefilters (to filter out some of the enumerated combinations), and a body (here of the form x[i][j]...). The variables or values in the resulting array follow the logical order ofenumerating the index combinations as defined by the generators.By default, this dynamic array is indexed from 0 to numberOfElements-1. As someconstraints make a particular usage of the index, it may be interesting to define another indexingschema. For this, it is possible to dynamically define the range of the resulting array of variablesby using the syntax [minindex..maxindex]. Finally, it is possible to use "*" asmaxIndex to indicate that only the minIndex is defined; the maxIndex will be setaccordingly depending on the number of elements.Here is a complete of usage of the syntax:using CP;int n = 5;range R = 1..n;dvar int x[R] in R;subject to {allDifferent(all(i in R:i%2==1) x[i]);}Obviously, this is just a new possibility to define array of variables or values and in all theconstraints and expressions that take arrays. You can use either this new syntax or pass directlya named array. When you pass a named array and indexes make sense in the constraint, itsindexer will be used to index the elements if it has one dimension only. If it has two dimensions,the indexer cannot be used.I 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 L85

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

Saved successfully!

Ooh no, something went wrong!