src/TrafficCoordinator.py
def attempt_two_reservations(self, first_request, second_request):
        '''
        First request, find when the intersection is available for car and then reserve the intersection for that time. 
        Repeat w/ second request, using the (updated) reservation matrices which now include the first request.
        If either request fails, return -1, -1, ... -1
        If both request succeed, return the utilities for both reservations, both reservations, and the updated queues/matrices
        '''
        lane_queues = self.copy_queues(self.lane_queues)
        (bid1, requested_start_time1, end_time1, intersection_lane1, agent_id1, current_car1) = first_request
        (bid2, requested_start_time2, end_time2, intersection_lane2, agent_id2, current_car2) = second_request

        t_enter_intersection_car1 = self.get_intersection_available_for_car(current_car1.current_lane, current_car1, lane_queues, self.strict_priority)
        start_time_1, t_interval_matrix_after_reservation1, t_available_matrix_after_reservation1 = self.attempt_reservation(t_enter_intersection_car1, intersection_lane1, current_car1, agent_id1, self.time_matrix_intervals, self.time_available_matrix)
        if start_time_1 < 0 or start_time_1 > self.time + 45.0: #NOTE THIS IS RISKY BUSINESS
            # print("Couldn't find reservation for 1")
            return -1, -1, -1, -1, -1, -1, -1
            pass
        else:
            time_intersection_entrance_free = self.get_intersection_entrance_free_time(current_car1.current_lane, t_available_matrix_after_reservation1)
            lane_queues[current_car1.current_lane] += [(current_car1, time_intersection_entrance_free)] #TODO:  This needs to be when I'm out of the control region

        time_car2_can_enter_intersection = self.get_intersection_available_for_car(current_car2.current_lane, current_car2, lane_queues, self.strict_priority)
        start_time_2, fake_interval_matrix_after2, fake_available_matrixafter2 = self.attempt_reservation(time_car2_can_enter_intersection, intersection_lane2, current_car2, agent_id2, t_interval_matrix_after_reservation1, t_available_matrix_after_reservation1)  


        if start_time_2 < 0:
            # print("Couldn't find reservation for 2")
            return -1, -1, -1, -1, -1, -1, -1
        else:
            time_intersection_entrance_free = self.get_intersection_entrance_free_time(current_car2.current_lane, fake_available_matrixafter2)
            # fake_lane_queues[current_car2.current_lane] += [(current_car2, time_intersection_entrance_free)] #TODO:  This needs to be when I'm out of the control region
        if self.svo_squared:
            utility1 = self.get_svo_utility_squared(start_time_1, start_time_2, current_car1, current_car2) 
            utility2 = self.get_svo_utility_squared(start_time_2, start_time_1, current_car2, current_car1) 
        else:
            utility1 = self.get_svo_utility(start_time_1, start_time_2, current_car1, current_car2) 
            utility2 = self.get_svo_utility(start_time_2, start_time_1, current_car2, current_car1) 
        return utility1, utility2, start_time_1, start_time_2, t_interval_matrix_after_reservation1, t_available_matrix_after_reservation1, lane_queues

        First request, find when the intersection is available for car and then reserve the intersection for that time. 
        Repeat w/ second request, using the (updated) reservation matrices which now include the first request.
        If either request fails, return -1, -1, ... -1
        If both request succeed, return the utilities for both reservations, both reservations, and the updated queues/matrices
        
