fix(optimization): shift the warm start by the slots elapsed since it was computed

A planned battery export kept moving 15 minutes later with every run. At
07:49 the plan exported at 08:00 and 08:15; the run at 08:00 exported at 08:15
and 08:30, although nothing in the forecasts had changed.

Genomes are run-relative: gene 0 controls the slot the run starts in. Clients
such as Node-RED send the previous `start_solution` back unchanged, so after a
slot boundary every decision in it is read one slot too late. The warm start is
seeded as exact copies and local neighbours, and when an export 15 minutes
later scores almost the same, the shifted genome survives and becomes the next
warm start. The internal energy management run reused its last solution the
same way.

Solutions now carry `start_solution_datetime`, the start of the slot gene 0
controls, and requests accept it back. Before seeding, the battery and EV blocks
drop the elapsed slots and repeat their last gene. A warm start that starts
after the run, or whose control slots have all elapsed, is ignored. When a
request omits the datetime but its `start_solution` equals the last solution of
this server, that solution's start is used, so existing clients are fixed
without changes. Appliance genes index per-run start slot lists that cannot be
rebuilt for the earlier run and stay as they are, validated as before.
This commit is contained in:
Andreas
2026-09-14 08:30:11 +02:00
parent 78f6dfeb84
commit d2e2d58237
5 changed files with 302 additions and 3 deletions
+34
View File
@@ -5385,6 +5385,23 @@
],
"title": "Start Solution",
"description": "Can be `null` or contain a previous solution (if available)."
},
"start_solution_datetime": {
"anyOf": [
{
"type": "string",
"format": "date-time"
},
{
"type": "null"
}
],
"title": "Start Solution Datetime",
"description": "Start of the slot that gene 0 of 'start_solution' controls, as returned with the previous solution. The warm start is shifted by the slots that have elapsed until this run. Without it, a 'start_solution' identical to the last solution of this server uses that solution's start; any other one is used unshifted.",
"examples": [
null,
"2026-09-14T07:45:00+02:00"
]
}
},
"additionalProperties": false,
@@ -5650,6 +5667,23 @@
"title": "Start Solution",
"description": "An array of binary values (0 or 1) representing a possible starting solution for the simulation."
},
"start_solution_datetime": {
"anyOf": [
{
"type": "string",
"format": "date-time"
},
{
"type": "null"
}
],
"title": "Start Solution Datetime",
"description": "Start of the slot that gene 0 of 'start_solution' controls. Send it back together with 'start_solution' so the next run can shift the warm start by the slots that have elapsed since.",
"examples": [
null,
"2026-09-14T07:45:00+02:00"
]
},
"washingstart": {
"anyOf": [
{