zasadni uprava LP planneru
Some checks failed
CI and deploy / migration-check (push) Failing after 24s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-05-21 11:18:09 +02:00
parent d984716f69
commit 08f1b6741a
7 changed files with 330 additions and 123 deletions

View File

@@ -1057,6 +1057,44 @@ def solve_dispatch(
prob += ge_bat[t] == 0
prob += z_export[t] == 0
# Ekonomické guardy: ceny v objective nestačí proti maskám / terminal SoC.
ref_buy_horizon = min(float(s.buy_price) for s in slots)
min_spread = float(degradation_cost_effective)
hp_rated_w = float(heat_pump.rated_heating_power_w)
soc_headroom_wh = max(
2000.0, 0.05 * float(battery.soc_max_wh)
)
for t in range(T):
s = slots[t]
buy_t = float(s.buy_price)
sell_t = float(s.sell_price)
load_t = float(s.load_baseline_w)
ev_cap_t = sum(
float(vehicles[e].max_charge_power_w)
for e in range(EV)
if (e == 0 and s.ev1_connected) or (e == 1 and s.ev2_connected)
)
pv_surplus_w = max(
0.0,
float(s.pv_a_forecast_w) + float(s.pv_b_forecast_w) - load_t,
)
# Ztrátový export FVE (sell ≪ buy): zakázat jen pokud jde energii do baterie.
# Výjimky: plná baterie (ventil), neriťitelné pv_b s přebytkem.
if sell_t < buy_t - min_spread:
block_loss_pv_export = not (
float(s.pv_b_forecast_w) > 0 and pv_surplus_w > 0
)
if t == 0 and current_soc_wh >= float(battery.soc_max_wh) - soc_headroom_wh:
block_loss_pv_export = False
if block_loss_pv_export:
prob += ge_pv[t] == 0
# Drahý nákup oproti horizontu: import jen na load + EV + TČ, ne na grid-nabíjení.
if buy_t >= 0 and buy_t > ref_buy_horizon + min_spread:
prob += gi[t] <= load_t + ev_cap_t + hp_rated_w
# Anti souběžný vývoz FVE + významný import (mikrocyklus).
if buy_t > sell_t + min_spread and pv_surplus_w > 0:
prob += ge_pv[t] <= pv_surplus_w
# Deadline constraints pro EV
for e, session in enumerate(ev_sessions):
if session and session.target_deadline and session.energy_needed_wh > 0: