补充上次提交内容

This commit is contained in:
xuwang 2026-06-09 17:26:32 +08:00
parent 7c19f1b5ea
commit 01f26913bd
1 changed files with 15 additions and 31 deletions

View File

@ -740,49 +740,33 @@ def calc_inroad_imbalance_index(inroad_delay_pb_list):
def _classify_angles_to_turn_types(angles, is_merge=False): def _classify_angles_to_turn_types(angles, is_merge=False):
"""
自适应阈值转向分类
从实际角度数据中提取候选阈值优先填满更多转向类型其次选择最接近默认阈值的方案
"""
if not angles: if not angles:
return set() return set()
default_straight = 30 default_straight = 30
default_uturn = 150 default_uturn = 150
abs_angles = sorted(set(round(abs(a)) for a in angles)) abs_angles = sorted(set(abs(a) for a in angles))
straight_candidates = sorted(set(abs_angles + [default_straight]))
straight_candidates = set() uturn_candidates = sorted(set(abs_angles + [default_uturn]))
uturn_candidates = set()
for aa in abs_angles:
if 20 <= aa <= 50:
straight_candidates.add(aa)
if 135 <= aa <= 165:
uturn_candidates.add(aa)
straight_candidates.add(default_straight)
uturn_candidates.add(default_uturn)
straight_candidates = sorted(straight_candidates)
uturn_candidates = sorted(uturn_candidates)
def classify(straight_thr, uturn_thr):
types = set()
for a in angles:
if abs(a) <= straight_thr:
types.add(0)
elif abs(a) >= uturn_thr:
types.add(3)
elif a > 0:
types.add(1 if is_merge else 2)
else:
types.add(2 if is_merge else 1)
return types
best_types = None best_types = None
best_score = (-1, float('inf'), float('inf')) best_score = (-1, float('inf'), float('inf'))
for s_thr in straight_candidates: for s_thr in straight_candidates:
for u_thr in uturn_candidates: for u_thr in uturn_candidates:
types = classify(s_thr, u_thr) if s_thr >= u_thr:
continue
types = set()
for a in angles:
if abs(a) <= s_thr:
types.add(0)
elif abs(a) >= u_thr:
types.add(3)
elif a > 0:
types.add(1 if is_merge else 2)
else:
types.add(2 if is_merge else 1)
score = (len(types), -abs(s_thr - default_straight), -abs(u_thr - default_uturn)) score = (len(types), -abs(s_thr - default_straight), -abs(u_thr - default_uturn))
if score > best_score: if score > best_score:
best_score = score best_score = score