Add Paper Problem 2 OCP benchmark#34
Conversation
bernalde
left a comment
There was a problem hiding this comment.
Review summary:
Blocking issues:
- The new Problem 2 paper OCP helpers are not exposed through the package-level
lyopronto.pyomo_modelsAPI, while the existing Problem 1 helpers are. This makes the new solver harder to discover and breaks the established import pattern.
Nonblocking issues:
_initialize_problem1_model()has a duplicate assignment.lyopronto/pyomo_models/README.mdshould be updated to match the new Problem 2 support documented indocs/PAPER_OCP_VALIDATION.md.
Questions:
- None.
Tests run and outcomes:
python - <<'PY' ... from lyopronto.pyomo_models import solve_paper_problem2 ... PYfailed withImportError, confirming the package-level API gap.pytest tests/test_pyomo_models/test_init.py tests/test_pyomo_models/test_paper_ocp.py -m "not slow" -q: 21 passed.pytest tests/test_pyomo_models/test_paper_ocp.py::test_problem2_coarse_solve_reaches_terminal_target_and_classifies_policy -q: 1 passed.PYTHONPATH=. pytest tests/ -n auto -v -m "not notebook and not pyomo" --ignore=tests/test_pyomo_models: 261 passed.python -m ruff check lyopronto/pyomo_models/paper_ocp.py tests/test_pyomo_models/test_paper_ocp.py: passed.python -m ruff format --check lyopronto/pyomo_models/paper_ocp.py tests/test_pyomo_models/test_paper_ocp.py: passed.
I would not merge this until the blocking issue above is addressed.
Note: I attempted to submit this as REQUEST_CHANGES, but GitHub rejected it because the authenticated account owns this PR (Review Can not request changes on your own pull request). Submitting as COMMENT instead with the blocking issue preserved.
| ) | ||
|
|
||
|
|
||
| def solve_paper_problem2( |
There was a problem hiding this comment.
Blocking: This adds solve_paper_problem2(), but the package-level API in lyopronto/pyomo_models/__init__.py still only imports and exposes the Problem 1 paper helpers. That makes from lyopronto.pyomo_models import solve_paper_problem2 fail while the equivalent Problem 1 import works, and tests/test_pyomo_models/test_init.py does not catch the missing export. Please add the Problem 2 helpers (create_paper_problem2_model, generate_problem2_policy_initialization, and solve_paper_problem2) to the conditional imports and __all__, and extend the init test to cover them.
There was a problem hiding this comment.
Addressed in 1788e7f. lyopronto.pyomo_models now exports the Problem 2 helpers, and tests/test_pyomo_models/test_init.py verifies both __all__ membership and actual attributes.
| discretization = model._paper_discretization | ||
| derived = model._paper_derived | ||
| settings = model._paper_problem_settings | ||
| settings = model._paper_problem_settings |
There was a problem hiding this comment.
Nonblocking: This assignment duplicates the line immediately above it. It is harmless, but removing the extra line keeps this initializer easier to scan.
There was a problem hiding this comment.
Addressed in 1788e7f. Removed the duplicate _paper_problem_settings assignment from _initialize_problem1_model().
| MATLAB. GEKKO is available in the repo-local Pixi environment for upstream | ||
| policy-segment verification. | ||
|
|
||
| Problem 2 is now available as a second paper-reference OCP: |
There was a problem hiding this comment.
Nonblocking: Since this doc now says Problem 2 is available, the package README should be kept in sync. lyopronto/pyomo_models/README.md still lists only the Problem 1 paper OCP functions and describes classify_paper_policies() as inferring Policy 1/Policy 2 regions. Please update that section to mention the Problem 2 model, initializer, solver, and Policy 3 support.
There was a problem hiding this comment.
Addressed in 1788e7f. Updated lyopronto/pyomo_models/README.md to list the Problem 2 model, initializer, solver, and Policy 3 classification support.
|
Pushed commit:
Main changes:
Tests run:
Comments intentionally not addressed:
Remaining risks or follow-up items:
|
Summary
T <= 240 K,dS/dt <= 2.8e-7 m/s, and228 K <= Tb <= 260 K.Tests run
pytest tests/test_pyomo_models/test_paper_ocp.py -m "not slow" -q-> 16 passed in 4.39s.pytest tests/test_pyomo_models/test_paper_ocp.py::test_problem2_coarse_solve_reaches_terminal_target_and_classifies_policy -q-> 1 passed in 4.45s.python -m ruff check lyopronto/pyomo_models/paper_ocp.py tests/test_pyomo_models/test_paper_ocp.py-> all checks passed.python -m ruff format --check lyopronto/pyomo_models/paper_ocp.py tests/test_pyomo_models/test_paper_ocp.py-> 2 files already formatted.PYTHONPATH=. pytest tests/ -n auto -v -m "not notebook and not pyomo" --ignore=tests/test_pyomo_models-> 261 passed in 371.19s.Notes
PYTHONPATH=.failed because local xdist workers could not import top-levelbenchmarksand namespaceexamples; direct Python imports from the repo root worked, and the same suite passed withPYTHONPATH=..Closes #29