Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We don't update rule when we change domain on IndexedVar #3326

Open
emma58 opened this issue Jul 19, 2024 · 0 comments
Open

We don't update rule when we change domain on IndexedVar #3326

emma58 opened this issue Jul 19, 2024 · 0 comments

Comments

@emma58
Copy link
Contributor

emma58 commented Jul 19, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants