src/TrafficCoordinator.py
def sort_and_break_ties_id(self, bid_queue, epsilon_bid = -1):
        ''' Sort of list of bids, find the ties, and sort by agent_id'''
        if epsilon_bid == -1:
            epsilon_bid = self.k_epsilon_bid
        
        sorted_queue_by_bids = sorted(bid_queue, key=lambda b: -b[0])
        final_sorted_queue_id_tiebreaker = []

        previous_bid_value = -999999
        previous_tied_bids = []
        for current_bid in sorted_queue_by_bids:
            if abs(current_bid[0]-previous_bid_value) <= epsilon_bid:
                previous_tied_bids += [current_bid]
            else:
                ''' Sort the previously tied bids and use the agent id as the sorting key''' 
                if len(previous_tied_bids) > 0:
                    sorted_bids_by_agent_id = sorted(previous_tied_bids, key=lambda b: b[-1].agent_id)
                    final_sorted_queue_id_tiebreaker += sorted_bids_by_agent_id
                previous_tied_bids = [current_bid]
                previous_bid_value = current_bid[0]
        if len(previous_tied_bids) > 0:
            sorted_bids_by_agent_id = sorted(previous_tied_bids, key=lambda b: b[-1].agent_id)
            final_sorted_queue_id_tiebreaker += sorted_bids_by_agent_id        
        return final_sorted_queue_id_tiebreaker
 Sort of list of bids, find the ties, and sort by agent_id
Sort of list of bids, find the ties, and sort by agent_id
Sort of list of bids find the ties and sort by agent_id
def sort_and_break_ties_id(self, bid_queue, epsilon_bid = -1):
        if epsilon_bid == -1:
            epsilon_bid = self.k_epsilon_bid
        sorted_queue_by_bids = sorted(bid_queue, key=lambda b: -b[0])
        final_sorted_queue_id_tiebreaker = []
        previous_bid_value = -999999
        previous_tied_bids = []
        for current_bid in sorted_queue_by_bids:
            if abs(current_bid[0]-previous_bid_value) <= epsilon_bid:
                previous_tied_bids += [current_bid]
            else:
                if len(previous_tied_bids) > 0:
                    sorted_bids_by_agent_id = sorted(previous_tied_bids, key=lambda b: b[-1].agent_id)
                    final_sorted_queue_id_tiebreaker += sorted_bids_by_agent_id
                previous_tied_bids = [current_bid]
                previous_bid_value = current_bid[0]
        if len(previous_tied_bids) > 0:
            sorted_bids_by_agent_id = sorted(previous_tied_bids, key=lambda b: b[-1].agent_id)
            final_sorted_queue_id_tiebreaker += sorted_bids_by_agent_id        
        return final_sorted_queue_id_tiebreaker
def sort_and_break_ties_id ( self , bid_queue , epsilon_bid = - 1 ) : if epsilon_bid == - 1 : epsilon_bid = self . k_epsilon_bid sorted_queue_by_bids = sorted ( bid_queue , key = lambda b : - b [ 0 ] ) final_sorted_queue_id_tiebreaker = [ ] previous_bid_value = - 999999 previous_tied_bids = [ ] for current_bid in sorted_queue_by_bids : if abs ( current_bid [ 0 ] - previous_bid_value ) <= epsilon_bid : previous_tied_bids += [ current_bid ] else : ''' Sort the previously tied bids and use the agent id as the sorting key''' if len ( previous_tied_bids ) > 0 : sorted_bids_by_agent_id = sorted ( previous_tied_bids , key = lambda b : b [ - 1 ] . agent_id ) final_sorted_queue_id_tiebreaker += sorted_bids_by_agent_id previous_tied_bids = [ current_bid ] previous_bid_value = current_bid [ 0 ] if len ( previous_tied_bids ) > 0 : sorted_bids_by_agent_id = sorted ( previous_tied_bids , key = lambda b : b [ - 1 ] . agent_id ) final_sorted_queue_id_tiebreaker += sorted_bids_by_agent_id return final_sorted_queue_id_tiebreaker
Sort of list of bids, find the ties, and sort by agent_id
Sort of list of bids find the ties and sort by agent_id
''' Sort of list of bids, find the ties, and sort by agent_id''' ''' Sort the previously tied bids and use the agent id as the sorting key'''
self
bid_queue
epsilon_bid