didppy.SetTable2D
- class didppy.SetTable2D
2-dimensional table of set constants.
t[x, y]returns a set expression referring to an item wheretisSetTable2DandxandyareElementExpr,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]], [[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:
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.
- Returns:
The intersection.
- Return type:
- 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:
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.
- Returns:
The symmetric difference.
- Return type:
- 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:
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.
- Returns:
The union.
- Return type:
- 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}