didppy.FloatTable2D

class didppy.FloatTable2D

2-dimensional table of continuous constants.

t[x, y] returns a continuous expression referring to an item where t is FloatTable2D and x and y are ElementExpr, ElementVar, ElementResourceVar, or int. If x and/or y are/is SetExpr, SetVar, or SetConst, t[x, y] returns the sum of constants over x and y.

Examples

>>> import didppy as dp
>>> model = dp.Model()
>>> obj = model.add_object_type(number=2)
>>> table = model.add_float_table([[2.5, 3.5], [-1.5, 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[var, set_var].eval(model.target_state, model)
1.0

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:
Returns:

The maximum.

Return type:

FloatExpr

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.5, 3.5], [-1.5, 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.max(var, set_var).eval(model.target_state, model)
2.5
min(x, y)

Takes the minimum of constants in a table over the set of indices.

Parameters:
Returns:

The minimum.

Return type:

FloatExpr

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.5, 3.5], [-1.5, 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.min(var, set_var).eval(model.target_state, model)
-1.5
product(x, y)

Takes the product of constants in a table over the set of indices.

Parameters:
Returns:

The product.

Return type:

FloatExpr

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.5, 3.5], [-1.5, 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.product(var, set_var).eval(model.target_state, model)
-3.75