DiscreteVariable.asRangeVar

DiscreteVariable.asRangeVar()

Returns a copy of the variable as a pyagrum.RangeVariable.

No conversion is done: the variable must already be a pyagrum.RangeVariable. Changing the copy does not change the original variable.

Returns:

a copy of the variable

Return type:

pyagrum.RangeVariable

Raises:

pyagrum.OperationNotAllowed – if the variable is not a pyagrum.RangeVariable

Example

import pyagrum as gum

v = gum.fastVariable("r[1,4]")
r = v.asRangeVar()  # a RangeVariable (a copy of v)
r.setMaxVal(6)
print(r)
# r:Range([1,6])

Used by

DiscreteVariable, DiscretizedVariable, IntegerVariable, LabelizedVariable, NumericalDiscreteVariable, RangeVariable

Inheritance diagram of pyagrum.DiscreteVariable, pyagrum.DiscretizedVariable, pyagrum.IntegerVariable, pyagrum.LabelizedVariable, pyagrum.NumericalDiscreteVariable, pyagrum.RangeVariable