didppy.SetTable3D
- class didppy.SetTable3D
3-dimensional table of set constants.
t[x, y, z]returns a set expression referring to an item wheretisSetTable3Dandx,y, andzareElementExpr,ElementVar,ElementResourceVar, orint.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:
x (int, ElementExpr, ElementVar, ElementResourceVar, SetExpr, SetVar, or SetConst) – Set of indices for the first dimension.
y (int, ElementExpr, ElementVar, ElementResourceVar, SetExpr, SetVar, or SetConst) – Set of indices for the second dimension.
z (int, ElementExpr, ElementVar, ElementResourceVar, SetExpr, SetVar, or SetConst) – Set of indices for the third dimension.
- Returns:
The intersection.
- Return type:
- 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:
x (int, ElementExpr, ElementVar, ElementResourceVar, SetExpr, SetVar, or SetConst) – Set of indices for the first dimension.
y (int, ElementExpr, ElementVar, ElementResourceVar, SetExpr, SetVar, or SetConst) – Set of indices for the second dimension.
z (int, ElementExpr, ElementVar, ElementResourceVar, SetExpr, SetVar, or SetConst) – Set of indices for the third dimension.
- Returns:
The symmetric difference.
- Return type:
- 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:
x (int, ElementExpr, ElementVar, ElementResourceVar, SetExpr, SetVar, or SetConst) – Set of indices for the first dimension.
y (int, ElementExpr, ElementVar, ElementResourceVar, SetExpr, SetVar, or SetConst) – Set of indices for the second dimension.
z (int, ElementExpr, ElementVar, ElementResourceVar, SetExpr, SetVar, or SetConst) – Set of indices for the third dimension.
- Returns:
The union.
- Return type:
- 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}