pyomo icon indicating copy to clipboard operation
pyomo copied to clipboard

Recursion error generating standard_repn on large linear expressions

Open whart222 opened this issue 6 years ago • 3 comments

The following code generates a large, imbalanced expression tree in Pyomo:

def o_rule(model):
    e = 0
    for i in range(N):
        e = model.v[i]*model.x[i] - e
    return e
model.o = Objective(rule=o_rule)

When Pyomo tries to generate the canonical representation of this model, Python throws a recursion error.

whart222 avatar Dec 07 '19 20:12 whart222

How large does N need to be?

qtothec avatar Dec 08 '19 17:12 qtothec

I had problems with N=50000

whart222 avatar Dec 08 '19 17:12 whart222

BWOM: We looked at this issue during the dev call on 2/25/2025 and we should be able to resolve this by replacing standard_repn with the new quadratic_repn. Still need to double check if parameterized_quadratic_repn fully supports the "compute_value" functionality in standard_repn. (See: https://github.com/Pyomo/pyomo/blob/main/pyomo/repn/parameterized_quadratic.py)

blnicho avatar Feb 25 '25 20:02 blnicho