fix(investigation): allow autonomous model baseline recovery
This commit is contained in:
@@ -125,6 +125,13 @@ def estimate_burst_impact(network: str, start: datetime, simulation: dict[str, A
|
||||
impact["below_threshold_node_count"] = len(comparisons) - affected
|
||||
if not comparisons:
|
||||
impact.update(status="unavailable", reason="no_exact_comparable_online_snapshot")
|
||||
impact["baseline_recovery"] = {
|
||||
"tool": "run_simulation",
|
||||
"parameters": {
|
||||
"start_time": start.isoformat(), "duration": 60, "output_node_ids": ids[:1],
|
||||
},
|
||||
"next_step": "自主补算同刻在线基线;等待作业成功并读取结果后,按原参数重跑爆管影响计算,再发布降压覆盖。返回节点仅用于核验,在线基线按全网写入。",
|
||||
}
|
||||
return output
|
||||
if affected > MAX_COVERAGE_NODES:
|
||||
impact["coverage_status"] = "unavailable"
|
||||
|
||||
@@ -157,6 +157,7 @@ def run_online_simulation(
|
||||
*,
|
||||
output_node_ids: list[str] | None = None,
|
||||
output_link_ids: list[str] | None = None,
|
||||
scada_mappings: ScadaElementMappings | None = None,
|
||||
) -> dict:
|
||||
"""Recalculate online baseline snapshots without cloning a model database."""
|
||||
if start_time.tzinfo is None or duration_seconds <= 0:
|
||||
@@ -166,7 +167,10 @@ def run_online_simulation(
|
||||
)
|
||||
if step <= 0:
|
||||
raise ValueError("HYDRAULIC TIMESTEP must be greater than 0.")
|
||||
mappings = query_corresponding_element_id_and_query_id(name)
|
||||
mappings = (
|
||||
scada_mappings if scada_mappings is not None
|
||||
else query_corresponding_element_id_and_query_id(name)
|
||||
)
|
||||
selected = {
|
||||
"node": {node: [] for node in output_node_ids or []},
|
||||
"link": {link: [] for link in output_link_ids or []},
|
||||
@@ -179,13 +183,13 @@ def run_online_simulation(
|
||||
output = run_simulation(
|
||||
name=name,
|
||||
simulation_type="realtime",
|
||||
modify_pattern_start_time=current.isoformat(timespec="seconds"),
|
||||
modify_pattern_start_time=current.isoformat(),
|
||||
scada_mappings=mappings,
|
||||
)
|
||||
if not isinstance(output, dict):
|
||||
raise RuntimeError("Online simulation did not return calculation results")
|
||||
units = output.get("units", {})
|
||||
sample_times.append(current.isoformat(timespec="seconds"))
|
||||
sample_times.append(current.isoformat())
|
||||
for kind, elements in selected.items():
|
||||
if not elements:
|
||||
continue
|
||||
|
||||
@@ -231,6 +231,7 @@ def valve_close_analysis(
|
||||
_temporary_project: str | None = None,
|
||||
persist_results: bool = True,
|
||||
username: str = "system",
|
||||
scada_mappings: ScadaElementMappings | None = None,
|
||||
) -> dict | str | None:
|
||||
"""
|
||||
关阀模拟
|
||||
@@ -291,6 +292,7 @@ def valve_close_analysis(
|
||||
result_db_name=name,
|
||||
persist_results=persist_results,
|
||||
scheme_username=username,
|
||||
scada_mappings=scada_mappings,
|
||||
)
|
||||
return result if not persist_results else None
|
||||
# step 3. restore the base model
|
||||
|
||||
Reference in New Issue
Block a user