PR 4/7: Pyomo multi-period DAE model#9
Conversation
fa26a34 to
65fc2c3
Compare
b8a82c3 to
53ad6d9
Compare
53ad6d9 to
389c49e
Compare
389c49e to
518df8b
Compare
3c852b8 to
07c52ee
Compare
518df8b to
c4356ba
Compare
c4356ba to
15eb233
Compare
15eb233 to
38607c8
Compare
4347637 to
bbda9c5
Compare
bernalde
left a comment
There was a problem hiding this comment.
I found several blocking issues in the core model formulation and in the new test coverage. The main concerns are that the product-temperature constraint is applied to the wrong variable/direction, scaled solves return scaled rather than physical units, warmstart initializes dmdt 10x too high, the cake-length ODE does not match the existing scipy drying-rate update, and one new Pyomo test fails when networkx is not installed.
bernalde
left a comment
There was a problem hiding this comment.
Review summary:
- Blocking issues: the default scaled
create_multi_period_model()result does not expose the documented unscaled model attributes and cannot be passed towarmstart_from_scipy_trajectory;dmdt[0]is unconstrained but is returned as part of the solution trajectory. - Nonblocking issues: none.
- Questions: none.
- Tests run and outcomes:
PYTHONPATH=/tmp/LyoPRONTO_pr9 pytest tests/test_pyomo_models -m "pyomo and not slow" -n 0 --tb=short --maxfail=10passed with 67 passed, 9 skipped, 14 deselected;RUN_SLOW_TESTS=1 PYTHONPATH=/tmp/LyoPRONTO_pr9 pytest tests/test_pyomo_models/test_model_multi_period.py::TestModelOptimization::test_optimization_runs tests/test_pyomo_models/test_model_validation.py::TestOptimizationComparison::test_optimization_improves_over_scipy tests/test_pyomo_models/test_model_validation.py::TestOptimizationComparison::test_optimized_solution_satisfies_constraints -n 0 --tb=short --maxfail=3passed with 3 passed;ruff check lyopronto/pyomo_models/model.py tests/test_pyomo_models/test_model_advanced.py tests/test_pyomo_models/test_model_multi_period.py tests/test_pyomo_models/test_model_validation.py tests/test_pyomo_models/test_physics_equations.pypassed;git diff --check origin/pr/pyomo-utils-singlestep...HEADpassed. - Merge as-is: no. I would not merge this until the blocking issues above are addressed.
bernalde
left a comment
There was a problem hiding this comment.
Propagating review feedback from the lower Pyomo PRs where the same issue still applies.
This PR adds the core multi-period Pyomo model: lyopronto/pyomo_models/model.py (640 lines): - Multi-period differential-algebraic equation (DAE) formulation - Orthogonal collocation discretization for time integration - Physics constraints: vapor pressure, sublimation rate, heat transfer - Equipment capability constraints - Product temperature limits - Variable scaling for numerical stability - Support for both Tsh and Pch optimization Key features: - Uses Pyomo DAE transformations from IDAES - Implements same physics as scipy-based calculators - Warmstart from scipy solution for faster convergence - Configurable time discretization (number of periods) Tests (4 files): - test_model_multi_period.py: Multi-period model construction - test_model_advanced.py: Advanced model features - test_model_validation.py: Input validation - test_physics_equations.py: Physics equation verification This is the core model used by the optimizer functions (PR 5).
bernalde
left a comment
There was a problem hiding this comment.
Review summary:
- Blocking issues:
final_drynessstops the optimizer at 95% dried whileoptimize_multi_period()reportst_finalas total drying time. - Nonblocking issues: none.
- Questions: none.
- Tests run and outcomes: targeted non-slow Pyomo suite passed; targeted slow multi-period IPOPT tests passed; CI-style Pyomo marker suite passed; ruff passed; git diff --check passed. The broader non-Pyomo CI command was interrupted after reaching 99% with one xdist worker still running for several minutes and no failures observed before interruption.
- Merge as-is: no. I would not merge this until the blocking issues above are addressed.
GitHub rejected REQUEST_CHANGES because the authenticated account owns this PR, so this review is submitted as COMMENT.
|
|
||
| def final_dryness_rule(m): | ||
| """Ensure drying is complete at final time.""" | ||
| return m.Lck[1] >= 0.95 * Lpr0 # 95% dried |
There was a problem hiding this comment.
Blocking: This terminal constraint lets the optimizer report t_final when the cake is only 95% dry. Since the objective minimizes t_final, the optimum stops at this threshold; with the standard warmstart I get Lck[-1] / Lpr0 = 0.94999999. That underestimates primary drying time compared with the existing calc_knownRp.dry completion event, which targets Lpr0 - L == 0 when the schedule permits. Please either enforce full completion, or add an explicit documented target_dry_fraction parameter that defaults to complete drying, and add a regression that checks the returned final Lck/percent dried reaches that target.
There was a problem hiding this comment.
Addressed in fe5fc82. target_dry_fraction now defaults to 1.0, final_dryness enforces that target, and the optimized-solution validation now checks complete drying by default. Added tests for default, custom, and invalid terminal targets.
|
Commits pushed:
Main changes made:
Tests run and results:
Comments intentionally not addressed:
Remaining risks or follow-up items:
|
Summary
Full trajectory optimization model. Discretizes the drying process into multiple time periods, encoding the physics (vapor pressure, product resistance, energy balance, mass transfer) as Pyomo constraints. Supports both finite-difference and collocation discretization. Log-transform for vapor pressure to avoid numerical issues with exponentials.
PR 4 of 7 in the Pyomo integration series.
Changes
lyopronto/pyomo_models/model.py— Full multi-period DAE modeltests/test_pyomo_models/test_model_multi_period.py— Multi-period tests (741 lines)tests/test_pyomo_models/test_model_advanced.py— Advanced model teststests/test_pyomo_models/test_model_validation.py— Validation against scipytests/test_pyomo_models/test_physics_equations.py— Physics equation testsKey Physics Encoded as Constraints
PR Chain
Testing
~2075 lines of new tests covering model construction, discretization, physics constraints, and validation against scipy baseline.