重构管道中心选择逻辑,优化数据处理方式
This commit is contained in:
@@ -37,6 +37,8 @@ def _ensure_signatures_for_centers(
|
||||
其中 subset 只包含 center_list 的行(顺序与 center_list 保持一致)。
|
||||
"""
|
||||
|
||||
center_list = _dedupe_preserve_order(center_list)
|
||||
|
||||
# 1) 推断传感器列名(与现有数据保持一致)
|
||||
sensor_name_all = list(pressure_monitor.columns)
|
||||
sensor_f_name_all = (
|
||||
@@ -193,6 +195,17 @@ def find_list_repeat(candidate_center, target):
|
||||
return repeated_list
|
||||
|
||||
|
||||
def _dedupe_preserve_order(items):
|
||||
seen = set()
|
||||
output = []
|
||||
for item in items:
|
||||
if item in seen:
|
||||
continue
|
||||
seen.add(item)
|
||||
output.append(item)
|
||||
return output
|
||||
|
||||
|
||||
def cal_DtoTop1(
|
||||
G0, pipe_leak, located_pipe, pipe_start_node_all, pipe_end_node_all, pipe_length
|
||||
):
|
||||
@@ -324,6 +337,7 @@ def DN_search_multi_simple_add_flow_count_new(
|
||||
dis_f_h = 0
|
||||
if_compalsive = 0
|
||||
record_center_dataset = []
|
||||
record_center_set = set()
|
||||
# iter
|
||||
while 1:
|
||||
final_area = []
|
||||
@@ -374,18 +388,21 @@ def DN_search_multi_simple_add_flow_count_new(
|
||||
leak_center_dict = dict()
|
||||
for i in range(len(candidate_center_list)):
|
||||
houxuan_center = []
|
||||
candidate_group_set = set(candidate_group_list[i])
|
||||
for each_center in record_center_dataset:
|
||||
if (
|
||||
each_center in candidate_group_list[i]
|
||||
each_center in candidate_group_set
|
||||
and each_center != candidate_center_list[i]
|
||||
):
|
||||
houxuan_center.append(each_center)
|
||||
add_center = add_center + houxuan_center
|
||||
houxuan_center.append(candidate_center_list[i])
|
||||
leak_center_dict[candidate_center_list[i]] = houxuan_center
|
||||
add_center = _dedupe_preserve_order(add_center)
|
||||
for each_center in candidate_center_list:
|
||||
if each_center not in record_center_dataset:
|
||||
if each_center not in record_center_set:
|
||||
record_center_dataset.append(each_center)
|
||||
record_center_set.add(each_center)
|
||||
|
||||
# --------------------------------------------------------
|
||||
# --------------------------------------------------------
|
||||
@@ -417,7 +434,9 @@ def DN_search_multi_simple_add_flow_count_new(
|
||||
if len(candidate_pipe_input) < 1.2 * top_pipe_num_max / top_group_ratio:
|
||||
if_compalsive = 1
|
||||
cos_h, dis_h, dis_f_h = adjust_ratio(similarity_mode, cos_h, dis_h, dis_f_h)
|
||||
candidate_center_list_sup = candidate_center_list + add_center
|
||||
candidate_center_list_sup = _dedupe_preserve_order(
|
||||
candidate_center_list + add_center
|
||||
)
|
||||
similarity, cos_h, dis_h, dis_f_h, break_flag = (
|
||||
cal_similarity_all_multi_new_sq_improve_double_lzr(
|
||||
candidate_center_list_sup,
|
||||
|
||||
Reference in New Issue
Block a user