修复车检器问题

This commit is contained in:
Zihan Ye 2026-04-23 11:58:56 +08:00
parent d764c7e763
commit a6a2e5a626
5 changed files with 35 additions and 14 deletions

View File

@ -53,8 +53,8 @@ environment:
free_flow_speed: 30.56 free_flow_speed: 30.56
reward: reward:
efficiency_alpha: 2.19 efficiency_alpha: 2.1159
safety_beta: 9.19 safety_beta: 7.8553
efficiency_exponent: 0.50 efficiency_exponent: 0.50
safety_exponent: 0.50 safety_exponent: 0.50
ttc_threshold_s: 2.3 ttc_threshold_s: 2.3

View File

@ -215,6 +215,8 @@ class SUMOEdgeVSLEnvironment:
str(self.end_time), str(self.end_time),
"--collision.action", "--collision.action",
"warn", "warn",
"--no-step-log",
"true",
"--quit-on-end", "--quit-on-end",
"true", "true",
] ]

View File

@ -199,7 +199,8 @@ class SUMONetworkParser:
for lane in lane_nodes: for lane in lane_nodes:
lane_idx = int(lane.get("index", "0")) lane_idx = int(lane.get("index", "0"))
allow = (lane.get("allow") or "").strip() allow = (lane.get("allow") or "").strip()
if allow != "emergency": allow_tokens = {token for token in allow.split() if token}
if allow_tokens != {"emergency"}:
traffic_lanes.append(lane_idx) traffic_lanes.append(lane_idx)
if not traffic_lanes: if not traffic_lanes:

View File

@ -36,8 +36,8 @@ def average_reward_components(totals: Mapping[str, float], steps: int) -> Dict[s
@dataclass(frozen=True) @dataclass(frozen=True)
class RewardConfig: class RewardConfig:
efficiency_alpha: float = 2.19 efficiency_alpha: float = 2.1159
safety_beta: float = 9.19 safety_beta: float = 7.8553
efficiency_exponent: float = 0.50 efficiency_exponent: float = 0.50
safety_exponent: float = 0.50 safety_exponent: float = 0.50
ttc_threshold_s: float = 2.3 ttc_threshold_s: float = 2.3
@ -55,8 +55,8 @@ class RewardConfig:
_ = speed_actions_ms _ = speed_actions_ms
return cls( return cls(
efficiency_alpha=float(raw_cfg.get("efficiency_alpha", 2.19)), efficiency_alpha=float(raw_cfg.get("efficiency_alpha", 2.1159)),
safety_beta=float(raw_cfg.get("safety_beta", 9.19)), safety_beta=float(raw_cfg.get("safety_beta", 7.8553)),
efficiency_exponent=float(raw_cfg.get("efficiency_exponent", 0.50)), efficiency_exponent=float(raw_cfg.get("efficiency_exponent", 0.50)),
safety_exponent=float(raw_cfg.get("safety_exponent", 0.50)), safety_exponent=float(raw_cfg.get("safety_exponent", 0.50)),
ttc_threshold_s=float(raw_cfg.get("ttc_threshold_s", 2.3)), ttc_threshold_s=float(raw_cfg.get("ttc_threshold_s", 2.3)),

View File

@ -30,6 +30,7 @@ EPS = 1e-6
BUILD_LOCK_TIMEOUT_S = 300.0 BUILD_LOCK_TIMEOUT_S = 300.0
BUILD_LOCK_STALE_S = 900.0 BUILD_LOCK_STALE_S = 900.0
BUILD_LOCK_POLL_S = 0.2 BUILD_LOCK_POLL_S = 0.2
DERIVED_ASSET_VERSION = 2
@dataclass @dataclass
@ -191,6 +192,7 @@ def _build_signature(
detector_start_offset_m: float, detector_start_offset_m: float,
) -> str: ) -> str:
payload = { payload = {
"derived_asset_version": DERIVED_ASSET_VERSION,
"net_file": str(net_path), "net_file": str(net_path),
"net_mtime_ns": net_path.stat().st_mtime_ns, "net_mtime_ns": net_path.stat().st_mtime_ns,
"route_file": str(route_path), "route_file": str(route_path),
@ -206,6 +208,28 @@ def _build_signature(
return digest[:16] return digest[:16]
def _lane_permission_tokens(lane: sumolib.net.lane.Lane) -> set[str]:
permissions = lane.getPermissions()
if permissions is None:
return set()
if isinstance(permissions, str):
return {token for token in permissions.split() if token}
return {str(token).strip() for token in permissions if str(token).strip()}
def _is_emergency_only_lane(lane: sumolib.net.lane.Lane) -> bool:
return _lane_permission_tokens(lane) == {"emergency"}
def _get_traffic_lane_indices(edge: sumolib.net.edge.Edge) -> List[int]:
traffic_lane_indices = [
lane.getIndex() for lane in edge.getLanes() if not _is_emergency_only_lane(lane)
]
if traffic_lane_indices:
return traffic_lane_indices
return [lane.getIndex() for lane in edge.getLanes()]
def _load_ready_corridor_artifacts( def _load_ready_corridor_artifacts(
manifest_path: Path, manifest_path: Path,
project_root: Path, project_root: Path,
@ -756,13 +780,7 @@ def _build_detector_additional(
continue continue
edge = derived_net.getEdge(edge_range["edge_id"]) edge = derived_net.getEdge(edge_range["edge_id"])
traffic_lane_indices = [ traffic_lane_indices = _get_traffic_lane_indices(edge)
lane.getIndex()
for lane in edge.getLanes()
if "emergency" not in lane.getPermissions()
]
if not traffic_lane_indices:
traffic_lane_indices = [lane.getIndex() for lane in edge.getLanes()]
local_position = global_distance - edge_range["start_m"] local_position = global_distance - edge_range["start_m"]
edge_pos_index = per_edge_pos_index.get(edge_range["edge_id"], 0) edge_pos_index = per_edge_pos_index.get(edge_range["edge_id"], 0)