Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,29 @@ Notebook cells produce:
- Scatter plots and histograms
- Summary interpretation

### Debug One Case
Use `run_single_case.py` to reproduce one SciPy baseline and one Pyomo run
without writing JSONL or figure artifacts:

```bash
python benchmarks/run_single_case.py \
--task both --scenario baseline \
--set product.A1=20 \
--set ht.KC=4e-4 \
--method fd \
--n-elements 24 \
--tsh-ramp 40 \
--pch-ramp 0.05 \
--tee
```

The runner prints compact SciPy and Pyomo summaries with objective time, solver
status, termination condition, trajectory size, and validation metrics.

## Core Modules

- **`grid_cli.py`** — CLI for N-dimensional grid generation (replaces legacy `run_grid*.py`)
- **`run_single_case.py`** — CLI for one-case SciPy/Pyomo debug runs without generated artifacts
- **`adapters.py`** — Normalized scipy/Pyomo runners with discretization metadata
- **`scenarios.py`** — Scenario definitions (vial, product, ht, eq_cap, nVial)
- **`schema.py`** — Versioned record serialization (v2: trajectories + hashing)
Expand Down
16 changes: 7 additions & 9 deletions benchmarks/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
from typing import Any

import numpy as np
from lyopronto import opt_Pch, opt_Pch_Tsh, opt_Tsh

from benchmarks.validate import compare_trajectories
from lyopronto import opt_Pch, opt_Pch_Tsh, opt_Tsh

DRYNESS_TARGET = 98.9 # Percentage (0-100)
ACCEPTABLE_PYOMO_TERMINATIONS = {"optimal", "locallyoptimal"}
Expand Down Expand Up @@ -245,15 +244,11 @@ def ipopt_replay_adapter(
"residual_tol": residual_tol,
"max_constraint_residual": meta.get("max_constraint_residual"),
"residuals": meta.get("residuals"),
"max_scipy_trajectory_residual": meta.get(
"max_scipy_trajectory_residual"
),
"max_scipy_trajectory_residual": meta.get("max_scipy_trajectory_residual"),
"scipy_trajectory_residuals": meta.get("scipy_trajectory_residuals"),
"max_scipy_mesh_residual": meta.get("max_scipy_mesh_residual"),
"scipy_mesh_residuals": meta.get("scipy_mesh_residuals"),
"max_replay_solution_residual": meta.get(
"max_replay_solution_residual"
),
"max_replay_solution_residual": meta.get("max_replay_solution_residual"),
"replay_solution_residuals": meta.get("replay_solution_residuals"),
"trajectory_comparison": comparison,
},
Expand Down Expand Up @@ -282,6 +277,7 @@ def pyomo_adapter(
use_secant_ramp_constraints: bool = True, # Add secant slope constraints for collocation
solver_cpu_time: float | None = None,
solver_wall_time: float | None = None,
tee: bool = False,
) -> dict[str, Any]:
"""Run Pyomo optimizer counterpart for specified task with discretization controls.

Expand All @@ -301,6 +297,8 @@ def pyomo_adapter(
When using collocation with ramp constraints, add explicit secant slope constraints.
Default True. If False, only polynomial derivative constraints are used, which may
allow numerical derivatives between mesh points to exceed the ramp limit (by ~15%).
tee : bool
Show solver output for interactive debugging.
"""
pyomo_opt = _load_pyomo_optimizers()

Expand Down Expand Up @@ -343,7 +341,7 @@ def pyomo_adapter(
treat_n_elements_as_effective=treat_eff,
warmstart_scipy=warmstart,
return_metadata=True,
tee=False,
tee=tee,
use_secant_ramp_constraints=use_secant_ramp_constraints,
solver_cpu_time=solver_cpu_time,
solver_wall_time=solver_wall_time,
Expand Down
Loading
Loading