Skip to content

Commit

Permalink
reversed the sorting to have a consistent key ordering and added a co…
Browse files Browse the repository at this point in the history
…mment
  • Loading branch information
carldlaird committed Jun 15, 2020
1 parent eb39d4c commit d2c560e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pyomo/repn/standard_repn.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,11 @@ def _collect_pow(exp, multiplier, idMap, compute_values, verbose, quadratic):
or res.constant != 0)
if has_constant:
ans.constant = multiplier*res.constant*res.constant
keys = sorted(res.linear.keys())

# this is reversed since we want to pop off the end for efficiency
# and the quadratic terms have a convention that the indexing tuple
# of key1, key2 is such that key1 <= key2
keys = sorted(res.linear.keys(), reverse=True)
while len(keys) > 0:
key1 = keys.pop()
coef1 = res.linear[key1]
Expand Down

0 comments on commit d2c560e

Please sign in to comment.