diff --git a/.changeset/bundle-energyplan-071.md b/.changeset/bundle-energyplan-071.md new file mode 100644 index 000000000..e6de41a5f --- /dev/null +++ b/.changeset/bundle-energyplan-071.md @@ -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. diff --git a/go/internal/mpc/energyplan_fault_test.go b/go/internal/mpc/energyplan_fault_test.go index 554e56f75..a715bd4bd 100644 --- a/go/internal/mpc/energyplan_fault_test.go +++ b/go/internal/mpc/energyplan_fault_test.go @@ -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) diff --git a/go/internal/mpc/energyplan_test.go b/go/internal/mpc/energyplan_test.go index 9651b57e8..05a410bec 100644 --- a/go/internal/mpc/energyplan_test.go +++ b/go/internal/mpc/energyplan_test.go @@ -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) diff --git a/go/internal/mpc/native_below_floor_test.go b/go/internal/mpc/native_below_floor_test.go new file mode 100644 index 000000000..5f532e934 --- /dev/null +++ b/go/internal/mpc/native_below_floor_test.go @@ -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) + } + } +} diff --git a/optimizer/native/bundle/ftw-solver-linux-amd64 b/optimizer/native/bundle/ftw-solver-linux-amd64 index c4149c016..cbf40d331 100755 Binary files a/optimizer/native/bundle/ftw-solver-linux-amd64 and b/optimizer/native/bundle/ftw-solver-linux-amd64 differ diff --git a/optimizer/native/bundle/ftw-solver-linux-arm64 b/optimizer/native/bundle/ftw-solver-linux-arm64 index 78b30ba71..d75fc4cd4 100755 Binary files a/optimizer/native/bundle/ftw-solver-linux-arm64 and b/optimizer/native/bundle/ftw-solver-linux-arm64 differ diff --git a/optimizer/native/bundle/manifest.json b/optimizer/native/bundle/manifest.json index 1a618852b..6729031dd 100644 --- a/optimizer/native/bundle/manifest.json +++ b/optimizer/native/bundle/manifest.json @@ -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, @@ -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",