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

Cannot initialize Suffix component with scalar value #3323

Open
anamaria105 opened this issue Jul 16, 2024 · 0 comments
Open

Cannot initialize Suffix component with scalar value #3323

anamaria105 opened this issue Jul 16, 2024 · 0 comments
Labels

Comments

@anamaria105
Copy link

Summary

I ran an old pyomo model from gdplib that failed to run because of an error when running the Suffix command. It took issue with the line m.bigM = Suffix(direction=Suffix.LOCAL, initialize = 7000), but ran when this was changed to

m.bigM = Suffix(direction=Suffix.LOCAL)
m.bigM[None] = 7000

Steps to reproduce the issue

>>> from pyomo.environ import *
>>> m = ConcreteModel()
>>> m.bigM = Suffix(direction=Suffix.LOCAL, initialize = 1000)
...

Error Message

ERROR: Constructing component 'bigM' from data=None failed:
        TypeError: 'int' object is not iterable
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\anapere\src\pyomo\build\__editable__.Pyomo-6.7.4.dev0-py2.py3-none-any\pyomo\core\base\block.py", line 571, in __setattr__
    self.add_component(name, val)
  File "C:\Users\anapere\src\pyomo\build\__editable__.Pyomo-6.7.4.dev0-py2.py3-none-any\pyomo\core\base\block.py", line 1116, in add_component
    val.construct(data)
  File "C:\Users\anapere\src\pyomo\build\__editable__.Pyomo-6.7.4.dev0-py2.py3-none-any\pyomo\core\base\disable_methods.py", line 124, in construct
    return base.construct(self, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\anapere\src\pyomo\build\__editable__.Pyomo-6.7.4.dev0-py2.py3-none-any\pyomo\core\base\suffix.py", line 244, in construct
    self.update_values(rule(self.parent_block(), None), expand=True)
  File "C:\Users\anapere\src\pyomo\build\__editable__.Pyomo-6.7.4.dev0-py2.py3-none-any\pyomo\core\base\suffix.py", line 295, in update_values
    for component, value in items:
TypeError: 'int' object is not iterable

Information on your system

Pyomo version: 6.7.3
Python version: 3.12
Operating system: Windows
How Pyomo was installed (PyPI, conda, source): Source, dev version
Solver (if applicable):

Additional information

This issue doesn't exist when using Pyomo version 6.7.0, so @emma58 suspects there was backwards compatibility that was lost in the following PR: https://github.com/Pyomo/pyomo/pull/3072/commits

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

No branches or pull requests

1 participant