Fix add_tiny_price_slope for flat prices to reliably break ties in LP optimizer#1991
Draft
Copilot wants to merge 2 commits intofeat/multi-commodityfrom
Draft
Fix add_tiny_price_slope for flat prices to reliably break ties in LP optimizer#1991Copilot wants to merge 2 commits intofeat/multi-commodityfrom
add_tiny_price_slope for flat prices to reliably break ties in LP optimizer#1991Copilot wants to merge 2 commits intofeat/multi-commodityfrom
Conversation
7 tasks
…arly-charging assertions Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Address feedback on multi-commodity support in device scheduler PR
Fix Feb 26, 2026
add_tiny_price_slope for flat prices to reliably break ties in LP optimizer
Copilot stopped work on behalf of
Flix6x due to an error
February 26, 2026 12:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With constant energy prices, the tie-breaking slope added by
add_tiny_price_slopewas too small for the LP solver to distinguish early from late charging, causing charging to scatter across time slots instead of front-loading as expected.Root cause
When
price_spread == 0, the fallback penalty was a fixed absolute valuemax_penalty = d = 1e-4(0.0001 EUR/MWh). At 100 EUR/MWh flat prices this creates a total slope of 0.0001 EUR/MWh across the scheduling window — within HiGHS's numerical tolerance, so the solver treated all time slots as equivalent.Fix
Scale the fallback by the actual price level instead of a fixed constant:
This produces a 100× larger slope (0.01 EUR/MWh) for typical energy prices, reliably above LP solver tolerance.
Test assertions added
test_two_flexible_assets_with_commoditynow verifies the expected early-charging behaviour and electricity costs:60/0.95 ≈ 63.16 kWh→ 3 full slots at 20 kW + partial slot, cost ≈ 6.316 EUR30/0.95 ≈ 31.58 kWh→ 3 full slots at 10 kW + partial slot, cost ≈ 3.158 EUR✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.