Skip to content

PR 5/7: Pyomo optimizer functions#10

Open
bernalde wants to merge 1 commit intopr/pyomo-modelfrom
pr/pyomo-optimizers
Open

PR 5/7: Pyomo optimizer functions#10
bernalde wants to merge 1 commit intopr/pyomo-modelfrom
pr/pyomo-optimizers

Conversation

@bernalde
Copy link
Member

@bernalde bernalde commented Mar 3, 2026

Summary

Top-level API matching scipy optimizer signatures: pyomo_opt_Pch(), pyomo_opt_Tsh(), pyomo_opt_Pch_Tsh(). Accepts the same input dicts as scipy optimizers. Implements staged solving (single-step warmstart → full trajectory), multiple discretization methods, and ramp-rate constraints. Output format matches scipy (7-column numpy array).

PR 5 of 7 in the Pyomo integration series.

Changes

  • lyopronto/pyomo_models/__init__.py — Updated public API exports
  • lyopronto/pyomo_models/optimizers.py — Main optimizer API (2017 lines)
  • tests/test_pyomo_models/test_optimizer_Pch.py — Pressure optimizer tests
  • tests/test_pyomo_models/test_optimizer_Pch_Tsh.py — Joint optimizer tests
  • tests/test_pyomo_models/test_optimizer_Tsh.py — Temperature optimizer tests
  • tests/test_pyomo_models/test_optimizer_framework.py — Framework tests
  • tests/test_pyomo_models/test_parameter_validation.py — Input validation tests
  • tests/test_pyomo_models/test_staged_solve.py — Staged solve tests
  • tests/test_pyomo_models/test_warmstart.py — Warmstart initialization tests

Key Design Decisions

  • Same API surface: Pyomo optimizers accept same input dicts, return same 7-column output as scipy
  • Staged solving: Single-step warmstart → full trajectory for robust convergence
  • Coexistence: Both lyopronto.opt_Pch (scipy) and lyopronto.pyomo_models.optimizers.pyomo_opt_Pch (Pyomo) available

PR Chain

# PR Status
0 Sync upstream (#5) Merged
1 CI/CD for Pyomo (#6) Open
2 Pyomo dependencies (#7) Open
3 Utils & single-step (#8) Open
4 Multi-period model (#9) Open
5 Optimizer functions (this PR)
6 Benchmarks Pending
7 Docs & examples Pending

Testing

~2885 lines of new tests covering all three optimizer modes, framework validation, parameter handling, warmstart, and staged solving.

This PR adds the main Pyomo optimizer functions:

lyopronto/pyomo_models/optimizers.py (2017 lines):
- optimize_Tsh_pyomo(): Optimize shelf temperature trajectory
- optimize_Pch_pyomo(): Optimize chamber pressure trajectory
- optimize_Pch_Tsh_pyomo(): Optimize both pressure and temperature
- Staged solving strategy for robustness
- Warmstart from scipy solutions
- Result formatting compatible with scipy outputs

lyopronto/pyomo_models/__init__.py:
- Export optimize_Tsh_pyomo, optimize_Pch_pyomo, optimize_Pch_Tsh_pyomo
- Import guards for optional Pyomo dependencies

API compatibility:
- Same function signatures as scipy-based opt_*.py modules
- Same output format (numpy array with 7 columns)
- Drop-in replacement for scipy versions

Tests (7 files):
- test_optimizer_Tsh.py: Tsh optimization tests
- test_optimizer_Pch.py: Pch optimization tests
- test_optimizer_Pch_Tsh.py: Combined optimization tests
- test_optimizer_framework.py: Framework tests
- test_warmstart.py: Warmstart functionality
- test_parameter_validation.py: Input validation
- test_staged_solve.py: Staged solving strategy

Usage:
  from lyopronto.pyomo_models import optimize_Tsh_pyomo
  result = optimize_Tsh_pyomo(vial, product, ht, Pchamber, Tshelf, dt, eq_cap, nVial)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant