src/TrafficCoordinator.py
def attempt_reservation(self, requested_start_time, intersection_lane, current_car, agent_id, time_matrix_intervals, time_available_matrix, last_entry_time=-1):
        ''' Attempts to reserve the interesection for entering at car_intersection_start_time.  Returns True/False depending on whether it is possible.'''
        new_time_matrix_intervals = copy.deepcopy(time_matrix_intervals)
        new_time_available_matrix = copy.deepcopy(time_available_matrix) 
        current_reservation_attempt = 0
        reservation_start_time = requested_start_time
        # if last_entry_time > 0:
        #     reservation_start_time = last_entry_time # You need to start after the last entry
        while current_reservation_attempt < self.k_max_retries:
            intersection_points_to_reserve = self.calculate_reservation(reservation_start_time, intersection_lane, current_car, agent_id, new_time_matrix_intervals)

            if len(intersection_points_to_reserve) > 0:
                new_time_matrix_intervals, new_time_available_matrix = self.add_points_to_reservation_matrix(intersection_points_to_reserve, agent_id, new_time_matrix_intervals, new_time_available_matrix) #I'm adding a fixed buffer size
                # time_matrix_intervals, time_available_matrix = self.set_reservation(intersection_points_to_reserve, agent_id, current_car, reservation_start_time, time_matrix_intervals, time_available_matrix)
                return reservation_start_time, new_time_matrix_intervals, new_time_available_matrix
            else:
                current_reservation_attempt += 1
            reservation_start_time +=  self.k_replan_increment_sec  #TODO: THIS SHOULD PROBABLY HAPPEN ELSEWHERE?
        self.agents_last_attempted_reservation[agent_id] = reservation_start_time
        print("RetryMaxOut: Car %d, Tried up to starting @ t %.03f"%(agent_id,reservation_start_time))
        return -1, new_time_matrix_intervals, new_time_available_matrix
 Attempts to reserve the interesection for entering at car_intersection_start_time.  Returns True/False depending on whether it is possible.
Attempts to reserve the interesection for entering at car_intersection_start_time.  Returns True/False depending on whether it is possible.
Attempts to reserve the interesection for entering at car_intersection_start_time . Returns True / False depending on whether it is possible .
def attempt_reservation(self, requested_start_time, intersection_lane, current_car, agent_id, time_matrix_intervals, time_available_matrix, last_entry_time=-1):
        new_time_matrix_intervals = copy.deepcopy(time_matrix_intervals)
        new_time_available_matrix = copy.deepcopy(time_available_matrix) 
        current_reservation_attempt = 0
        reservation_start_time = requested_start_time
        while current_reservation_attempt < self.k_max_retries:
            intersection_points_to_reserve = self.calculate_reservation(reservation_start_time, intersection_lane, current_car, agent_id, new_time_matrix_intervals)
            if len(intersection_points_to_reserve) > 0:
                new_time_matrix_intervals, new_time_available_matrix = self.add_points_to_reservation_matrix(intersection_points_to_reserve, agent_id, new_time_matrix_intervals, new_time_available_matrix) 
                return reservation_start_time, new_time_matrix_intervals, new_time_available_matrix
            else:
                current_reservation_attempt += 1
            reservation_start_time +=  self.k_replan_increment_sec  
        self.agents_last_attempted_reservation[agent_id] = reservation_start_time
        print("RetryMaxOut: Car %d, Tried up to starting @ t %.03f"%(agent_id,reservation_start_time))
        return -1, new_time_matrix_intervals, new_time_available_matrix
def attempt_reservation ( self , requested_start_time , intersection_lane , current_car , agent_id , time_matrix_intervals , time_available_matrix , last_entry_time = - 1 ) : new_time_matrix_intervals = copy . deepcopy ( time_matrix_intervals ) new_time_available_matrix = copy . deepcopy ( time_available_matrix ) current_reservation_attempt = 0 reservation_start_time = requested_start_time while current_reservation_attempt < self . k_max_retries : intersection_points_to_reserve = self . calculate_reservation ( reservation_start_time , intersection_lane , current_car , agent_id , new_time_matrix_intervals ) if len ( intersection_points_to_reserve ) > 0 : new_time_matrix_intervals , new_time_available_matrix = self . add_points_to_reservation_matrix ( intersection_points_to_reserve , agent_id , new_time_matrix_intervals , new_time_available_matrix ) return reservation_start_time , new_time_matrix_intervals , new_time_available_matrix else : current_reservation_attempt += 1 reservation_start_time += self . k_replan_increment_sec self . agents_last_attempted_reservation [ agent_id ] = reservation_start_time print ( "RetryMaxOut: Car %d, Tried up to starting @ t %.03f" % ( agent_id , reservation_start_time ) ) return - 1 , new_time_matrix_intervals , new_time_available_matrix
Attempts to reserve the interesection for entering at car_intersection_start_time.
Attempts to reserve the interesection for entering at car_intersection_start_time .
''' Attempts to reserve the interesection for entering at car_intersection_start_time.  Returns True/False depending on whether it is possible.''' # if last_entry_time > 0: #     reservation_start_time = last_entry_time # You need to start after the last entry #I'm adding a fixed buffer size # time_matrix_intervals, time_available_matrix = self.set_reservation(intersection_points_to_reserve, agent_id, current_car, reservation_start_time, time_matrix_intervals, time_available_matrix) #TODO: THIS SHOULD PROBABLY HAPPEN ELSEWHERE?
self
requested_start_time
intersection_lane
current_car
agent_id
time_matrix_intervals
time_available_matrix
last_entry_time