E2001: Variable domains must be an instance of a Pyomo Set
Variable domains are always Pyomo Set
or RangeSet
objects. This includes global sets like Reals
, Integers
,
Binary
, NonNegativeReals
, etc., as well as model-specific
Set
instances. The Var.domain
setter will attempt to
convert assigned values to a Pyomo Set, with any failures leading to
this warning (and an exception from the converter):
>>> m = pyo.ConcreteModel()
>>> m.x = pyo.Var()
>>> m.x.domain = 5
Traceback (most recent call last):
...
TypeError: Cannot create a Set from data that does not support __contains__...
ERROR (E2001): 5 is not a valid domain. Variable domains must be an instance
of a Pyomo Set or convertible to a Pyomo Set.
See also https://pyomo.readthedocs.io/en/stable/errors.html#e2001