a zase dalsi
This commit is contained in:
@@ -64,7 +64,9 @@ 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-morning-hold-soc-v21b"
|
||||
NEG_BUY_CHARGE_SHORTFALL_PENALTY_CZK_KWH = 100.0
|
||||
PRE_NEG_CHARGE_PENALTY_CZK_KWH = 250.0
|
||||
PLANNER_BUILD_TAG = "2026-05-28-buy-sell-split-v22"
|
||||
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
|
||||
@@ -1387,6 +1389,7 @@ def solve_dispatch(
|
||||
pv_charge_shortfall: list[tuple[int, pulp.LpVariable, float]] = []
|
||||
neg_sell_bat_dump_shortfall: list[tuple[int, pulp.LpVariable, float]] = []
|
||||
neg_sell_soc_underfill: list[tuple[int, pulp.LpVariable]] = []
|
||||
neg_buy_charge_shortfall: list[tuple[int, pulp.LpVariable, float]] = []
|
||||
fixed_tariff_like = fixed_tariff_like_pre
|
||||
block_export_neg_sell = bool(getattr(grid, "block_export_on_negative_sell", False))
|
||||
if om == "AUTO":
|
||||
@@ -1406,9 +1409,17 @@ def solve_dispatch(
|
||||
))
|
||||
sf = pulp.LpVariable(f"export_shortfall_{t}", 0, cap_w)
|
||||
peak_export_shortfall.append((t, sf, cap_w))
|
||||
for t in range(T):
|
||||
if float(slots[t].buy_price) >= 0.0:
|
||||
continue
|
||||
cap_w = float(battery.max_charge_power_w)
|
||||
sf_nb = pulp.LpVariable(f"neg_buy_charge_sf_{t}", 0, cap_w)
|
||||
neg_buy_charge_shortfall.append((t, sf_nb, cap_w))
|
||||
for t in range(T):
|
||||
if float(slots[t].sell_price) >= 0:
|
||||
continue
|
||||
if float(slots[t].buy_price) < 0.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).
|
||||
@@ -1444,6 +1455,8 @@ def solve_dispatch(
|
||||
for t in range(T):
|
||||
if float(slots[t].sell_price) >= 0:
|
||||
continue
|
||||
if float(slots[t].buy_price) < 0.0:
|
||||
continue
|
||||
if t not in charge_slots:
|
||||
continue
|
||||
if first_neg_buy_idx is not None and t < first_neg_buy_idx:
|
||||
@@ -1575,6 +1588,22 @@ def solve_dispatch(
|
||||
sf * NEG_SELL_BAT_DUMP_SHORTFALL_PENALTY_CZK_KWH * INTERVAL_H / 1000.0
|
||||
for _t, sf, _cap in neg_sell_bat_dump_shortfall
|
||||
)
|
||||
+ pulp.lpSum(
|
||||
sf * NEG_BUY_CHARGE_SHORTFALL_PENALTY_CZK_KWH * INTERVAL_H / 1000.0
|
||||
for _t, sf, _cap in neg_buy_charge_shortfall
|
||||
)
|
||||
+ pulp.lpSum(
|
||||
(bc_pv[t] + bc_gi[t])
|
||||
* PRE_NEG_CHARGE_PENALTY_CZK_KWH
|
||||
* INTERVAL_H
|
||||
/ 1000.0
|
||||
for t in range(T)
|
||||
if (
|
||||
first_neg_buy_idx is not None
|
||||
and t < first_neg_buy_idx
|
||||
and float(slots[t].buy_price) >= 0.0
|
||||
)
|
||||
)
|
||||
+ pulp.lpSum(
|
||||
-25.0 * z_export[t]
|
||||
for t in range(T)
|
||||
@@ -1591,6 +1620,8 @@ def solve_dispatch(
|
||||
prob += sf >= cap_w - ge_bat[t_sf]
|
||||
for t_us, us in neg_sell_soc_underfill:
|
||||
prob += us >= float(battery.soc_max_wh) - soc[t_us]
|
||||
for t_sf, sf, cap_w in neg_buy_charge_shortfall:
|
||||
prob += sf >= cap_w - (bc_gi[t_sf] + bc_pv[t_sf])
|
||||
preneg_export_min_soc_wh = float(min_soc_wh) + max(
|
||||
float(battery.max_discharge_power_w)
|
||||
* float(battery.discharge_efficiency)
|
||||
@@ -1731,6 +1762,9 @@ def solve_dispatch(
|
||||
+ sum(v.max_charge_power_w for v in vehicles)
|
||||
+ heat_pump.rated_heating_power_w,
|
||||
)
|
||||
prob += ge[t] == 0
|
||||
prob += ge_pv[t] == 0
|
||||
prob += ge_bat[t] == 0
|
||||
|
||||
# Záporný prodej (sell < 0): výboj baterie jen před extrémně záporným buy (v11).
|
||||
# Export FVE při sell<0: spot = nabíjení/curtail A; ventil jen pole B při plné baterii.
|
||||
@@ -1952,7 +1986,14 @@ def solve_dispatch(
|
||||
before_neg_buy = (
|
||||
first_neg_buy_idx is not None and t < first_neg_buy_idx
|
||||
)
|
||||
if before_neg_buy and sell_t_pre < 0.0 and pv_surplus_w > 0:
|
||||
if (
|
||||
before_neg_buy
|
||||
and float(s.buy_price) >= 0.0
|
||||
and bool(getattr(s, "is_daytime_pv_surplus_slot", False))
|
||||
):
|
||||
prob += bc_pv[t] == 0
|
||||
prob += bc_gi[t] == 0
|
||||
elif 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:
|
||||
@@ -2005,6 +2046,7 @@ def solve_dispatch(
|
||||
float(s.pv_b_forecast_w) > 0
|
||||
and not getattr(grid, "block_export_on_negative_sell", False)
|
||||
and sell_t < 0
|
||||
and buy_t >= 0.0
|
||||
and not purchase_fixed_pre
|
||||
) or (
|
||||
# KV1: plná baterie + kladný sell — neblokovat ge_pv==0 (jinak masivní curtail).
|
||||
@@ -2046,6 +2088,7 @@ def solve_dispatch(
|
||||
# zablokovalo legitimní pre-neg-pv export pole A z testů).
|
||||
if (
|
||||
sell_t < 0
|
||||
and buy_t >= 0.0
|
||||
and float(s.pv_b_forecast_w) > 0
|
||||
and not getattr(grid, "block_export_on_negative_sell", False)
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user