didppy.SetTable3D

class didppy.SetTable3D

3-dimensional table of set constants.

t[x, y, z] returns a set expression referring to an item where t is SetTable3D and x, y, and z 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]], [[], [2]]], [[[1, 1], [2, 3]], [[], [2]]]],
...     object_type=obj2
... )
>>> table[0, var, 1].eval(model.target_state, model)
{1, 2}

Methods

intersection(x, y, z)

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

symmetric_difference(x, y, z)

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

union(x, y, z)

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

intersection(x, y, z)

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, y, or z 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]], [[], [2]]], [[[1, 1], [2, 3]], [[], [2]]]],
...     object_type=obj2
... )
>>> table.intersection(0, var, 1).eval(model.target_state, model)
{2}
symmetric_difference(x, y, z)

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, y, or z is a negative integer.

Examples

>>> import didppy as dp
>>> model = dp.Model()
>>> object1 = model.add_object_type(number=2)
>>> object2 = 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]], [[], [2]]], [[[1, 1], [2, 3]], [[], [2]]]],
...     object_type=obj2
... )
>>> table.symmetric_difference(0, var, 1).eval(model.target_state, model)
{1}
union(x, y, z)

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, y, or z 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]], [[], [2]]], [[[1, 1], [2, 3]], [[], [2]]]],
...     object_type=obj2
... )
>>> table.union(0, var, 1).eval(model.target_state, model)
{1, 2}