dalsi fix forecat tuningu
This commit is contained in:
@@ -1158,8 +1158,8 @@ async def run_rolling_replan(
|
||||
)
|
||||
|
||||
slots = await _load_slots(site_id, replan_from, horizon_to, db, soc_wh=soc_wh)
|
||||
# PV forecast korekce je kanonicky v DB (delta + rolling faktor + decay),
|
||||
# viz ems.fn_forecast_pv_slots_range_canonical_ab a ems.fn_load_planning_slots_full.
|
||||
# PV forecast korekce je kanonicky v DB (delta + rolling faktor + decay) a do LP vstupuje přes
|
||||
# ems.fn_load_planning_slots_full. Pro audit/debug ale chceme ukládat i RAW (bez korekcí).
|
||||
correction_factor, correction_log = 1.0, {
|
||||
"window_start": None,
|
||||
"window_end": None,
|
||||
@@ -1169,6 +1169,31 @@ async def run_rolling_replan(
|
||||
"reason": "canonical_db",
|
||||
}
|
||||
|
||||
# RAW PV pro slot_inputs: přímý součet nejnovějších forecast_pv_interval per array/slot (bez delta/rolling).
|
||||
raw_pv_rows = await db.fetchval(
|
||||
"select ems.fn_forecast_pv_slots_range_raw_ab($1::int, $2::timestamptz, $3::timestamptz)",
|
||||
site_id,
|
||||
replan_from,
|
||||
horizon_to,
|
||||
)
|
||||
raw_pv = raw_pv_rows if isinstance(raw_pv_rows, list) else json.loads(raw_pv_rows)
|
||||
raw_by_ts: dict[str, tuple[int, int]] = {}
|
||||
if isinstance(raw_pv, list):
|
||||
for r in raw_pv:
|
||||
if not isinstance(r, dict):
|
||||
continue
|
||||
ts = r.get("interval_start")
|
||||
if isinstance(ts, str):
|
||||
raw_by_ts[ts] = (
|
||||
int(r.get("pv_a_forecast_raw_w") or 0),
|
||||
int(r.get("pv_b_forecast_raw_w") or 0),
|
||||
)
|
||||
slots_raw_pv: list[PlanningSlot] = []
|
||||
for s in slots:
|
||||
key = s.interval_start.isoformat()
|
||||
pva, pvb = raw_by_ts.get(key, (s.pv_a_forecast_w, s.pv_b_forecast_w))
|
||||
slots_raw_pv.append(replace(s, pv_a_forecast_w=pva, pv_b_forecast_w=pvb))
|
||||
|
||||
commitment_prev = await _load_previous_plan_charge_commitment_prev_w(site_id, slots, db)
|
||||
|
||||
results, duration_ms, solver_snapshot = solve_dispatch(
|
||||
@@ -1178,7 +1203,7 @@ async def run_rolling_replan(
|
||||
charge_commitment_prev_w=commitment_prev,
|
||||
)
|
||||
|
||||
slot_inputs = _build_slot_inputs(slots, slots)
|
||||
slot_inputs = _build_slot_inputs(slots_raw_pv, slots)
|
||||
run_id = await _save_planning_run(
|
||||
site_id,
|
||||
results,
|
||||
|
||||
Reference in New Issue
Block a user