Summary
Follow-up from #276 (see design doc docs/superpowers/specs/2026-07-12-dp-continuous-action-reformulation-design.md,
PR #281). That investigation empirically confirmed the DP's per-period
reward+continuation objective is piecewise-linear in the continuous power
action, and recommended trying the smaller "Approach 1" fix before
committing to the larger exact-piecewise-linear-V redesign (Approach 2).
What to implement
In _best_action_at_continuous_state (core/bess/dp_battery_algorithm.py),
replace the per-period grid search over power_levels with breakpoint
enumeration:
- Discharge: since the objective is piecewise-linear, its optimum
always lands on a breakpoint or a domain boundary. Evaluate the
candidate set: physical discharge power bounds, the
BATTERY_EXPORT_THRESHOLD_KWH crossing (a real jump discontinuity —
must be modeled explicitly, not smoothed over), and V_next's existing
grid breakpoints (reachable via _interpolate_value's known grid
spacing) — instead of ~30 discharge power levels.
- Charge (STORE): no search needed at all. The design doc's Finding 4
showed the actual energy stored during any power > POWER_TOLERANCE_KW
depends only on max_charge_power_kw, solar surplus, and available
room — not on the chosen power value. Evaluate one STORE action
instead of ~30 identical-reward grid points.
- IDLE remains a single evaluated action, as today.
This should be both more accurate (closes most of #275's residual
interpolation-error gap, per the design doc's measured 0.03–0.10 SEK
single-period gaps) and cheaper (fewer candidate points evaluated per
cell than today's ~61-level grid), unlike Option B's tradeoff (finer grid
= more expensive).
Validation required before merge
Out of scope
References
Summary
Follow-up from #276 (see design doc
docs/superpowers/specs/2026-07-12-dp-continuous-action-reformulation-design.md,PR #281). That investigation empirically confirmed the DP's per-period
reward+continuation objective is piecewise-linear in the continuous power
action, and recommended trying the smaller "Approach 1" fix before
committing to the larger exact-piecewise-linear-
Vredesign (Approach 2).What to implement
In
_best_action_at_continuous_state(core/bess/dp_battery_algorithm.py),replace the per-period grid search over
power_levelswith breakpointenumeration:
always lands on a breakpoint or a domain boundary. Evaluate the
candidate set: physical discharge power bounds, the
BATTERY_EXPORT_THRESHOLD_KWHcrossing (a real jump discontinuity —must be modeled explicitly, not smoothed over), and
V_next's existinggrid breakpoints (reachable via
_interpolate_value's known gridspacing) — instead of ~30 discharge power levels.
showed the actual energy stored during any
power > POWER_TOLERANCE_KWdepends only on
max_charge_power_kw, solar surplus, and availableroom — not on the chosen
powervalue. Evaluate one STORE actioninstead of ~30 identical-reward grid points.
This should be both more accurate (closes most of #275's residual
interpolation-error gap, per the design doc's measured 0.03–0.10 SEK
single-period gaps) and cheaper (fewer candidate points evaluated per
cell than today's ~61-level grid), unlike Option B's tradeoff (finer grid
= more expensive).
Validation required before merge
confirm the residual gap shrinks further.
test_scenarios.py) — direction-check everyre-pinned value before accepting, per the standing 2026-07-06 convention
(don't blindly accept fixture changes).
test_plan_faithfulness.py— confirm no R≠P regressions, matching thediscipline that caught real hardware-rate/threshold collisions during
Option B's validation.
Out of scope
Vpropagation via backwardrecursion) — only pursue if this doesn't close the gap enough; tracked
back in Investigate continuous-action/exact-piecewise-linear reformulation of the DP to eliminate discretization interpolation error #276 if still needed.
References
docs/superpowers/specs/2026-07-12-dp-continuous-action-reformulation-design.md— empirical findings and recommendation (PR docs: investigate continuous-action DP reformulation (#276) #281)