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.

Data membership consistencyThe keyword with enables you to indicate that a given element of a tuple must be containedin a given set. If you use it, <strong>OPL</strong> checks the consistency of the tuple set at run time wheninitializing the set. The syntax is:{tupletype} tupleset with cell1 in set1, cell2 in set = ...;Let's take an example. You have a set of arcs between nodes. Nodes are defined by a tupleset of tuples consisting of an origin node and a destination node. The with syntax enablesyou to ensure that the origin and destination nodes do belong to a given set of nodes. CompareData found inconsistent (keyword with) and Data found consistent (keyword with):Data found inconsistent (keyword with){int} nodes = {1, 5, 7};tuple arc {int origin;int destination;}{arc} arcs2 with origin in nodes, destination in nodes ={, };execute {writeln(arcs2);};Data found consistent (keyword with){int} nodes = {1, 5, 7};tuple arc {int origin;int destination;}{arc} arcs1 with origin in nodes, destination in nodes ={, };execute {writeln(arcs1);};If you write Data found inconsistent (keyword with), an error will be raised when the setarcs2 is initialized because the with syntax will detect that the statement(int) nodes = (1, 5, 7);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 L73

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

Saved successfully!

Ooh no, something went wrong!