didppy.FloatTable

class didppy.FloatTable

Table of continuous constants.

t[index] returns a continuous expression referring to an item where t is FloatTable and index is a sequence of ElementExpr, ElementVar, ElementResourceVar, or int. If one of index is SetExpr, SetVar, or SetConst, 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:

FloatExpr

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:

FloatExpr

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:

FloatExpr

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