didppy.FloatTable
- class didppy.FloatTable
Table of continuous constants.
t[index]returns a continuous expression referring to an item wheretisFloatTableandindexis a sequence ofElementExpr,ElementVar,ElementResourceVar, orint. If one ofindexisSetExpr,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_float_table({(0, 0, 0, 0): -1.5, (1, 1, 1, 1): 3.5}, default=2.5) >>> 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) 5.0
Methods
max(index)Takes the maximum of constants in a table over the set of indices.
min(index)Takes the minimum of constants in a table over the set of indices.
product(index)Takes the product of constants in a table over the set of indices.
- max(index)
Takes the maximum of constants in a table over the set of indices.
- Parameters:
index (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
index.
Examples
>>> import didppy as dp >>> model = dp.Model() >>> obj = model.add_object_type(number=2) >>> table = model.add_float_table({(0, 0, 0, 0): -1.5, (1, 1, 1, 1): 3.5}, default=2.5) >>> var = model.add_set_var(object_type=obj, target=[0, 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.5
- min(index)
Takes the minimum of constants in a table over the set of indices.
- Parameters:
index (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
index.
Examples
>>> import didppy as dp >>> model = dp.Model() >>> obj = model.add_object_type(number=2) >>> table = model.add_float_table({(0, 0, 0, 0): -1.5, (1, 1, 1, 1): 3.5}, default=2.5) >>> var = model.add_set_var(object_type=obj, target=[0, 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.5
- product(index)
Takes the product of constants in a table over the set of indices.
- Parameters:
index (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
index.
Examples
>>> import didppy as dp >>> model = dp.Model() >>> obj = model.add_object_type(number=2) >>> table = model.add_float_table({(0, 0, 0, 0): -1.5, (1, 1, 1, 1): 3.5}, default=2.5) >>> 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) 6.25