neverim ze to pomoze
Some checks failed
CI and deploy / migration-check (push) Failing after 12s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-05-25 02:37:04 +02:00
parent 4beb8cf99f
commit a1270dcda3
4 changed files with 41 additions and 13 deletions

View File

@@ -64,7 +64,7 @@ NEG_SELL_PV_B_VENT_PENALTY_CZK_KWH = 4.0
# Výboj baterie při sell<0 jen těsně před extrémně záporným buy (round-trip arbitráž).
EXTREME_BUY_DUMP_PREWINDOW_SLOTS = 12
NEG_SELL_BAT_DUMP_SHORTFALL_PENALTY_CZK_KWH = 80.0
PLANNER_BUILD_TAG = "2026-05-28-revert-v19-hard-v20"
PLANNER_BUILD_TAG = "2026-05-28-morning-hold-soc-v21"
CORRECTION_WINDOW_H = 1 # hodina zpět pro výpočet korekčního faktoru
CORRECTION_MIN_CLAMP = 0.5 # spodní limit korekčního faktoru
CORRECTION_MAX_CLAMP = 1.5 # horní limit korekčního faktoru
@@ -1402,11 +1402,17 @@ def solve_dispatch(
))
sf = pulp.LpVariable(f"export_shortfall_{t}", 0, cap_w)
peak_export_shortfall.append((t, sf, cap_w))
first_neg_buy_idx_pen = next(
(t for t, s in enumerate(slots) if float(s.buy_price) < 0.0), None
)
for t in range(T):
if float(slots[t].sell_price) >= 0:
continue
if t not in charge_slots:
continue
# Před buy<0: nepenalizovat / netlačit PV→bat (jinak 98 % v 09:15 a export v sell<0).
if first_neg_buy_idx_pen is not None and t < first_neg_buy_idx_pen:
continue
pv_surplus_w = max(
0.0,
float(slots[t].pv_a_forecast_w)
@@ -1439,6 +1445,8 @@ def solve_dispatch(
continue
if t not in charge_slots:
continue
if first_neg_buy_idx_pen is not None and t < first_neg_buy_idx_pen:
continue
pv_surplus_w = max(
0.0,
float(slots[t].pv_a_forecast_w)
@@ -1912,16 +1920,20 @@ def solve_dispatch(
prob += bd[t] == 0
# Slot pre-selection (z DB fn_load_planning_slots_full → allow_*)
first_neg_buy_idx_main = next(
(t for t, s in enumerate(slots) if float(s.buy_price) < 0.0), None
)
if om == "AUTO":
for t in range(T):
s = slots[t]
sell_t_pre = float(s.sell_price)
pv_surplus_for_gi = max(
pv_surplus_w = max(
0,
int(s.pv_a_forecast_w)
+ int(s.pv_b_forecast_w)
- int(s.load_baseline_w),
)
pv_surplus_for_gi = pv_surplus_w
if (
t in charge_slots
and sell_t_pre < 0
@@ -1929,13 +1941,13 @@ def solve_dispatch(
and float(s.buy_price) >= 0.0
):
prob += bc_gi[t] == 0
if t not in charge_slots:
pv_surplus_w = max(
0,
int(s.pv_a_forecast_w)
+ int(s.pv_b_forecast_w)
- int(s.load_baseline_w),
)
before_neg_buy = (
first_neg_buy_idx_main is not None and t < first_neg_buy_idx_main
)
if before_neg_buy and sell_t_pre < 0.0 and pv_surplus_w > 0:
# Ranní sell<0 před buy<0: PV do sítě/curtail, ne do baterie (kapacita na import).
prob += bc_pv[t] == 0
elif t not in charge_slots:
if float(s.buy_price) >= 0.0:
prob += bc_gi[t] == 0
if pv_surplus_w <= 0: