博主简介:擅长数据搜集与处理、建模仿真、程序设计、仿真代码、论文写作与指导,毕业论文、期刊论文经验交流。

 ✅成品或者定制,扫描文章底部微信二维码。


实践证明,随着自动驾驶技术的越来越成熟,为了更好地发挥自动驾驶汽车的效用,有人论述来修建自动驾驶汽车专用车道。基于此,修建自动驾驶车道的方式主要有新建或者利用其他专用车道。与此同时,本研究提出了自动驾驶汽车借道BRT专用车道行驶的方法。本研究首先使用元胞自动机模型,深入分析自动驾驶汽车和普通人工驾驶汽车的混合交通流问题,对自动驾驶汽车和普通人工驾驶汽车设置了不同的规则,通过时空图、流量密度图展示了自动车占比的变化对交通的影响,发现百分之百是自动驾驶汽车时,道路上的交通明显更畅通,通行能力更大,随着普通人工驾驶汽车占比的增加,通行能力降低,走停现象开始变得明显,自动驾驶汽车也很难发挥出自身优势。还考虑到了自动驾驶出现检测误差,人类驾驶出现判断误差的情形,研究了这种情况下的通行能力变化。

在此基础上,之后尝试设置自动驾驶专用车道,发现在自动驾驶汽车占比较低时另外设置专用车道反而造成了一部分资源的浪费,这部分的结论为后文研究自动驾驶专用车道奠定了基础。在自动驾驶汽车占比较低时可以采取自动驾驶汽车借道其他专用车道行驶的方式作为过渡,
本文基于此分析了自动驾驶汽车借道BRT车道行驶时的干线协调控制和运行效率问题。干线协调采用遗传算法进行配时方案的优化,以总延误作为目标函数,将干线自动驾驶汽车的占比分成10%、30%、37.5%、60%四种情况,将道路设置方式分为两种,场景一为自动驾驶汽车在BRT专用车道上行驶,场景二为自动驾驶汽车在普通人工驾驶汽车道上行驶。分析发现,不论自动驾驶汽车占比如何,场景二的总延误一直是最高的,在自动车占比为30%时场景一的延误最小,此时允许自动驾驶汽车到BRT车道上行驶的效果最好。

这说明了在自动驾驶汽车占比较低时,允许自动驾驶汽车借道BRT专用车道行驶是一种很好的过渡方式。

 

仿真代码

import numpy as np
from collections import deque

class PedestrianSignalOptimization:
    def __init__(self):
        self.min_pedestrian_green = 7
        self.walking_speed = 1.2
        self.perception_reaction_time = 3
       
    def calculate_pedestrian_clearance_time(self, crosswalk_width):
        clearance_time = self.perception_reaction_time + (crosswalk_width / self.walking_speed)
        return np.ceil(clearance_time)
   
    def webster_pedestrian_timing(self, ped_flow, veh_flow, crosswalk_width):
        total_lost_time = 12
        optimal_cycle = (1.5 * total_lost_time + 5) / (1 - (ped_flow + veh_flow) / 3600)
        optimal_cycle = min(max(optimal_cycle, 60), 150)
       
        clearance = self.calculate_pedestrian_clearance_time(crosswalk_width)
       
        ped_green = max(self.min_pedestrian_green, clearance)
        veh_green = optimal_cycle - ped_green - total_lost_time
       
        return {
            'cycle_length': optimal_cycle,
            'pedestrian_green': ped_green,
            'vehicle_green': veh_green,
            'clearance_time': clearance
        }
   
    def calculate_pedestrian_delay(self, arrival_rate, green_time, cycle_length):
        red_time = cycle_length - green_time
       
        capacity = 3600 / cycle_length
       
        if arrival_rate < capacity:
            avg_delay = (red_time ** 2) / (2 * cycle_length)
        else:
            avg_delay = red_time + (arrival_rate - capacity) * 3600 / arrival_rate
       
        return avg_delay
   
    def pedestrian_vehicle_conflict_analysis(self, ped_volume, veh_right_turn, crosswalk_width):
        conflict_rate = (ped_volume / 3600) * (veh_right_turn / 3600)
       
        severity_factor = 1 + (crosswalk_width - 3) * 0.1
       
        conflict_points = conflict_rate * severity_factor * 3600
       
        return conflict_points
   
    def exclusive_pedestrian_phase_decision(self, ped_volume, veh_volume, right_turn_volume):
        ped_vehicle_ratio = ped_volume / (veh_volume + 1)
       
        conflict_severity = right_turn_volume / (veh_volume + 1)
       
        if ped_vehicle_ratio > 0.3 and conflict_severity > 0.4:
            return True
        elif ped_volume > 500 and right_turn_volume > 300:
            return True
        else:
            return False

