Esempio n. 1
0
    def target_slot(self, t, history, reserve):
        """Figure out the best slot to target, assuming that everyone else
        keeps their bids constant from the previous rounds.

        Returns (slot_id, min_bid, max_bid), where min_bid is the bid needed to tie
        the other-agent bid for that slot in the last round.  If slot_id = 0,
        max_bid is min_bid * 2
        """
        i = argmax_index(self.expected_utils(t, history, reserve))
        info = self.slot_info(t, history, reserve)
        try:
            return info[i]
        except:
            i = argmax_index(self.expected_utils(t, history, reserve)[:-1])
            return info[i]
    def target_slot(self, t, history, reserve):
        """Figure out the best slot to target, assuming that everyone else
        keeps their bids constant from the previous rounds.

        Returns (slot_id, min_bid, max_bid), where min_bid is the bid needed to tie
        the other-agent bid for that slot in the last round.  If slot_id = 0,
        max_bid is min_bid * 2
        """
        i =  argmax_index(self.expected_utils(t, history, reserve))
        info = self.slot_info(t, history, reserve)
        return info[i]
    def estimate_values(self, t, history,
                        reserve):  # this is assuming other players play BB
        # the values are drawn in U[25, 175]
        prev_round = history.round(t - 1)

        other_bids = filter(lambda (a_id, b): a_id != self.id, prev_round.bids)
        # check that bids are sorted by agent id
        if t == 1:  # at second round, estimate with the mean 100, to refine
            self.estimated_values = [(other_bids[k][0], 100)
                                     for k in range(len(other_bids))]

        # assume the agents are playing balanced bidding
        else:
            prevprev_round = history.round(t - 2)
            clicks = prevprev_round.clicks
            for i in range(len(other_bids)):
                # assume agent i is playing balanced bids in round t-1
                id_i = other_bids[i][0]
                bid_i = other_bids[i][1]

                other_bids_i = filter(lambda (a_id, b): a_id != id_i,
                                      prevprev_round.bids)
                other_bids_i = sorted([x[1] for x in other_bids_i],
                                      reverse=True)

                num_slots = len(clicks)

                for _ in range(len(other_bids_i), num_slots):
                    other_bids_i.append(0)

                other_bids_i = [max(x, reserve) for x in other_bids_i]
                expected_utilities_i = [
                    clicks[k] * (self.estimated_values[i][1] -
                                 max(other_bids_i[k], reserve))
                    for k in range(len(other_bids_i))
                ]

                target_slot_i = argmax_index(expected_utilities_i)

                if target_slot_i == 0:
                    value_i = bid_i

                elif expected_utilities_i[target_slot_i] < 0:
                    value_i = bid_i
                else:
                    t_star_i = other_bids_i[target_slot_i]
                    value_i = (clicks[target_slot_i] * t_star_i - bid_i * clicks[target_slot_i - 1]) / \
                              (clicks[target_slot_i] - clicks[target_slot_i-1])

                if value_i < 25:
                    value_i = 25

                if value_i > 175:
                    value_i = 175

                if t == 2:
                    self.estimated_values[i] = (id_i, value_i)
                else:
                    self.estimated_values[i] = (id_i,
                                                (self.estimated_values[i][1] *
                                                 (t - 2) + value_i) / (t - 1))

                self.estimated_values[i] = (id_i, value_i)