We don't update rule when we change domain on IndexedVar
emma58 opened this issue · 0 comments
emma58 commented
Summary
When I change the domain of an IndexedVar
, it changes all the existing VarDatas, but when I add a new one, it has the old domain.
Steps to reproduce the issue
from pyomo.environ import *
m = ConcreteModel()
m.x = Var(Any, domain=NonNegativeIntegers, dense=False)
m.x[1]
m.x[2]
# This is fine:
m.pprint()
# Never mind!
m.x.domain= NonNegativeReals
# Fine
m.pprint()
m.x[3]
# Whoops, we didn't update the rule!
m.pprint()
Gives this output:
1 Var Declarations
x : Size=2, Index=Any
Key : Lower : Value : Upper : Fixed : Stale : Domain
1 : 0 : None : None : False : True : NonNegativeIntegers
2 : 0 : None : None : False : True : NonNegativeIntegers
1 Declarations: x
1 Var Declarations
x : Size=2, Index=Any
Key : Lower : Value : Upper : Fixed : Stale : Domain
1 : 0 : None : None : False : True : NonNegativeReals
2 : 0 : None : None : False : True : NonNegativeReals
1 Declarations: x
1 Var Declarations
x : Size=3, Index=Any
Key : Lower : Value : Upper : Fixed : Stale : Domain
1 : 0 : None : None : False : True : NonNegativeReals
2 : 0 : None : None : False : True : NonNegativeReals
3 : 0 : None : None : False : True : NonNegativeIntegers
1 Declarations: x
Information on your system
Pyomo version: main
Python version: 3.11
Operating system: linux
How Pyomo was installed (PyPI, conda, source): source
Solver (if applicable):