diff
OPL keyword to compute the difference between two sets.
Purpose
OPL keyword to construct set expressions
| context |
|---|
| Model files (.mod) |
Syntax
BinaryExpression: Expression "==" Expression
| Expression "!=" Expression
| Expression "<=" Expression
| Expression "<" Expression
| Expression ">=" Expression
| Expression ">" Expression
| Expression "+" Expression
| Expression "-" Expression
| Expression "*" Expression
| Expression "/" Expression
| Expression "%" Expression
| Expression "in" Expression
| Expression "not in" Expression
| Expression "inter" Expression
| Expression "union" Expression
| Expression "diff" Expression
| Expression "symdiff" Expression
| Expression "^" Expression
| Expression "&&" Expression
| Expression "||" Expression
Description
Set
data can be initialized by set expressions. These expressions are
constructed from previously defined sets and the set operations union, inter, diff, and symdiff.
The keyword diff goes through the
first set and keeps each element that is not in the second set.
Example
The following
code initializes i to {1}, u to
{1,2,3,4,5}, d to {2,3}, and sd to
{2,3,4,5}.
{int} s1 = {1,2,3};
{int} s2 = {1,4,5};
{int} i = s1 inter s2;
{int} u = s1 union s2;
{int} d = s1 diff s2;
{int} sd = s1 symdiff s2;
assert(1 in s1);
assert(4 not in s1);
This
is true if the result is an ordered set. If you apply the property sorted or reversed to
the resulting set, the result is affected accordingly.