Skip to content

Initialize mutable Params after DAE discretization - #4030

Open
mameikagou wants to merge 2 commits into
Pyomo:mainfrom
mameikagou:fix/dae-param-discretization
Open

mameikagou wants to merge 2 commits into
Pyomo:mainfrom
mameikagou:fix/dae-param-discretization

Conversation

@mameikagou

Copy link
Copy Markdown

Fixes #4009.

Summary/Motivation:

DAE discretization adds points to a ContinuousSet after indexed Param components are constructed. Mutable Params with an explicit initializer therefore contain uninitialized ParamData at those new points.

Changes proposed in this PR:

  • Initialize newly added indices of mutable Params from their existing initializer during DAE component expansion.
  • Preserve lazy defaults, existing values, and immutable Param behavior.
  • Add finite-difference and collocation regression coverage for scalar and indexed initializers.

AI-Use Disclosure

  • AI tools were NOT used during the preparation of this PR

or

  • AI tools contributed to the development of this PR

    • AI tools generated documentation (including the PR description/comments, code comments, and/or Sphinx documentation)
    • AI tools generated tests (baselines, examples, and/or code)
    • AI tools generated code (apart from tests)

    Review process (select ONE):

    • Rewritten: All AI-generated content was rewritten by me before being committed.
    • Reviewed/verified: I retained AI-generated content and verified it before committing. Verification included (as applicable):
      • Ran the code and fixed issues
      • Added and ran tests
      • Checked correctness/logic of code and tests
      • Checked for alignment with the contribution guide
      • Considered security implications
    • As-is: AI-generated content was commited directly to the repository

Notes for reviewers (optional): Verified the original reproducer before and after the change. The complete pyomo/dae/tests unittest suite passes: 178 tests, 33 skipped.

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 my contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@blnicho
blnicho self-requested a review September 1, 2026 19:09

@mrmundt mrmundt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With respect to code style and quality, this is great. Pending a review from another dev for mathematical correctness. (Probably @blnicho )

@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.14%. Comparing base (e099f64) to head (2328af6).

Files with missing lines Patch % Lines
pyomo/dae/misc.py 89.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4030      +/-   ##
==========================================
- Coverage   90.14%   90.14%   -0.01%     
==========================================
  Files         917      917              
  Lines      109261   109278      +17     
==========================================
+ Hits        98494    98507      +13     
- Misses      10767    10771       +4     
Flag Coverage Δ
builders 29.11% <5.26%> (-0.01%) ⬇️
default 86.14% <89.47%> (?)
expensive 35.09% <5.26%> (?)
linux 87.68% <89.47%> (-1.98%) ⬇️
linux_other 87.68% <89.47%> (+<0.01%) ⬆️
oldsolvers 28.05% <5.26%> (-0.01%) ⬇️
osx 83.12% <89.47%> (+<0.01%) ⬆️
win 85.43% <89.47%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Params indexed by ContinuousSets are not initialized when the set is discretized.

3 participants