Repository navigation
feat(thermaltwin,heat): typed bounded twin v2, sensor guard, flow input, and closed-loop shadow sim - #2157
Draft
hannesb90 wants to merge 11 commits into
Draft
feat(thermaltwin,heat): typed bounded twin v2, sensor guard, flow input, and closed-loop shadow sim#2157hannesb90 wants to merge 11 commits into
hannesb90 wants to merge 11 commits into
Conversation
A water-heated floor answers late and then settles, which the twin's form cannot say. Run a candidate with six earlier windows of heat beside it and score both over the same stretches. Nothing plans from it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: hannesb90 <bruhn90@gmail.com>
Raise the floor's limit for a measured room, leave neighbours' heat out of dear slots, and check each plan against the lagged candidate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: hannesb90 <bruhn90@gmail.com>
Judge it as a plan uses it, on a week, against no-change and on how often a zone ends colder than predicted. Bound the covariance without freezing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: hannesb90 <bruhn90@gmail.com>
A house on always-open loops moves a tenth of a kelvin in three hours, the sensor's own step, so no form can beat "no change" there. A zone that loses heat to outdoors is now held to a twelve-hour score instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The candidate learns one half-hour step at a time and is judged over three or twelve hours. A house drifting 0.04 K/h is under its sensor's step in a window and half a kelvin in twelve hours, so the step never sees it. Keep a bounded rate correction that each judgement moves against its stretch's error: the twelve hours for a slow zone, the three for a floor. Replayed on 2026-11-27..12-02, the house's twelve-hour error fell from 0.54 to 0.23 K and its bias from -0.54 to -0.21 K; three hours and the floors were unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: hannesb90 <279736760+hannesb90@users.noreply.github.com>
… input, and closed-loop shadow sim
…Forecast hysteresis - Raise longWarmupSamples from 12 (6h) to 48 (24h) so cold-start 12h errors before Huber engages do not pollute a week of hydronic skill scores. - Make warmMissK emitter-aware (0.75 K for lively electric_floor, 0.5 K for hydronic/room_air) and tighten electric_floor negative lag lower bounds. - Tolerate tiny 1-min relay blips and 15-min blockade boundary overlaps in AfterOff while keeping minAfterOffForForecast=10 strict. - Align Lagged.Forecast skill gate with Status hysteresis (driftSkill once WasTrusted) so trusted zones do not flap unchecked around 0.80. - Pass Twin.LastEval into heat-replay instead of hardcoded 0 so replay scores AfterOff/Forecast accurately.
A write needs the candidate twin trusted and checking the plan, so the streaming-phone test's house carries one that agrees with it, as the heatrun tests do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: hannesb90 <bruhn90@gmail.com>
hannesb90
force-pushed
the
feat/thermal-twin-v2
branch
from
December 5, 2026 16:58
5dc4287 to
0cc88dc
Compare
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.
Summary
Follow-up improvements to the thermal twin, heat planner, and shadow runner based on 11 days of real-house data (SE3 Sweden, Nov 21 – Dec 2, 2026) across a hydronic air-to-water heat pump floor slab (over crawlspace) and 3 direct-electric underfloor zones:
Lagged candidate twin + typed bounded v2 (
go/internal/thermaltwin/lagged.go,model.go,service.go):electric_floorK=6,hydronicK=2,room_airK=6) with optionalemitter/flow_ref_cconfig fields and automatic inference (go/internal/config/heat.go).a > 0, consistentc), and Huber outlier weighting so wood-stove spikes or brief disturbances don't corrupt the twin.*_flow_temp_casmax(0, flow - ref)/10) instead of noisy compressor cycles.Long) without requiringAfterOff >= 10windows.Sample.Suspectsensor guard (frozen sensor flatline & phantomoutput_limitedwith< 10 Wdraw) so misbehaving thermostats don't poison training or scoring.Params()) and earn write trust (go/internal/heatrun/service.go,guard.go) while holding floor plans to room minimum temperatures.Closed-loop shadow rollout & long-peak relief (
go/internal/heatrun/shadowlog.go,go/internal/heatplan/comfort.go):sim_temp_c/sim_costvssim_base_temp_c/sim_base_cost) inheat-shadow.jsonlto eliminate the open-loop "free coasting" mirage when evaluating shadow savings against real meter data.PeakRelief.NoTimeCap(bandMinCgoverns coast duration; DP picks cheapest quarters inside long peaks; non-positive prices are never treated as peaks).Offline benchmark tool (
go/cmd/heat-replay):thermaltwinandheatplanpackages.Real-house historical benchmark (Nov 21 – Dec 2, 2026, SE3)
Verified with
go run ./cmd/heat-replayon anonymized real-house data (ftw-heat-replay-anonymized-2026-12-02.json— happy to share privately):Twin accuracy (
thermaltwinv2 candidate vs 1-node twin & persistence)floor_1(bathroom downstairs, 900 W)electric_floor0.268 K/0.358 K4%, bias+0.024 Kfloor_2(bathroom upstairs, 575 W)electric_floor0.564 K/0.743 Kfloor_3(entryway, 650 W)electric_floor0.542 K/0.739 Kτ = 5.5 h,C = 0.35 kWh/Khouse_hydronic_w(A2W HP,house_heat_w)hydronic0.232 K/0.266 Kτ = 61.4 h,C = 9.04 kWh/Khouse_hydronic_flow(A2W HP,flow_temp)hydronic0.266 K/0.266 K0.68 < 0.80,τ = 63.2 hClosed-loop shadow rollout vs real meter
plan / base)min / mean)house_hydronic_w444.4 / 846.0 kr19.5 / 20.3 °Cfloor_31.46 / 36.25 kr20.2 / 22.0 °Cfloor_253.4 / 213.9 kr22.5 / 23.7 °Cfloor_189.6 / 286.3 kr23.6 / 24.4 °CVerification
go test ./internal/thermaltwin ./internal/heatplan ./internal/config ./internal/heatrun— all passing.go run ./cmd/heat-replay -in ftw-heat-replay-anonymized-2026-12-02.json— verified end-to-end.heat.write: falseshadow mode on Raspberry Pi 4 (v0.166.0-beta.97).