pry oprava uplne chybneho rizeni (prodaval za levneji nez nakoupil)
This commit is contained in:
@@ -707,6 +707,13 @@ def solve_dispatch(
|
||||
)
|
||||
|
||||
om = (operating_mode or "AUTO").strip().upper()
|
||||
charge_slots: set[int] = set()
|
||||
discharge_export_slots: set[int] = set()
|
||||
if om == "AUTO":
|
||||
charge_slots = {t for t, s in enumerate(slots) if s.allow_charge}
|
||||
discharge_export_slots = {
|
||||
t for t, s in enumerate(slots) if s.allow_discharge_export
|
||||
}
|
||||
# SELF_SUSTAIN dřív vynucoval ge[t] == 0, což umí udělat MILP infeasible v okamžiku, kdy:
|
||||
# - baterie je na max SoC (nelze nabíjet),
|
||||
# - PV pole B není curtailable,
|
||||
@@ -939,14 +946,28 @@ def solve_dispatch(
|
||||
arb_cap_t = min(arb_t, soc_low_t)
|
||||
else:
|
||||
arb_cap_t = arb_t
|
||||
prob += soc_prev_expr >= (arb_cap_t - (arb_cap_t - soc_low_t) * (1 - w_arb[t]))
|
||||
prob += bd[t] <= (
|
||||
s.load_baseline_w
|
||||
+ ev_total_t
|
||||
+ hp[t]
|
||||
+ bc[t]
|
||||
+ battery.max_discharge_power_w * w_arb[t]
|
||||
)
|
||||
if om == "AUTO" and t not in discharge_export_slots:
|
||||
# PASSIVE na střídači: EMS neplánuje vybíjení do load (Deye pokryje skutečnou zátěž).
|
||||
pass
|
||||
elif om == "AUTO" and t in discharge_export_slots:
|
||||
prob += soc_prev_expr >= (
|
||||
arb_cap_t - (arb_cap_t - soc_low_t) * (1 - w_arb[t])
|
||||
)
|
||||
prob += bd[t] <= (
|
||||
battery.max_discharge_power_w * w_arb[t]
|
||||
+ pulp.lpSum(ev_via_bat[e][t] for e in range(EV))
|
||||
)
|
||||
else:
|
||||
prob += soc_prev_expr >= (
|
||||
arb_cap_t - (arb_cap_t - soc_low_t) * (1 - w_arb[t])
|
||||
)
|
||||
prob += bd[t] <= (
|
||||
s.load_baseline_w
|
||||
+ ev_total_t
|
||||
+ hp[t]
|
||||
+ bc[t]
|
||||
+ battery.max_discharge_power_w * w_arb[t]
|
||||
)
|
||||
|
||||
# Významný export ⇒ koncové SoC ≥ podlaha (viz soc_panel_min / arb_base).
|
||||
m_ge = float(grid.max_export_power_w)
|
||||
@@ -1001,18 +1022,12 @@ def solve_dispatch(
|
||||
|
||||
# Slot pre-selection (z DB fn_load_planning_slots_full → allow_*)
|
||||
if om == "AUTO":
|
||||
charge_slots = {t for t, s in enumerate(slots) if s.allow_charge}
|
||||
discharge_export_slots = {t for t, s in enumerate(slots) if s.allow_discharge_export}
|
||||
for t in range(T):
|
||||
if t not in charge_slots:
|
||||
prob += bc[t] == 0
|
||||
|
||||
if t not in discharge_export_slots:
|
||||
s = slots[t]
|
||||
ev_total_t = pulp.lpSum(
|
||||
ev_direct[e][t] + ev_via_bat[e][t] for e in range(EV)
|
||||
)
|
||||
prob += bd[t] <= s.load_baseline_w + ev_total_t + hp[t]
|
||||
prob += bd[t] == 0
|
||||
prob += w_arb[t] == 0
|
||||
|
||||
# Deadline constraints pro EV
|
||||
for e, session in enumerate(ev_sessions):
|
||||
@@ -1083,10 +1098,18 @@ def solve_dispatch(
|
||||
if grid_w < 0:
|
||||
export_mode = "BATTERY_SELL" if batt_w < 0 else "PV_SURPLUS"
|
||||
|
||||
# Primární klasifikace fyzického režimu pro Deye: explicitně do plánu (Variant A).
|
||||
# Default PASSIVE; SELL při export+vybíjení; CHARGE při import+nabíjení.
|
||||
# Deye: default PASSIVE (střídač pokryje load). CHARGE/SELL jen v maskovaných AUTO slotech.
|
||||
deye_mode = "PASSIVE"
|
||||
if batt_w < 0 and grid_w < 0:
|
||||
if om == "AUTO":
|
||||
if (
|
||||
slots[t].allow_discharge_export
|
||||
and batt_w < 0
|
||||
and grid_w < 0
|
||||
):
|
||||
deye_mode = "SELL"
|
||||
elif slots[t].allow_charge and batt_w > 0 and grid_w > 0:
|
||||
deye_mode = "CHARGE"
|
||||
elif batt_w < 0 and grid_w < 0:
|
||||
deye_mode = "SELL"
|
||||
elif batt_w > 0 and grid_w > 0:
|
||||
deye_mode = "CHARGE"
|
||||
|
||||
Reference in New Issue
Block a user