Skip to content

Add core symbolic gradient support to Pyomo.DoE#3898

Open
snarasi2 wants to merge 12 commits intoPyomo:mainfrom
snarasi2:codex/merge-pyomo-doe-symbolic
Open

Add core symbolic gradient support to Pyomo.DoE#3898
snarasi2 wants to merge 12 commits intoPyomo:mainfrom
snarasi2:codex/merge-pyomo-doe-symbolic

Conversation

@snarasi2
Copy link
Copy Markdown

@snarasi2 snarasi2 commented Apr 1, 2026

Fixes # .

Summary/Motivation:
This PR ports the core symbolic-gradient functionality from the historical pyomo-doe-symbolic work into the current pyomo.contrib.doe implementation.

Summary/Motivation:

This PR ports the core symbolic-gradient functionality from the historical pyomo-doe-symbolic work into the current pyomo.contrib.doe implementation.

Rather than merging the old branch directly, this change transplants the symbolic DoE pieces onto current main so that symbolic sensitivities work with the newer DoE implementation already present in Pyomo, including the current objective and GreyBox-oriented code paths.

This PR is intentionally scoped to the core symbolic-gradient integration. It does not attempt to port every example, test refactor, or auxiliary change from the historical adowling2/pyomo-doe-symbolic branch in one step.

This contribution was prepared with coding assistance from OpenAI Codex. All design decisions, validation, testing, and quality-assurance responsibility remain with Shilpa Narasimhan.

Local validation included:

  • pyomo/contrib/doe/tests: 133 passed, 4 skipped, 5 warnings, 10 subtests passed
  • pyomo/contrib/doe/tests/test_greybox.py: 33 passed in HSL-enabled local environments

The remaining public-CI GreyBox cyipopt skips are environment-dependent and tied to MA57/HSL runtime availability.

Changes proposed in this PR:

  • add GradientMethod support to DesignOfExperiments
  • preserve the existing finite-difference workflow through the new gradient-method interface
  • add a symbolic / pynumero gradient path for DoE
  • add an analytic FIM computation path for non-optimization FIM evaluation
  • export ExperimentGradients from pyomo.contrib.doe
  • refactor ExperimentGradients so symbolic and automatic differentiation are set up together
  • add supporting symbolic-gradient utilities for labeled experiment models
  • update DoE model construction so symbolic sensitivities can be used in the Jacobian-based DoE machinery
  • add a guard preventing run_doe() from being called with GradientMethod.kaug
  • add the polynomial example and polynomial-focused regression coverage
  • add broader symbolic-versus-automatic gradient consistency tests
  • add factorial-result dataframe tests
  • add reactor regression tests against expected solutions
  • clarify the GreyBox cyipopt test skip reason when the MA57/HSL runtime is unavailable

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.

@adowling2
Copy link
Copy Markdown
Member

This is a port of adowling2#7

Shilpa Narasimhan added 10 commits April 1, 2026 16:30
Add schema, filtering, and error-path tests for factorial-result tables and DataFrame input handling.

Validation:
- 101 passed, 5 warnings, 10 subtests passed in 30.00s

Notes:
- plotting tests emit expected matplotlib warnings under the non-interactive Agg backend because draw_factorial_figure() calls plt.show().
Add a determinant-based reactor regression test, guard Codecov uploads when coverage.xml is absent, and align local formatting with Black expectations.

Validation:
- focused reactor regression subset: 2 passed, 28 deselected in 10.08s
- full DoE suite: 102 passed, 5 warnings, 10 subtests passed in 30.29s

Notes:
- plotting-related tests continue to emit expected matplotlib warnings under the non-interactive Agg backend because draw_factorial_figure() calls plt.show().
Add coverage for draw_factorial_figure guard branches covering more-than-two sensitivity variables and missing fixed design variables.

Validation:
- focused plotting-guard subset: 2 passed, 37 deselected in 1.92s
- full DoE suite: 104 passed, 5 warnings, 10 subtests passed in 31.47s

Notes:
- plotting-related tests continue to emit expected matplotlib warnings under the non-interactive Agg backend because draw_factorial_figure() calls plt.show().
@snarasi2
Copy link
Copy Markdown
Author

snarasi2 commented Apr 2, 2026

Outstanding item from the historical symbolic branch still remain to be completed:

  • updating documentation

Closed out:

  • refactoring ExperimentGradients so symbolic and automatic differentiation are set up together
  • adding tests for the polynomial example
  • checking symbolic and automatic gradient correctness more broadly
  • testing the data frame functions
  • adding reactor regression tests against expected solutions
  • checking code coverage
  • removing diagnostic print statements
  • removing stale or outdated comments
  • running remaining lint and spellcheck steps

@snarasi2
Copy link
Copy Markdown
Author

snarasi2 commented Apr 2, 2026

@sscini @smondal13 @slilonfe5 ready for preliminary review. Could you please take a look when you are free?

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

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants