Repository navigation
perf(optimizer): use direct HiGHS for shared storage - #883
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19825e40fa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| started, | ||
| prepare_ms, | ||
| "shared", | ||
| shared=True, |
There was a problem hiding this comment.
Model post-curtailment baseline flows on the shared path
For self_consumption requests where shared curtailment turns a low-PV scenario from export into import, shared=True reuses direct_highs.py's fixed pre-curtailment base_import = max(load - PV, 0) bound. The CVXPY shared model instead derives its auxiliary baseline flow after curtailment (model.py:753-766), so a feasible request—such as widely separated downside/upside PV scenarios behind an export cap—can return kInfeasible here while solving with CVXPY. Auto mode therefore incurs a failed solve before falling back, and shared_backend=highs fails outright; model the post-curtailment baseline flow equivalently or exclude these modes from direct eligibility.
Useful? React with 👍 / 👎.
Summary
Measured result
Local Apple M5 arm64 benchmark, 192 15-minute slots, one warm-up and five measured solves:
These timings measure the convex fast path. The exact mixed-integer retry is a correctness path and was not used by these fixtures.
On those fixtures, the objective deltas were 0.000000049 and 0.000000115 ore. The largest battery-action deltas were 0.00000322 W and 0.00000886 W.
A seeded 80-case parity sweep also passed. Its largest objective delta was 0.0662 ore and its largest battery-action delta was 0.339 W, both within the existing solver tolerances.
Two added seeded suites covered 270 feasible cases with 852 scenario-slot import/export crossings. All returned valid highspy plans; 32 naturally used the exact mixed-integer retry. No meter-flow rule, storage replay or objective check failed. Tests allow different battery and curtailment choices when both have the same cost and meet the same rules.
Safety and scope
Auto mode uses the direct path only for continuous, cycle-safe HIGHS requests with storage alone. Commercial constraints, flexible loads, thermal loads, guarded tariffs, CLARABEL, forced MILP, and out-of-bound initial storage stay on CVXPY. Ordinary direct-path errors fall back to the unchanged CVXPY model and report the reason.
The wire schema, protocol version and plan response stay unchanged. Eligible default shared plans now report
highspyas the engine. A post-curtailment direction crossing may reportmilpas the formulation when the exact retry is needed. CVXPY remains installed and available as the fallback.Checks
make verify-allLimits