def pedestrian_actuation_control(button_press_times, max_wait=90):
    if not button_press_times:
        return None
   
    current_time = button_press_times[-1]
    earliest_press = button_press_times[0]
   
    wait_time = current_time - earliest_press
   
    num_requests = len(button_press_times)
   
    if wait_time > max_wait:
        return 'immediate_service'
    elif num_requests >= 5:
        return 'accelerated_service'
    else:
        return 'normal_service'

def pedestrian_countdown_timing(total_crossing_time, flash_duration=5):
    solid_walk = total_crossing_time - flash_duration
   
    if solid_walk < 7:
        solid_walk = 7
        flash_duration = max(total_crossing_time - 7, 3)
   
    return {
        'solid_walk': solid_walk,
        'flashing_dont_walk': flash_duration,
        'total_crossing_time': solid_walk + flash_duration
    }

def elderly_friendly_timing_adjustment(standard_timing, elderly_percentage):
    adjustment_factor = 1 + (elderly_percentage / 100) * 0.3
   
    adjusted_timing = {
        'pedestrian_green': standard_timing['pedestrian_green'] * adjustment_factor,
        'clearance_time': standard_timing['clearance_time'] * adjustment_factor
    }
   
    adjusted_timing['cycle_length'] = (standard_timing['cycle_length'] -
                                       standard_timing['pedestrian_green'] +
                                       adjusted_timing['pedestrian_green'])
   
    return adjusted_timing

def diagonal_crossing_timing(intersection_diagonal, walking_speed=1.0):
    crossing_time = intersection_diagonal / walking_speed
   
    perception_reaction = 5
   
    total_time = crossing_time + perception_reaction
   
    return np.ceil(total_time)

def pedestrian_phase_sequencing(ped_demands, phase_capacity):
    sequences = []
   
    sorted_demands = sorted(ped_demands.items(), key=lambda x: x[1], reverse=True)
   
    current_sequence = []
    current_load = 0
   
    for crossing, demand in sorted_demands:
        if current_load + demand <= phase_capacity:
            current_sequence.append(crossing)
            current_load += demand
        else:
            if current_sequence:
                sequences.append(current_sequence)
            current_sequence = [crossing]
            current_load = demand
   
    if current_sequence:
        sequences.append(current_sequence)
   
    return sequences

def adaptive_pedestrian_detection(detection_zones, occupancy_threshold=0.3):
    active_zones = []
   
    for zone_id, occupancy in detection_zones.items():
        if occupancy > occupancy_threshold:
            active_zones.append(zone_id)
   
    if len(active_zones) >= 2:
        priority = 'high'
    elif len(active_zones) == 1:
        priority = 'medium'
    else:
        priority = 'low'
   
    return {
        'active_zones': active_zones,
        'priority': priority,
        'num_active': len(active_zones)
    }

def pedestrian_green_extension(initial_green, detected_pedestrians, max_extension=15):
    base_time_per_ped = 2
   
    additional_time = detected_pedestrians * base_time_per_ped
   
    extension = min(additional_time, max_extension)
   
    total_green = initial_green + extension
   
    return total_green

