fix BA81 nevybijeni do site
This commit is contained in:
@@ -29,7 +29,6 @@ logger = logging.getLogger(__name__)
|
|||||||
# Když DB vrátí NULL (skoro žádná OTE data), denní plán použije krátký fallback (soulad s min hodinami ve fn_planning_horizon_end).
|
# Když DB vrátí NULL (skoro žádná OTE data), denní plán použije krátký fallback (soulad s min hodinami ve fn_planning_horizon_end).
|
||||||
_DAILY_FALLBACK_HORIZON_HOURS = 1.0
|
_DAILY_FALLBACK_HORIZON_HOURS = 1.0
|
||||||
# Shadow cena zbytkové energie na konci horizontu: - (avg_buy * FACTOR / 1000) * soc[T-1] (Kč; soc v Wh).
|
# Shadow cena zbytkové energie na konci horizontu: - (avg_buy * FACTOR / 1000) * soc[T-1] (Kč; soc v Wh).
|
||||||
TERMINAL_SOC_VALUE_FACTOR = 0.9
|
|
||||||
INTERVAL_H = 0.25 # 15 minut v hodinách
|
INTERVAL_H = 0.25 # 15 minut v hodinách
|
||||||
CURTAILMENT_PENALTY = 0.001 # Kč/Wh – malá penalizace za omezení FVE pole A
|
CURTAILMENT_PENALTY = 0.001 # Kč/Wh – malá penalizace za omezení FVE pole A
|
||||||
SOLVER_TIME_LIMIT = 10 # sekund
|
SOLVER_TIME_LIMIT = 10 # sekund
|
||||||
@@ -577,9 +576,7 @@ def solve_dispatch(
|
|||||||
if horizon_slots_h24 > 0
|
if horizon_slots_h24 > 0
|
||||||
else 4.0
|
else 4.0
|
||||||
)
|
)
|
||||||
terminal_factor = float(
|
terminal_factor = float(battery.planner_terminal_soc_value_factor)
|
||||||
getattr(battery, "planner_terminal_soc_value_factor", TERMINAL_SOC_VALUE_FACTOR)
|
|
||||||
)
|
|
||||||
# Kč/Wh: ocenění energie ponechané v baterii na konci horizontu (receding horizon kotva).
|
# Kč/Wh: ocenění energie ponechané v baterii na konci horizontu (receding horizon kotva).
|
||||||
terminal_soc_kcz_per_wh = (
|
terminal_soc_kcz_per_wh = (
|
||||||
avg_buy_terminal * terminal_factor / 1000.0
|
avg_buy_terminal * terminal_factor / 1000.0
|
||||||
@@ -1135,6 +1132,7 @@ async def _load_site_context(site_id: int, db):
|
|||||||
planner_discharge_relax_prewindow_slots=int(relax_prewin)
|
planner_discharge_relax_prewindow_slots=int(relax_prewin)
|
||||||
if relax_prewin is not None
|
if relax_prewin is not None
|
||||||
else DEFAULT_PLANNER_DISCHARGE_RELAX_PREWINDOW_SLOTS,
|
else DEFAULT_PLANNER_DISCHARGE_RELAX_PREWINDOW_SLOTS,
|
||||||
|
planner_terminal_soc_value_factor=float(b["planner_terminal_soc_value_factor"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
hpj = ctx["heat_pump"]
|
hpj = ctx["heat_pump"]
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ def _battery(
|
|||||||
min_pct: float = 10.0,
|
min_pct: float = 10.0,
|
||||||
arb_pct: float = 20.0,
|
arb_pct: float = 20.0,
|
||||||
max_pct: float = 95.0,
|
max_pct: float = 95.0,
|
||||||
|
terminal_soc_value_factor: float = 0.9,
|
||||||
) -> SimpleNamespace:
|
) -> SimpleNamespace:
|
||||||
uc = uc_wh
|
uc = uc_wh
|
||||||
min_wh = min_pct / 100.0 * uc
|
min_wh = min_pct / 100.0 * uc
|
||||||
@@ -59,6 +60,7 @@ def _battery(
|
|||||||
degradation_cost_czk_kwh=0.15,
|
degradation_cost_czk_kwh=0.15,
|
||||||
max_charge_power_w=10_000,
|
max_charge_power_w=10_000,
|
||||||
max_discharge_power_w=10_000,
|
max_discharge_power_w=10_000,
|
||||||
|
planner_terminal_soc_value_factor=terminal_soc_value_factor,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
-- planner_terminal_soc_value_factor: LP terminal SoC shadow price (planning_engine).
|
||||||
|
-- V062 přidal sloupec NOT NULL default 0.9; tato migrace je idempotentní upevnění pro starší / ručně upravené DB.
|
||||||
|
|
||||||
|
update ems.asset_battery
|
||||||
|
set planner_terminal_soc_value_factor = 0.9
|
||||||
|
where planner_terminal_soc_value_factor is null;
|
||||||
|
|
||||||
|
alter table ems.asset_battery
|
||||||
|
alter column planner_terminal_soc_value_factor set default 0.9;
|
||||||
|
|
||||||
|
alter table ems.asset_battery
|
||||||
|
alter column planner_terminal_soc_value_factor set not null;
|
||||||
@@ -66,7 +66,8 @@ begin
|
|||||||
)
|
)
|
||||||
)::int,
|
)::int,
|
||||||
'charge_slot_buffer', ab.charge_slot_buffer,
|
'charge_slot_buffer', ab.charge_slot_buffer,
|
||||||
'discharge_slot_buffer', ab.discharge_slot_buffer
|
'discharge_slot_buffer', ab.discharge_slot_buffer,
|
||||||
|
'planner_terminal_soc_value_factor', ab.planner_terminal_soc_value_factor
|
||||||
)
|
)
|
||||||
into v_b
|
into v_b
|
||||||
from ems.asset_battery ab
|
from ems.asset_battery ab
|
||||||
@@ -130,13 +131,6 @@ begin
|
|||||||
raise exception 'No site_grid_connection for site_id=%', p_site_id;
|
raise exception 'No site_grid_connection for site_id=%', p_site_id;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
-- LP tuning (battery-level): terminal SoC shadow price factor
|
|
||||||
v_b := jsonb_set(
|
|
||||||
v_b,
|
|
||||||
'{planner_terminal_soc_value_factor}',
|
|
||||||
to_jsonb(coalesce((v_b->>'planner_terminal_soc_value_factor')::numeric, 0.9))
|
|
||||||
);
|
|
||||||
|
|
||||||
select coalesce(
|
select coalesce(
|
||||||
jsonb_agg(
|
jsonb_agg(
|
||||||
jsonb_build_object(
|
jsonb_build_object(
|
||||||
|
|||||||
Reference in New Issue
Block a user