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.

initialize i to {1}, u to {1,2,3,5,7,9}, d to {2,3}, and sd to {2,3,4,5}.It is also possible to initialize a set from a range expression. For example, the declaration:{int} s = asSet(1..10)initializes s to {1,2,..,10}It is important to point out at this point that sets initialized by ranges are represented explicitly(unlike ranges). As a consequence, a declaration of the form{int} s = asSet(1..100000);creates a set where all the values 1, 2, ..., 100000 are explicitly represented, while the rangerange s = 1..100000;represents only the bounds explicitly.More about internal initialization of setsWhen writing the assignment s2=s1, you add one element to s1, that element is also addedto s2. If you do not want this, writes1={i|i in s2}For example, compare the statements in Initializing sets in the model file:Initializing sets in the model fileIf you writethe result is{1 2 3}{int} s1={1,2};{int} s2=s1;execute{s2.add(3);writeln(s1);}{1 2}{int} s1={1,2};{int} s2={ i | i in s1};//{int} s2=s1;execute{s2.add(3);writeln(s1);}50I 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!