def multi_phase_pedestrian_optimization(crossings_data):
    num_crossings = len(crossings_data)
   
    phase_plan = []
   
    for i, crossing in enumerate(crossings_data):
        phase = {
            'crossing_id': i,
            'green_time': max(7, crossing['required_time']),
            'demand': crossing['pedestrian_demand'],
            'start_time': sum([p['green_time'] + 4 for p in phase_plan])
        }
        phase_plan.append(phase)
   
    total_cycle = sum([p['green_time'] + 4 for p in phase_plan])
   
    return phase_plan, total_cycle

def safety_performance_evaluation(conflict_data, volume_data):
    total_conflicts = sum(conflict_data.values())
    total_volume = sum(volume_data.values())
   
    if total_volume > 0:
        conflict_rate = total_conflicts / total_volume * 1000
    else:
        conflict_rate = 0
   
    if conflict_rate < 2:
        safety_level = 'excellent'
    elif conflict_rate < 5:
        safety_level = 'good'
    elif conflict_rate < 10:
        safety_level = 'fair'
    else:
        safety_level = 'poor'
   
    return {
        'conflict_rate': conflict_rate,
        'safety_level': safety_level,
        'total_conflicts': total_conflicts
    }

def main():
    pso = PedestrianSignalOptimization()
   
    crosswalk_width = 12
    clearance = pso.calculate_pedestrian_clearance_time(crosswalk_width)
    print(f"Required Clearance Time: {clearance:.1f} seconds")
   
    ped_flow = 400
    veh_flow = 800
    timing = pso.webster_pedestrian_timing(ped_flow, veh_flow, crosswalk_width)
   
    print(f"\nWebster Method Timing:")
    print(f"Cycle Length: {timing['cycle_length']:.1f}s")
    print(f"Pedestrian Green: {timing['pedestrian_green']:.1f}s")
    print(f"Vehicle Green: {timing['vehicle_green']:.1f}s")
   
    ped_delay = pso.calculate_pedestrian_delay(400, 25, 120)
    print(f"\nAverage Pedestrian Delay: {ped_delay:.2f} seconds")
   
    conflicts = pso.pedestrian_vehicle_conflict_analysis(300, 150, 10)
    print(f"Estimated Conflict Points per Hour: {conflicts:.1f}")
   
    needs_exclusive = pso.exclusive_pedestrian_phase_decision(500, 800, 350)
    print(f"Exclusive Pedestrian Phase Needed: {needs_exclusive}")
   
    button_presses = [0, 15, 25, 35, 42, 48]
    service_type = pedestrian_actuation_control(button_presses)
    print(f"\nActuation Control Decision: {service_type}")
   
    countdown = pedestrian_countdown_timing(20)
    print(f"Countdown Timing: {countdown}")
    
    elderly_adjusted = elderly_friendly_timing_adjustment(timing, 30)
    print(f"\nElderly-Adjusted Timing:")
    print(f"Pedestrian Green: {elderly_adjusted['pedestrian_green']:.1f}s")
   
    crossings_data = [
        {'required_time': 12, 'pedestrian_demand': 300},
        {'required_time': 15, 'pedestrian_demand': 450},
        {'required_time': 10, 'pedestrian_demand': 200},
        {'required_time': 18, 'pedestrian_demand': 350}
    ]
   
    phase_plan, cycle = multi_phase_pedestrian_optimization(crossings_data)
    print(f"\nMulti-Phase Optimization:")
    print(f"Total Cycle Length: {cycle:.1f}s")
    for phase in phase_plan:
        print(f"Crossing {phase['crossing_id']}: Green={phase['green_time']:.1f}s, Start={phase['start_time']:.1f}s")

if __name__ == "__main__":
    main()
 

 


如有问题,可以直接沟通

👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇

Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