Pyomo / pyomo

An object-oriented algebraic modeling language in Python for structured optimization problems.
https://www.pyomo.org
Other
1.9k stars 490 forks source link

Constraint: only store the original expression (not lower/body/upper) #3293

Open jsiirola opened 2 weeks ago

jsiirola commented 2 weeks ago

Fixes # .

Summary/Motivation:

This PR changes the internal data store for Constraint to only store the original (relational) expression and not break it apart into (lower, body, and upper). Those attributes are preserved as properties (and the expression rearrangement happens dynamically when they are called). Most clients who need the expression "standardized" should use the new normalize_constraint() method (which is more efficient, as it avoids duplicate work and unnecessary calls to as_numeric()).

While this would appear to be strictly cosmetic, this change is the first part of the templatized LP writer.

Changes proposed in this PR:

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.