Skip to content

test: cover peak shaping strategies with data driven cases#101

Open
andig wants to merge 3 commits into
mainfrom
test/peak-shaping-cases
Open

test: cover peak shaping strategies with data driven cases#101
andig wants to merge 3 commits into
mainfrom
test/peak-shaping-cases

Conversation

@andig

@andig andig commented Jul 24, 2026

Copy link
Copy Markdown
Member

Fix #100, depends on #102

Follows up on #96 (comment): the peak shaping coverage lives in the existing data driven harness instead of a feature specific test module.

  • three test cases, one per strategy: attenuate_demand_peaks levels grid import, attenuate_feedin_peaks moves charging into the solar hump, attenuate_grid_peaks does both
  • a test case may now set "strict": true, which compares grid import, grid export, and the battery schedules with numpy.allclose on top of status and objective value
  • strict is needed here because peak shaping only decides between cost neutral schedules. Without it the three cases pass unchanged when peak shaping is removed, the objective value differs only in the eighth digit
  • existing cases stay non strict, several of them have equally optimal alternatives whose schedule comparison would be arbitrary
  • testbench.py update keeps the strict flag when it refreshes a case

🤖 Generated with Claude Code

Peak shaping only picks between cost neutral schedules, so the objective
value moves by less than the comparison tolerance. Strict cases compare
the resulting schedule instead.
@andig

andig commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

@ekkea hope this is a better direction

The three strategy cases pin the absolute peak, but not the shape of the
profile underneath it. Cover that separately: the surplus of the first step is
far beyond c_max, so the export peak is pinned there and the remaining 170 Wh
can be charged anywhere in the following steps without touching it. A
schedule that only caps the peak therefore has a free choice, and the strict
comparison pins the leveled one.

Requires #102: without the ramp
penalty the optimizer returns grid_export [950, 50, 50, 50, 80] instead of
[950, 57.5, 57.5, 57.5, 57.5].

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
andig added a commit that referenced this pull request Jul 24, 2026
The coverage moves to test_cases/026-attenuate-feedin-peaks-below-cap.json on
#101, where the peak shaping cases and
the strict schedule comparison live.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@andig

andig commented Jul 24, 2026

Copy link
Copy Markdown
Member Author

Added test_cases/026-attenuate-feedin-peaks-below-cap.json.

The three strategy cases pin the absolute peak; this one pins the shape of the profile below the peak. The surplus of the first step is far beyond c_max, so the export peak is fixed there and the remaining 170 Wh can be charged anywhere in the following steps without changing it — a schedule that only caps the peak has a free choice there, and the strict comparison pins the leveled one.

It fails on current main and needs #102:

  • without the ramp penalty: grid_export [950, 50, 50, 50, 80]
  • with it: grid_export [950, 57.5, 57.5, 57.5, 57.5]

🤖 Generated with Claude Code

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.

Add peak shaving test cases

1 participant