| | |
| | | StationTrafficSnapshot trafficSnapshot, |
| | | LoopMergeGuardContext loopMergeGuardContext, |
| | | Set<LoopMergeEntry> mandatoryLoopMergeEntrySet) { |
| | | if (path == null || path.size() < 2 || loopMergeGuardContext == null || loopMergeGuardContext.loopStationIdSet.isEmpty()) { |
| | | return true; |
| | | } |
| | | |
| | | List<Integer> stationIdList = extractStationIdList(path); |
| | | if (stationIdList.size() < 2) { |
| | | return true; |
| | | } |
| | | |
| | | for (int i = 1; i < stationIdList.size(); i++) { |
| | | Integer prevStationId = stationIdList.get(i - 1); |
| | | Integer currentStationId = stationIdList.get(i); |
| | | if (prevStationId == null || currentStationId == null) { |
| | | continue; |
| | | } |
| | | if (loopMergeGuardContext.loopStationIdSet.contains(prevStationId) |
| | | || !loopMergeGuardContext.loopStationIdSet.contains(currentStationId)) { |
| | | continue; |
| | | } |
| | | |
| | | Set<Integer> trunkNeighborSet = loopMergeGuardContext.loopNeighborMap.getOrDefault(currentStationId, Collections.emptySet()); |
| | | if (trunkNeighborSet.size() < 2) { |
| | | continue; |
| | | } |
| | | |
| | | LoopMergeEntry currentEntry = new LoopMergeEntry(prevStationId, currentStationId); |
| | | for (Integer trunkNeighborStationId : trunkNeighborSet) { |
| | | if (isStationOccupiedForLoopMerge(trunkNeighborStationId, statusMap, trafficSnapshot)) { |
| | | return false; |
| | | } |
| | | } |
| | | boolean mandatoryEntry = mandatoryLoopMergeEntrySet != null && mandatoryLoopMergeEntrySet.contains(currentEntry); |
| | | if (!mandatoryEntry && !isLoopTrunkVeryIdle(currentStationId, loopMergeGuardContext, statusMap, trafficSnapshot)) { |
| | | return false; |
| | | } |
| | | } |
| | | // 环线并入保护已停用:允许候选路径直接参与后续评分。 |
| | | return true; |
| | | } |
| | | |