From 6fe01aa248b18aa3bae42e7717de3e2c600379c8 Mon Sep 17 00:00:00 2001 From: Jiang Date: Tue, 3 Feb 2026 10:57:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=85=B3=E9=98=80=E5=88=86?= =?UTF-8?q?=E6=9E=90=E7=AE=97=E6=B3=95=E8=BE=93=E5=87=BA=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/algorithms/valve_isolation.py | 33 +------------------------------ scripts/run_server.py | 2 +- 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/app/algorithms/valve_isolation.py b/app/algorithms/valve_isolation.py index 7c9f088..98f22ce 100644 --- a/app/algorithms/valve_isolation.py +++ b/app/algorithms/valve_isolation.py @@ -1,13 +1,7 @@ from collections import defaultdict, deque from typing import Any -from app.services.tjnetwork import ( - get_link_properties, - get_link_type, - get_network_link_nodes, - is_link, - is_node, -) +from app.services.tjnetwork import get_network_link_nodes VALVE_LINK_TYPE = "valve" @@ -35,30 +29,6 @@ def valve_isolation_analysis( target_elements = accident_elements start_nodes = set() - accident_types = set() - - for element in target_elements: - if is_node(network, element): - start_nodes.add(element) - accident_types.add("node") - elif is_link(network, element): - l_type = get_link_type(network, element) - accident_types.add(l_type) - link_props = get_link_properties(network, element) - node1 = link_props.get("node1") - node2 = link_props.get("node2") - if not node1 or not node2: - # 如果是批量处理,可以选择跳过错误或记录错误,这里暂时保持严谨抛出异常 - raise ValueError(f"Accident link {element} missing node endpoints") - start_nodes.add(node1) - start_nodes.add(node2) - else: - raise ValueError(f"Accident element {element} not found") - - # 如果有多种类型混合,简化返回类型描述 - accident_type_str = ( - list(accident_types)[0] if len(accident_types) == 1 else "mixed" - ) adjacency: dict[str, set[str]] = defaultdict(set) valve_links: dict[str, tuple[str, str]] = {} @@ -97,7 +67,6 @@ def valve_isolation_analysis( result = { "accident_elements": target_elements, - "accident_type": accident_type_str, "affected_nodes": sorted(affected_nodes), "must_close_valves": must_close_valves, "optional_valves": optional_valves, diff --git a/scripts/run_server.py b/scripts/run_server.py index 57f2c67..77b566d 100644 --- a/scripts/run_server.py +++ b/scripts/run_server.py @@ -16,6 +16,6 @@ if __name__ == "__main__": "app.main:app", host="0.0.0.0", port=8000, - # workers=2, # 这里可以设置多进程 + workers=2, # 这里可以设置多进程 loop="asyncio", )