didppy.ElementVar

class didppy.ElementVar

Element variable.

If an arithmetic operator (+, -, *, /, //, %) with an ElementExpr, ElementVar, ElementResourceVar, or int is applied, a new ElementExpr is returned.

If a comparison operator (<, <=, ==, !=, >, >=) with an ElementExpr, ElementVar, ElementResourceVar, or int is applied, a Condition is returned.

Note that didppy.max() and didppy.min() should be used instead of max() and min() as comparison operators are overloaded.

Examples

>>> import didppy as dp
>>> model = dp.Model()
>>> obj = model.add_object_type(number=4)
>>> var = model.add_element_var(object_type=obj, target=3)
>>> state = model.target_state
>>> state[var]
3
>>> (var + 1).eval(state, model)
4
>>> (var - 1).eval(state, model)
2
>>> (var * 2).eval(state, model)
6
>>> (var / 2).eval(state, model)
1
>>> (var // 2).eval(state, model)
1
>>> (var % 2).eval(state, model)
1
>>> (var < 3).eval(state, model)
False
>>> (var <= 3).eval(state, model)
True
>>> (var == 3).eval(state, model)
True
>>> (var != 3).eval(state, model)
False
>>> (var > 3).eval(state, model)
False
>>> (var >= 3).eval(state, model)
True

Methods