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

Unexpected failure with set product #358

Closed
qtothec opened this issue Feb 23, 2018 · 0 comments
Closed

Unexpected failure with set product #358

qtothec opened this issue Feb 23, 2018 · 0 comments

Comments

@qtothec
Copy link
Contributor

qtothec commented Feb 23, 2018

The code below is expected to work, but does not. The first m.test = Block statement goes through properly, but an error appears during the m.test2 = Block line.

Related issue: #326
This might be another manifestation of #134

from pyomo.environ import *
m = ConcreteModel()
m.s = RangeSet(1)
m.s2 = RangeSet(1)
m.set_mult = m.s * m.s2
m.s3 = RangeSet(1)

def _test(b, x, y, z):
    print(x, y, z)
m.test = Block(m.set_mult, m.s3, rule=_test)
m.test2 = Block(m.set_mult, m.s3, rule=_test)

Output:

(1, 1, 1)
ERROR: Constructing component 'test2' from data=None failed: TypeError:
    _test() takes exactly 4 arguments (5 given)
Traceback (most recent call last):
  File "set_fail.py", line 11, in <module>
    m.test2 = Block(m.set_mult, m.s3, rule=_test)
  File "/home/qichen/git/pyomo/pyomo/core/base/block.py", line 540, in __setattr__
    self.add_component(name, val)
  File "/home/qichen/git/pyomo/pyomo/core/base/block.py", line 980, in add_component
    val.construct(data)
  File "/home/qichen/git/pyomo/pyomo/core/base/block.py", line 1796, in construct
    self, self._rule, _block, idx, self._options)
  File "/home/qichen/git/pyomo/pyomo/core/base/misc.py", line 80, in apply_indexed_rule
    return rule(model, *index)
TypeError: _test() takes exactly 4 arguments (5 given)

This is using the current master branch commit 7d4eee7.

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