Skip to content

[PEP] Revisit design of method used to create the canonical repn #1073

Open
@whart222

Description

@whart222

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:

  1. Fewer Results objects are created overall
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions