didppy.IntTable2D
- class didppy.IntTable2D
2-dimensional table of integer constants.
t[x, y]
returns an integer expression referring to an item wheret
isIntTable2D
andx
andy
areElementExpr
,ElementVar
,ElementResourceVar
, orint
. Ifx
and/ory
are/isSetExpr
,SetVar
, orSetConst
,t[x, y]
returns the sum of constants overx
andy
.Examples
>>> import didppy as dp >>> model = dp.Model() >>> obj = model.add_object_type(number=2) >>> table = model.add_int_table([[2, 3], [-1, 2]]) >>> var = model.add_element_var(object_type=obj, target=1) >>> set_var = model.add_set_var(object_type=obj, target=[0, 1]) >>> table[var, set_var].eval(model.target_state, model) 1
Methods
max
(x, y)Takes the maximum of constants in a table over the set of indices.
min
(x, y)Takes the minimum of constants in a table over the set of indices.
product
(x, y)Takes the product of constants in a table over the set of indices.
- max(x, y)
Takes the maximum of 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 maximum.
- Return type:
- Raises:
OverflowError – If x or y is a negative integer.
Examples
>>> import didppy as dp >>> model = dp.Model() >>> obj = model.add_object_type(number=2) >>> table = model.add_int_table([[2, 3], [-1, 2]]) >>> var = model.add_element_var(object_type=obj, target=1) >>> set_var = model.add_set_var(object_type=obj, target=[0, 1]) >>> table.max(var, set_var).eval(model.target_state, model) 2
- min(x, y)
Takes the minimum of 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 minimum.
- Return type:
- Raises:
OverflowError – If x or y is a negative integer.
Examples
>>> import didppy as dp >>> model = dp.Model() >>> obj = model.add_object_type(number=2) >>> table = model.add_int_table([[2, 3], [-1, 2]]) >>> var = model.add_element_var(object_type=obj, target=1) >>> set_var = model.add_set_var(object_type=obj, target=[0, 1]) >>> table.min(var, set_var).eval(model.target_state, model) -1
- product(x, y)
Takes the product of 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 product.
- Return type:
- Raises:
OverflowError – If x or y is a negative integer.
Examples
>>> import didppy as dp >>> model = dp.Model() >>> obj = model.add_object_type(number=2) >>> table = model.add_int_table([[2, 3], [-1, 2]]) >>> var = model.add_element_var(object_type=obj, target=1) >>> set_var = model.add_set_var(object_type=obj, target=[0, 1]) >>> table.product(var, set_var).eval(model.target_state, model) -2