didppy.SetTable2D

class didppy.SetTable2D

2-dimensional table of set constants.

t[x, y] returns a set expression referring to an item where t is SetTable2D and x and y are ElementExpr, ElementVar, ElementResourceVar, or int.

Examples

>>> import didppy as dp
>>> model = dp.Model()
>>> obj1 = model.add_object_type(number=2)
>>> obj2 = model.add_object_type(number=4)
>>> var = model.add_element_var(object_type=obj1, target=0)
>>> table = model.add_set_table(
...     [[[2, 3], [1, 2]], [[1, 1], [0, 1]]],
...     object_type=obj2
... )
>>> table[0, var].eval(model.target_state, model)
{2, 3}

Methods

intersection(x, y)

Takes the intersection of set constants in a table over the set of indices.

symmetric_difference(x, y)

Takes the symmetric difference of set constants in a table over the set of indices.

union(x, y)

Takes the union of set constants in a table over the set of indices.

intersection(x, y)

Takes the intersection of set constants in a table over the set of indices.

Parameters:
Returns:

The intersection.

Return type:

SetExpr

Raises:

OverflowError – If x or y is a negative integer.

Examples

>>> import didppy as dp
>>> model = dp.Model()
>>> obj1 = model.add_object_type(number=2)
>>> obj2 = model.add_object_type(number=4)
>>> var = model.add_set_var(object_type=obj1, target=[0, 1])
>>> table = model.add_set_table(
...     [[[2, 3], [1, 2]], [[1, 1], [0, 1]]],
...     object_type=obj2
... )
>>> table.intersection(0, var).eval(model.target_state, model)
{2}
symmetric_difference(x, y)

Takes the symmetric difference of set constants in a table over the set of indices.

Parameters:
Returns:

The symmetric difference.

Return type:

SetExpr

Raises:

OverflowError – If x or y is a negative integer.

Examples

>>> import didppy as dp
>>> model = dp.Model()
>>> obj1 = model.add_object_type(number=2)
>>> obj2 = model.add_object_type(number=4)
>>> var = model.add_set_var(object_type=obj1, target=[0, 1])
>>> table = model.add_set_table(
...     [[[2, 3], [1, 2]], [[1, 1], [0, 1]]],
...     object_type=obj2
... )
>>> table.symmetric_difference(0, var).eval(model.target_state, model)
{1, 3}
union(x, y)

Takes the union of set constants in a table over the set of indices.

Parameters:
Returns:

The union.

Return type:

SetExpr

Raises:

OverflowError – If x or y is a negative integer.

Examples

>>> import didppy as dp
>>> model = dp.Model()
>>> obj1 = model.add_object_type(number=2)
>>> obj2 = model.add_object_type(number=4)
>>> var = model.add_set_var(object_type=obj1, target=[0, 1])
>>> table = model.add_set_table(
...     [[[2, 3], [1, 2]], [[1, 1], [0, 1]]],
...     object_type=obj2
... )
>>> table.union(0, var).eval(model.target_state, model)
{1, 2, 3}