Add experimental LyoPRONTO policy OCP adapter#36
Conversation
bernalde
left a comment
There was a problem hiding this comment.
Blocking issues: active flux/velocity caps can fail through the default SciPy staged warmstart path before the optimized control is released. I attempted to submit this as REQUEST_CHANGES, but GitHub rejects change requests from the PR author's own account. Nonblocking issues: none. Questions: none. Tests run: python -m ruff check lyopronto/pyomo_models/policy_ocp.py lyopronto/pyomo_models/__init__.py tests/test_pyomo_models/test_policy_ocp.py tests/test_pyomo_models/test_init.py passed; python -m ruff format --check lyopronto/pyomo_models/policy_ocp.py lyopronto/pyomo_models/__init__.py tests/test_pyomo_models/test_policy_ocp.py tests/test_pyomo_models/test_init.py passed; python -m pytest tests/test_pyomo_models/test_policy_ocp.py tests/test_pyomo_models/test_init.py -n 0 passed with 8 tests; no-cap smoke solve with solve_lyopronto_policy_ocp(..., n_elements=4, warmstart_scipy=True) reached optimal termination; active flux-cap smoke solve with default warmstart failed in Stage 1 as described inline; the same active cap with warmstart_scipy=False solved and classified Policy 3; python -m pytest tests/ -m "not notebook and not pyomo" --ignore=tests/test_pyomo_models -n auto passed with 262 tests. I would not merge this until the blocking issue is addressed.
| use_secant_ramp_constraints=use_secant_ramp_constraints, | ||
| ) | ||
|
|
||
| if warmstart_scipy: |
There was a problem hiding this comment.
Blocking: With the default warmstart_scipy=True, an active flux or interface-velocity cap can make the staged solve fail before the optimized shelf control is ever released. Stage 1 fixes Tsh and t_final to the uncapped SciPy warmstart while the new cap constraints are already active, so a valid capped OCP becomes infeasible if the warmstart trajectory violates the cap. I reproduced this with the standard fixture inputs, n_elements=4, and a flux cap set below the uncapped max flux: the default path failed in Stage 1, while the same capped problem solved with warmstart_scipy=False and classified Policy 3. Since this new public solve API defaults to the failing path, please make capped solves use a cap-aware initialization/staged sequence, skip the fixed-control staged solve when caps are present, or temporarily relax/deactivate cap constraints until controls are released. Add a regression smoke test that solves an active cap case through the default API.
There was a problem hiding this comment.
Addressed in 6690b29. Capped solves now skip the fixed-control staged solve while preserving SciPy initialization, and tests/test_pyomo_models/test_policy_ocp.py::test_policy_ocp_default_warmstart_solves_active_flux_cap covers the default active flux-cap path.
|
Pushed commit Main changes:
Tests run:
Comments intentionally not addressed:
Remaining risks or follow-up:
|
Summary
lyopronto.pyomo_models.policy_ocpadapter that reuses the existing quasi-steady Pyomo optimizer model in LyoPRONTO units.kg/hr/m^2) and interface velocity (cm/hr), plus paper-style rich result extraction and active policy classification.Tests run
python -m ruff check lyopronto/pyomo_models/policy_ocp.py lyopronto/pyomo_models/__init__.py tests/test_pyomo_models/test_policy_ocp.py tests/test_pyomo_models/test_init.py-> passedpython -m ruff format --check lyopronto/pyomo_models/policy_ocp.py lyopronto/pyomo_models/__init__.py tests/test_pyomo_models/test_policy_ocp.py tests/test_pyomo_models/test_init.py-> passedpytest tests/test_pyomo_models/test_policy_ocp.py tests/test_pyomo_models/test_init.py -n 0-> 8 passedpython -m pytest tests/test_benchmarks.py tests/test_opt_Tsh.py::TestOptTsh::test_optimizer_example_script_runs -n 0-> 19 passedpython -m pytest tests/ -m "not notebook and not pyomo" --ignore=tests/test_pyomo_models -n auto-> 262 passedNotes
pytest tests/ -m "not notebook and not pyomo" --ignore=tests/test_pyomo_models -n autoreached 243 passes but failed on local import-path errors forbenchmarksandexamples; the focused rerun and full broader rerun both passed throughpython -m pytest.Closes #31