Description
While rethinking the design of COEK expressions, I've realized that we can probably accelerate the generation of canonical representations in Pyomo.
Currently, the _collect* functions used in pyomo/repn/standard_repn.py return a "Results" object. (Actually, there are several, in an attempt to minimize the creation of unused data.)
The 'ast' branch of COEK uses a similar walker strategy, but the visit(*) functions accept a Results object, and the semantics are that the visiting function "adds" terms to the Results object.
This has two positive effects:
- Fewer Results objects are created overall
- We avoid walking through Results objects and adding their terms to the parent Results object
WRT (2), I think that Pyomo exhibits quadratic behavior when processing an expression like:
a - (b - (c - (d - (e ... - z) ... )))
What happens, is that the RHS objects are created, passed back, and then pulled into the Results object in the parent calling function. The proposed new logic avoids this.