oprava KV1 nabijeni rano misto prodeje
This commit is contained in:
@@ -619,21 +619,31 @@ def _slots_with_charge_acquisition(
|
||||
]
|
||||
|
||||
|
||||
def _pv_store_value_czk_kwh(
|
||||
slot: PlanningSlot,
|
||||
charge_acquisition_czk_kwh: float,
|
||||
min_spread: float,
|
||||
) -> float:
|
||||
def _pv_store_value_czk_kwh(slot: PlanningSlot, min_spread: float) -> float:
|
||||
"""
|
||||
Minimální efektivní sell [Kč/kWh], pod kterým je FVE→síť horší než uložení
|
||||
(večerní peak / náklad zásoby z levného nákupu).
|
||||
Minimální sell [Kč/kWh], pod kterým je FVE→síť horší než uložení na večerní peak.
|
||||
Používá jen future_sell_opportunity (ne charge_acquisition — u fixního tarifu KV1
|
||||
by jinak blokoval export i při kladném sell 2 Kč).
|
||||
"""
|
||||
future = float(
|
||||
slot.future_sell_opportunity_czk_kwh
|
||||
if slot.future_sell_opportunity_czk_kwh is not None
|
||||
else slot.sell_price
|
||||
)
|
||||
return max(future, float(charge_acquisition_czk_kwh)) - min_spread
|
||||
return future - min_spread
|
||||
|
||||
|
||||
def _pre_negative_sell_export_window(
|
||||
slots: list[PlanningSlot],
|
||||
) -> tuple[int | None, int | None]:
|
||||
"""Index prvního sell<0 a posledního slotu před ním (pro strategii „vyvézt dřív“)."""
|
||||
first_neg = next(
|
||||
(i for i, s in enumerate(slots) if float(s.sell_price) < 0),
|
||||
None,
|
||||
)
|
||||
if first_neg is None or first_neg <= 0:
|
||||
return first_neg, None
|
||||
return first_neg, first_neg - 1
|
||||
|
||||
|
||||
def _pv_forced_vent_export_allowed(
|
||||
@@ -917,7 +927,7 @@ def solve_dispatch(
|
||||
|
||||
# Kotva: poslední slot před prvním sell<0 by měl končit u planner floor (pokud relaxace existuje).
|
||||
# Slack penalizujeme v objective; samotné omezení přidáme až po definici soc.
|
||||
first_neg_sell_idx = next((i for i, s in enumerate(slots) if float(s.sell_price) < 0), None)
|
||||
first_neg_sell_idx, pre_neg_export_last_t = _pre_negative_sell_export_window(slots)
|
||||
if first_neg_sell_idx is not None and first_neg_sell_idx > 0 and floor_pct is not None:
|
||||
t_anchor = first_neg_sell_idx - 1
|
||||
soc_anchor_slack = pulp.LpVariable("soc_anchor_slack_wh", 0, float(battery.usable_capacity_wh))
|
||||
@@ -1311,16 +1321,25 @@ def solve_dispatch(
|
||||
0.0,
|
||||
float(s.pv_a_forecast_w) + float(s.pv_b_forecast_w) - load_t,
|
||||
)
|
||||
# FVE export jen pokud sell ≥ hodnota uložení (večerní peak / acquisition − degradace).
|
||||
pv_store_val = _pv_store_value_czk_kwh(
|
||||
s, charge_acquisition_czk_kwh, min_spread
|
||||
# FVE export: před prvním sell<0 smí jít přebytek do sítě (kladný sell), pak nabít
|
||||
# v záporném okně z PV. Jinak držet energii na future_sell peak.
|
||||
allow_pre_neg_pv_export = (
|
||||
first_neg_sell_idx is not None
|
||||
and pre_neg_export_last_t is not None
|
||||
and t <= pre_neg_export_last_t
|
||||
and sell_t >= 0
|
||||
)
|
||||
if sell_t < pv_store_val and not _pv_forced_vent_export_allowed(
|
||||
t,
|
||||
current_soc_wh=current_soc_wh,
|
||||
battery=battery,
|
||||
soc_headroom_wh=soc_headroom_wh,
|
||||
pv_surplus_w=pv_surplus_w,
|
||||
pv_store_val = _pv_store_value_czk_kwh(s, min_spread)
|
||||
if (
|
||||
not allow_pre_neg_pv_export
|
||||
and sell_t < pv_store_val
|
||||
and not _pv_forced_vent_export_allowed(
|
||||
t,
|
||||
current_soc_wh=current_soc_wh,
|
||||
battery=battery,
|
||||
soc_headroom_wh=soc_headroom_wh,
|
||||
pv_surplus_w=pv_surplus_w,
|
||||
)
|
||||
):
|
||||
prob += ge_pv[t] == 0
|
||||
# Drahý nákup: dům + TČ z baterie (ne import ze sítě); síť jen EV (+ případně TČ).
|
||||
|
||||
Reference in New Issue
Block a user