didppy.IntTable
- class didppy.IntTable
Table of integer constants.
t[index]
returns an integer expression referring to an item wheret
isIntTable
andindex
is a sequence ofElementExpr
,ElementVar
,ElementResourceVar
, orint
. If one ofindex
isSetExpr
,SetVar
, orSetConst
,t[index]
returns the sum of constants.Examples
>>> import didppy as dp >>> model = dp.Model() >>> obj = model.add_object_type(number=2) >>> table = model.add_int_table({(0, 0, 0, 0): -1, (1, 1, 1, 1): 3}, default=2) >>> var = model.add_element_var(object_type=obj, target=1) >>> set_var = model.add_set_var(object_type=obj, target=[0, 1]) >>> table[0, var, set_var, 0].eval(model.target_state, model) 4
Methods
max
(indices)Takes the maximum of constants in a table over the set of indices.
min
(indices)Takes the minimum of constants in a table over the set of indices.
product
(indices)Takes the product of constants in a table over the set of indices.
- max(indices)
Takes the maximum of constants in a table over the set of indices.
- Parameters:
indices (tuple of int, ElementExpr, ElementVar, ElementResourceVar, SetExpr, SetVar, or SetConst) – Tuple of index sets.
- Returns:
The maximum.
- Return type:
- Raises:
OverflowError – If a negative integer is in
indices
.
Examples
>>> import didppy as dp >>> model = dp.Model() >>> obj = model.add_object_type(number=2) >>> table = model.add_int_table({(0, 0, 0, 0): -1, (1, 1, 1, 1): 3}, default=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((0, var, set_var, 0)).eval(model.target_state, model) 2
- min(indices)
Takes the minimum of constants in a table over the set of indices.
- Parameters:
indices (tuple of int, ElementExpr, ElementVar, ElementResourceVar, SetExpr, SetVar, or SetConst) – Tuple of index sets.
- Returns:
The minimum.
- Return type:
- Raises:
OverflowError – If a negative integer is in
indices
.
Examples
>>> import didppy as dp >>> model = dp.Model() >>> obj = model.add_object_type(number=2) >>> table = model.add_int_table({(0, 0, 0, 0): -1, (1, 1, 1, 1): 3}, default=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((0, var, set_var, 0)).eval(model.target_state, model) 2
- product(indices)
Takes the product of constants in a table over the set of indices.
- Parameters:
indices (tuple of int, ElementExpr, ElementVar, ElementResourceVar, SetExpr, SetVar, or SetConst) – Tuple of index sets.
- Returns:
The product.
- Return type:
- Raises:
OverflowError – If a negative integer is in
indices
.
Examples
>>> import didppy as dp >>> model = dp.Model() >>> obj = model.add_object_type(number=2) >>> table = model.add_int_table({(0, 0, 0, 0): -1, (1, 1, 1, 1): 3}, default=2) >>> var = model.add_set_var(object_type=obj, target=[0, 1]) >>> set_var = model.add_set_var(object_type=obj, target=[0, 1]) >>> table.product((0, var, set_var, 0)).eval(model.target_state, model) 4