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
7 changes: 7 additions & 0 deletions .changeset/bundle-energyplan-071.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"ftw": patch
---

Bundle Energyplan 0.7.1. A battery that starts below its lowest allowed
charge, with a car in the plan, now gets its cheap night charge from
Energyplan as well, instead of an idle plan.
2 changes: 1 addition & 1 deletion go/internal/mpc/energyplan_fault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestNativeEnergyplanEVRecoveryFallbackFaults(t *testing.T) {
t.Cleanup(func() { _ = external.Close() })
wrapper := &EnergyplanOptimizer{ExternalOptimizer: external}
health, err := wrapper.Health(context.Background())
if err != nil || health.Version != "0.7.0" {
if err != nil || health.Version != "0.7.1" {
t.Fatalf("bundle health=%+v err=%v", health, err)
}
svc := shadowTestService(t)
Expand Down
2 changes: 1 addition & 1 deletion go/internal/mpc/energyplan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestNativeEnergyplanDownsideAndAsyncShadow(t *testing.T) {
svc := shadowTestService(t)
svc.Optimizer = o
info, err := svc.Optimizer.(*EnergyplanOptimizer).Health(context.Background())
if err != nil || info.Name != "ftw-solver" || info.Version != "0.7.0" {
if err != nil || info.Name != "ftw-solver" || info.Version != "0.7.1" {
t.Fatalf("bundled worker health: %+v %v", info, err)
}
start := time.Now().UTC().Truncate(time.Hour)
Expand Down
78 changes: 78 additions & 0 deletions go/internal/mpc/native_below_floor_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package mpc

import (
"context"
"testing"
"time"
)

// belowFloorNight is the shape of #2043: a 20 kWh battery 60 Wh under its
// floor and a car due by morning, with a cheap night before a dear day.
func belowFloorNight() ([]Slot, Params) {
slots := make([]Slot, 96)
for i := range slots {
load, price := 1500.0, 260.0
switch {
case i < 16:
load, price = 2000, 300
case i < 40:
load, price = 800, 115
}
slots[i] = Slot{StartMs: 1_794_942_000_000 + int64(i)*15*60*1000, LenMin: 15, PriceOre: price, SpotOre: price * .8, LoadW: load}
}
p := Params{
Mode: ModePassiveArbitrage, SoCLevels: 41, ActionLevels: 41,
CapacityWh: 20000, SoCMin: .1, SoCMax: .95, InitialSoC: .097,
MaxChargeW: 10000, MaxDischargeW: 10000, ChargeEfficiency: .95, DischargeEfficiency: .95,
TerminalSoCPrice: 200, MinArbitrageSpreadOreKwh: 60,
Loadpoint: &LoadpointSpec{
ID: "car", CapacityWh: 84000, Levels: 85, SoCMin: 0, SoCMax: 1,
InitialSoC: .34, PluggedIn: true, TargetSoC: .8, TargetSlotIdx: 48,
MinChargeW: 4800, MaxChargeW: 11100, ChargeEfficiency: .9,
AllowedStepsW: []float64{0, 4800, 5500, 6200, 6900, 7600, 8300, 9000, 9700, 10400, 11100},
NoBatteryToEV: true,
Charging: ChargingPeriods{MinChargeSeconds: 300, StartCostOre: 5},
},
}
return slots, p
}

// On a field request Energyplan 0.7.0 kept such a battery idle for the whole
// horizon (#2043). Core now starts it on the floor (#2045), and the worker
// must plan the night charge from either start. This shape passes on 0.7.0
// too under Core's time budget; Energyplan's own suite holds the case that
// failed.
func TestNativeBatteryUnderItsFloorBesideACarChargesAtNight(t *testing.T) {
external := nativeWorker(t, 1500*time.Millisecond)
defer external.Close()
o := &EnergyplanOptimizer{ExternalOptimizer: external}
nightKWh := func(plan Plan) float64 {
var wh float64
for i, a := range plan.Actions {
if i >= 16 && i < 40 && a.BatteryW > 0 {
wh += a.BatteryW * float64(plan.Actions[i].SlotLenMin) / 60
}
}
return wh / 1000
}
for _, onFloor := range []bool{true, false} {
slots, p := belowFloorNight()
if onFloor {
if _, ok := clampParamsIntoOperatingBand(&p); !ok {
t.Fatal("clamp refused")
}
}
plan, err := o.Optimize(context.Background(), slots, p)
if err != nil {
t.Fatalf("on floor %v: %v", onFloor, err)
}
if err := ValidatePlan(slots, p, &plan); err != nil {
t.Fatalf("on floor %v: %v", onFloor, err)
}
night := nightKWh(plan)
t.Logf("on floor %v: %s, %.1f kWh charged at night", onFloor, plan.Solver.Backend, night)
if night < 10 {
t.Errorf("on floor %v: %.1f kWh charged at night, want a night charge", onFloor, night)
}
}
}
Binary file modified optimizer/native/bundle/ftw-solver-linux-amd64
Binary file not shown.
Binary file modified optimizer/native/bundle/ftw-solver-linux-arm64
Binary file not shown.
12 changes: 6 additions & 6 deletions optimizer/native/bundle/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"schema_version": 1,
"product": "energyplan",
"version": "0.7.0",
"version": "0.7.1",
"source_repository": "srcfl/energyplan",
"source_commit": "7ea7d99835a80f6fd56efb14f89a1c206e43016b",
"source_commit": "906cf053f138129eff88f4a97dedf7db43cc9fa6",
"rustc": "rustc 1.95.0 (59807616e 2026-04-14)",
"protocol_version": 1,
"forecast_protocol_version": 1,
Expand Down Expand Up @@ -35,12 +35,12 @@
"bytes": 15377
},
"ftw-solver-linux-amd64": {
"sha256": "22bec2f482e2f1bc63e1781fb37fc672bfa897df0f738452eaf3714b10c2a8d2",
"bytes": 2108704
"sha256": "37ae2a39f921934f3e9610e4943bb5e7ceaca4c959d42419611faed09b1d7846",
"bytes": 2112480
},
"ftw-solver-linux-arm64": {
"sha256": "b56d705ebd80823c9a90b784c876c27ae153a3b3ab3beb28a9acc23ef05f5261",
"bytes": 1676792
"sha256": "e9dd74c63cf36b7b52c8b7aa68811a09a969cd06f762cab8b253d15bc6c7b594",
"bytes": 1679712
},
"rust-runtime/COPYRIGHT-library.html": {
"sha256": "90567e2718bf7fd65a71a3a43c5596488e80e5f51ed02bfea6fec54458b5f3d1",
Expand Down
Loading