with

OPL keyword for membership

Purpose

OPL and IBM ILOG Script keyword to indicate that an element of a tuple must be contained in a given set.

context
Model files (.mod)

Note that the keyword with is not currently supported for an array of tuple sets.

Syntax

References_opt: /* empty */
               | "with" References

Description

The with keyword enables you to indicate that an element of a tuple must be contained in a given set. If you use this syntax, OPL checks the consistency of the tuple set at run time when initializing the set. This syntax is recommended because it also saves memory.

See the Data membership consistency in the Language Reference Manual.

Example

{int} nodes = {1, 5, 7};
 
tuple arc  {
  int origin;
  int destination;
}
 
{arc} arcs1 with origin in nodes, destination in nodes = 
  {<1,5>, <5,7>};
 
execute {
  writeln(arcs1);
};