First request, find when the intersection is available for car and then reserve the intersection for that time.
Repeat w/ second request, using the (updated) reservation matrices which now include the first request.
If either request fails, return -1, -1, ... -1
If both request succeed, return the utilities for both reservations, both reservations, and the updated queues/matrices
First request find when the intersection is available for car and then reserve the intersection for that time . Repeat w / second request using the ( updated ) reservation matrices which now include the first request . If either request fails return - 1 - 1 ... - 1 If both request succeed return the utilities for both reservations both reservations and the updated queues / matrices
def attempt_two_reservations(self, first_request, second_request):
        lane_queues = self.copy_queues(self.lane_queues)
        (bid1, requested_start_time1, end_time1, intersection_lane1, agent_id1, current_car1) = first_request
        (bid2, requested_start_time2, end_time2, intersection_lane2, agent_id2, current_car2) = second_request
        t_enter_intersection_car1 = self.get_intersection_available_for_car(current_car1.current_lane, current_car1, lane_queues, self.strict_priority)
        start_time_1, t_interval_matrix_after_reservation1, t_available_matrix_after_reservation1 = self.attempt_reservation(t_enter_intersection_car1, intersection_lane1, current_car1, agent_id1, self.time_matrix_intervals, self.time_available_matrix)
        if start_time_1 < 0 or start_time_1 > self.time + 45.0: 
            return -1, -1, -1, -1, -1, -1, -1
            pass
        else:
            time_intersection_entrance_free = self.get_intersection_entrance_free_time(current_car1.current_lane, t_available_matrix_after_reservation1)
            lane_queues[current_car1.current_lane] += [(current_car1, time_intersection_entrance_free)] 
        time_car2_can_enter_intersection = self.get_intersection_available_for_car(current_car2.current_lane, current_car2, lane_queues, self.strict_priority)
        start_time_2, fake_interval_matrix_after2, fake_available_matrixafter2 = self.attempt_reservation(time_car2_can_enter_intersection, intersection_lane2, current_car2, agent_id2, t_interval_matrix_after_reservation1, t_available_matrix_after_reservation1)  
        if start_time_2 < 0:
            return -1, -1, -1, -1, -1, -1, -1
        else:
            time_intersection_entrance_free = self.get_intersection_entrance_free_time(current_car2.current_lane, fake_available_matrixafter2)
            # fake_lane_queues[current_car2.current_lane] += [(current_car2, time_intersection_entrance_free)] 
        if self.svo_squared:
            utility1 = self.get_svo_utility_squared(start_time_1, start_time_2, current_car1, current_car2) 
            utility2 = self.get_svo_utility_squared(start_time_2, start_time_1, current_car2, current_car1) 
        else:
            utility1 = self.get_svo_utility(start_time_1, start_time_2, current_car1, current_car2) 
            utility2 = self.get_svo_utility(start_time_2, start_time_1, current_car2, current_car1) 
        return utility1, utility2, start_time_1, start_time_2, t_interval_matrix_after_reservation1, t_available_matrix_after_reservation1, lane_queues
def attempt_two_reservations ( self , first_request , second_request ) : lane_queues = self . copy_queues ( self . lane_queues ) ( bid1 , requested_start_time1 , end_time1 , intersection_lane1 , agent_id1 , current_car1 ) = first_request ( bid2 , requested_start_time2 , end_time2 , intersection_lane2 , agent_id2 , current_car2 ) = second_request t_enter_intersection_car1 = self . get_intersection_available_for_car ( current_car1 . current_lane , current_car1 , lane_queues , self . strict_priority ) start_time_1 , t_interval_matrix_after_reservation1 , t_available_matrix_after_reservation1 = self . attempt_reservation ( t_enter_intersection_car1 , intersection_lane1 , current_car1 , agent_id1 , self . time_matrix_intervals , self . time_available_matrix ) if start_time_1 < 0 or start_time_1 > self . time + 45.0 : return - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 pass else : time_intersection_entrance_free = self . get_intersection_entrance_free_time ( current_car1 . current_lane , t_available_matrix_after_reservation1 ) lane_queues [ current_car1 . current_lane ] += [ ( current_car1 , time_intersection_entrance_free ) ] time_car2_can_enter_intersection = self . get_intersection_available_for_car ( current_car2 . current_lane , current_car2 , lane_queues , self . strict_priority ) start_time_2 , fake_interval_matrix_after2 , fake_available_matrixafter2 = self . attempt_reservation ( time_car2_can_enter_intersection , intersection_lane2 , current_car2 , agent_id2 , t_interval_matrix_after_reservation1 , t_available_matrix_after_reservation1 ) if start_time_2 < 0 : return - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 else : time_intersection_entrance_free = self . get_intersection_entrance_free_time ( current_car2 . current_lane , fake_available_matrixafter2 ) if self . svo_squared : utility1 = self . get_svo_utility_squared ( start_time_1 , start_time_2 , current_car1 , current_car2 ) utility2 = self . get_svo_utility_squared ( start_time_2 , start_time_1 , current_car2 , current_car1 ) else : utility1 = self . get_svo_utility ( start_time_1 , start_time_2 , current_car1 , current_car2 ) utility2 = self . get_svo_utility ( start_time_2 , start_time_1 , current_car2 , current_car1 ) return utility1 , utility2 , start_time_1 , start_time_2 , t_interval_matrix_after_reservation1 , t_available_matrix_after_reservation1 , lane_queues
First request, find when the intersection is available for car and then reserve the intersection for that time.
First request find when the intersection is available for car and then reserve the intersection for that time .
'''
        First request, find when the intersection is available for car and then reserve the intersection for that time. 
        Repeat w/ second request, using the (updated) reservation matrices which now include the first request.
        If either request fails, return -1, -1, ... -1
        If both request succeed, return the utilities for both reservations, both reservations, and the updated queues/matrices
        ''' #NOTE THIS IS RISKY BUSINESS # print("Couldn't find reservation for 1") #TODO:  This needs to be when I'm out of the control region # print("Couldn't find reservation for 2") # fake_lane_queues[current_car2.current_lane] += [(current_car2, time_intersection_entrance_free)] #TODO:  This needs to be when I'm out of the control region
self
first_request
second_request