Skip to content

Centralize processing of monomial terms in LinearRepn compiler#3956

Open
jsiirola wants to merge 4 commits into
Pyomo:mainfrom
jsiirola:repn-common-monomial-recorder
Open

Centralize processing of monomial terms in LinearRepn compiler#3956
jsiirola wants to merge 4 commits into
Pyomo:mainfrom
jsiirola:repn-common-monomial-recorder

Conversation

@jsiirola
Copy link
Copy Markdown
Member

@jsiirola jsiirola commented May 18, 2026

Fixes # .

Summary/Motivation:

This is the first step in reworking the core monomial recording logic in the "new" (LinearRepn / QuadraticRepn) compilers. Having a single method for recording monomial terms into an already-created Repn data structure will make it easier to do custom overloads (e.g., in ParameterizedRepn walkers) and to experiment with different Repn internal data formats. It also removes "in-lined" (copy/pasted) code.

The cost of this is an extra function call when processing terms. This has a measurable, albeit small impact on the LP writer:

image

Changes proposed in this PR:

  • centralize all processing of monomial terms (in the LinearBeforeChildDispatcher) in a record_monomial method
  • update the base LinearBeforeChildDispatcher _before_var, _before_monomial and _before_linear methods.

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.10%. Comparing base (6ffd3cb) to head (2b5b655).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3956   +/-   ##
=======================================
  Coverage   90.10%   90.10%           
=======================================
  Files         908      908           
  Lines      108344   108325   -19     
=======================================
- Hits        97620    97606   -14     
+ Misses      10724    10719    -5     
Flag Coverage Δ
builders 29.13% <44.11%> (+0.01%) ⬆️
default 86.09% <100.00%> (?)
expensive 35.14% <64.70%> (?)
linux 87.61% <100.00%> (-1.99%) ⬇️
linux_other 87.61% <100.00%> (+<0.01%) ⬆️
oldsolvers 28.07% <88.23%> (+<0.01%) ⬆️
osx 83.05% <100.00%> (-0.01%) ⬇️
win 85.36% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants