didppy.SetTable1D
- class didppy.SetTable1D
1-dimensional table of set constants.
t[x]
returns a set expression referring to an item wheret
isSetTable1D
andx
isElementExpr
,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]], object_type=obj2) >>> table[var].eval(model.target_state, model) {2, 3}
Methods
intersection
(x)Takes the intersection of set constants in a table over the set of indices.
Takes the symmetric difference of set constants in a table over the set of indices.
union
(x)Takes the union of set constants in a table over the set of indices.
- intersection(x)
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.
- Returns:
The intersection.
- Return type:
- Raises:
OverflowError – If x 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=6) >>> var = model.add_set_var(object_type=obj1, target=[0, 1]) >>> table = model.add_set_table([[2, 3], [1, 2]], object_type=obj2) >>> table.intersection(var).eval(model.target_state, model) {2}
- symmetric_difference(x)
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.
- Returns:
The symmetric difference.
- Return type:
- Raises:
OverflowError – If x 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=6) >>> var = model.add_set_var(object_type=obj1, target=[0, 1]) >>> table = model.add_set_table([[2, 3], [1, 2]], object_type=obj2) >>> table.symmetric_difference(var).eval(model.target_state, model) {1, 3}
- union(x)
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.
- Returns:
The union.
- Return type:
- Raises:
OverflowError – If x 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=6) >>> var = model.add_set_var(object_type=obj1, target=[0, 1]) >>> table = model.add_set_table([[2, 3], [1, 2]], object_type=obj2) >>> table.union(var).eval(model.target_state, model) {1, 2, 3}