src/TrafficCoordinator.py
def new_batch_intersection_FCFS(self):
        """Takes the queue of reservation requests and returns a list of return
        reservations.  
        
        1. Ensures that lane queues are up-to-date with cars and existing reservations
        2. For each request, forward simulate car trajectory and check for conflicts in reservation-matrix
        3. If no conflict, add reservation.  Else, repeat 10 times with offset.
        4. Set reservation for each agent from final list of reservations 
        """

        self.lane_queues = self.update_lane_queues(self.lane_queues)  # Make sure lane queue is up-to-date (subroutine?)
        
        # #3/4 edition
        # new_queue = []
        # for bid, requested_start_time, end_time, intersection_lane, agentID, current_car in self.bid_queue:
        #     bid = self.time - current_car.time_entered_control 
        #     new_queue += [(bid, requested_start_time, end_time, intersection_lane, agentID, current_car)]            
        # self.bid_queue = new_queue
        # self.sorted_queue = self.sort_queue(self.bid_queue,"FCFS")

        # ### 3/4 Edition

        final_reservations = []
        
        self.car_ids_with_reservation = set()  #TODO: Is this the right thing to have?
        
        # previous_priority_car_time_entered_control = 0.0 #TODO THIS NEEDS TO GET INFO
        for bid, requested_start_time, end_time, intersection_lane, agent_id, current_car in self.sorted_queue:
            if agent_id in self.car_ids_with_reservation: continue  # Agent already received reservation, maybe we don't need this
            if len(self.lane_queues[current_car.current_lane]) > self.k_max_cars_planning_lane_FCFS: break
            
            time_car_can_enter_intersection = self.get_intersection_available_for_car(current_car.current_lane, current_car, self.lane_queues)
            
            reservation_window_start_time, self.time_matrix_intervals, self.time_available_matrix = self.attempt_reservation(time_car_can_enter_intersection, intersection_lane, current_car, agent_id, self.time_matrix_intervals, self.time_available_matrix)
            
            if reservation_window_start_time < 0:  
                break
            else:
                final_reservations += [(reservation_window_start_time,100000)]
                time_intersection_entrance_free = self.get_intersection_entrance_free_time(current_car.current_lane, self.time_available_matrix)
                self.lane_queues[current_car.current_lane] += [(current_car, time_intersection_entrance_free)] #TODO:  This needs to be when I'm out of the control region
                current_car.intersection_window = (reservation_window_start_time, 100000)        

                self.car_ids_with_reservation.add(agent_id)
        self.bid_queue = []   
        return final_reservations
Takes the queue of reservation requests and returns a list of return
        reservations.  
        
        1. Ensures that lane queues are up-to-date with cars and existing reservations
        2. For each request, forward simulate car trajectory and check for conflicts in reservation-matrix
        3. If no conflict, add reservation.  Else, repeat 10 times with offset.
        4. Set reservation for each agent from final list of reservations 
        
Takes the queue of reservation requests and returns a list of return
reservations.

1. Ensures that lane queues are up-to-date with cars and existing reservations
2. For each request, forward simulate car trajectory and check for conflicts in reservation-matrix
3. If no conflict, add reservation.  Else, repeat 10 times with offset.
4. Set reservation for each agent from final list of reservations
Takes the queue of reservation requests and returns a list of return reservations . 1 . Ensures that lane queues are up - to - date with cars and existing reservations 2 . For each request forward simulate car trajectory and check for conflicts in reservation - matrix 3 . If no conflict add reservation . Else repeat 10 times with offset . 4 . Set reservation for each agent from final list of reservations
def new_batch_intersection_FCFS(self):
        self.lane_queues = self.update_lane_queues(self.lane_queues)  
        final_reservations = []
        self.car_ids_with_reservation = set()  
        for bid, requested_start_time, end_time, intersection_lane, agent_id, current_car in self.sorted_queue:
            if agent_id in self.car_ids_with_reservation: continue  
            if len(self.lane_queues[current_car.current_lane]) > self.k_max_cars_planning_lane_FCFS: break
            time_car_can_enter_intersection = self.get_intersection_available_for_car(current_car.current_lane, current_car, self.lane_queues)
            reservation_window_start_time, self.time_matrix_intervals, self.time_available_matrix = self.attempt_reservation(time_car_can_enter_intersection, intersection_lane, current_car, agent_id, self.time_matrix_intervals, self.time_available_matrix)
            if reservation_window_start_time < 0:  
                break
            else:
                final_reservations += [(reservation_window_start_time,100000)]
                time_intersection_entrance_free = self.get_intersection_entrance_free_time(current_car.current_lane, self.time_available_matrix)
                self.lane_queues[current_car.current_lane] += [(current_car, time_intersection_entrance_free)] 
                current_car.intersection_window = (reservation_window_start_time, 100000)        
                self.car_ids_with_reservation.add(agent_id)
        self.bid_queue = []   
        return final_reservations
def new_batch_intersection_FCFS ( self ) : self . lane_queues = self . update_lane_queues ( self . lane_queues ) final_reservations = [ ] self . car_ids_with_reservation = set ( ) for bid , requested_start_time , end_time , intersection_lane , agent_id , current_car in self . sorted_queue : if agent_id in self . car_ids_with_reservation : continue if len ( self . lane_queues [ current_car . current_lane ] ) > self . k_max_cars_planning_lane_FCFS : break time_car_can_enter_intersection = self . get_intersection_available_for_car ( current_car . current_lane , current_car , self . lane_queues ) reservation_window_start_time , self . time_matrix_intervals , self . time_available_matrix = self . attempt_reservation ( time_car_can_enter_intersection , intersection_lane , current_car , agent_id , self . time_matrix_intervals , self . time_available_matrix ) if reservation_window_start_time < 0 : break else : final_reservations += [ ( reservation_window_start_time , 100000 ) ] time_intersection_entrance_free = self . get_intersection_entrance_free_time ( current_car . current_lane , self . time_available_matrix ) self . lane_queues [ current_car . current_lane ] += [ ( current_car , time_intersection_entrance_free ) ] current_car . intersection_window = ( reservation_window_start_time , 100000 ) self . car_ids_with_reservation . add ( agent_id ) self . bid_queue = [ ] return final_reservations
Takes the queue of reservation requests and returns a list of return
reservations.
Takes the queue of reservation requests and returns a list of return reservations .
"""Takes the queue of reservation requests and returns a list of return
        reservations.  
        
        1. Ensures that lane queues are up-to-date with cars and existing reservations
        2. For each request, forward simulate car trajectory and check for conflicts in reservation-matrix
        3. If no conflict, add reservation.  Else, repeat 10 times with offset.
        4. Set reservation for each agent from final list of reservations 
        """ # Make sure lane queue is up-to-date (subroutine?) # #3/4 edition # new_queue = [] # for bid, requested_start_time, end_time, intersection_lane, agentID, current_car in self.bid_queue: #     bid = self.time - current_car.time_entered_control  #     new_queue += [(bid, requested_start_time, end_time, intersection_lane, agentID, current_car)]             # self.bid_queue = new_queue # self.sorted_queue = self.sort_queue(self.bid_queue,"FCFS") # ### 3/4 Edition #TODO: Is this the right thing to have? # previous_priority_car_time_entered_control = 0.0 #TODO THIS NEEDS TO GET INFO # Agent already received reservation, maybe we don't need this #TODO:  This needs to be when I'm out of the control region
self