Skip to content

Commit

Permalink
Merge branch 'main' into finalize-6.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmundt authored May 30, 2023
2 parents 9e60667 + 28d39dc commit 00d7b32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pyomo/repn/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ def _handle_pow_ANY_constant(visitor, node, arg1, arg2):
visitor, None, ans, (_type, _arg.duplicate())
)
return ans
elif exp == 0:
return _CONSTANT, 1
else:
return _handle_pow_nonlinear(visitor, node, arg1, arg2)

Expand Down
12 changes: 12 additions & 0 deletions pyomo/repn/tests/test_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,18 @@ def test_pow_expr(self):
self.assertEqual(repn.linear, {id(m.x): 1})
self.assertEqual(repn.nonlinear, None)

m.p = 0

cfg = VisitorConfig()
repn = LinearRepnVisitor(*cfg).walk_expression(e)
self.assertEqual(cfg.subexpr, {})
self.assertEqual(cfg.var_map, {id(m.x): m.x})
self.assertEqual(cfg.var_order, {id(m.x): 0})
self.assertEqual(repn.multiplier, 1)
self.assertEqual(repn.constant, 1)
self.assertEqual(repn.linear, {})
self.assertEqual(repn.nonlinear, None)

m.p = 2

cfg = VisitorConfig()
Expand Down

0 comments on commit 00d7b32

Please sign in to comment.