def __init__(self, bidder_id, num_rounds, num_bidders, possible_types, type_dist, type_dist_disc): """ :param bidder_id: Integer. A unique identifier for this given agent. :param num_rounds: Integer. The number of rounds the auction this bidder is participating in will run for. :param num_bidders: Integer. The total number of bidders in the auction this bidder is participating in. :param possible_types: List. A list of all possible types the bidder can take. Types are arranged in increasing order. :param type_dist: List. Probabilities corresponding to each entry in possible_types. :param type_dist_disc: Boolean. True if type_dist is describing a discrete distribution. """ # Init will call make_state_space, but we need some more information before going through this process. MDPBidderUAI.__init__(self, bidder_id, num_rounds, num_bidders, possible_types, type_dist, type_dist_disc) self.num_price_samples = len(self.action_space) # Not used self.num_prices_for_state = len(self.action_space) - 1 state_price_delta = float(max(possible_types) - min(possible_types)) / self.num_prices_for_state self.prices_in_state = [i * state_price_delta for i in range(self.num_prices_for_state)] self.digit_precision = 2 # Learn values to this precision self.prices_in_state = set() self.state_space = set() self.terminal_states = set() self.action_space = set() self.use_given_pi = False self.given_pi = {}
if type_dist_disc: type_dist = [1.0 / len(possible_types)] * len(possible_types) else: type_dist = [1.0] * len(possible_types) num_mc = 50000 bidders = [KatzmanBidder(i, num_rounds, num_bidders, possible_types, type_dist, type_dist_disc) for i in range(num_bidders)] # bidders = [MenezesMonteiroBidder(i, num_rounds, num_bidders, possible_types, type_dist, type_dist_disc) # for i in range(num_bidders)] # bidders = [SimpleBidder(i, num_rounds, num_bidders, possible_types, type_dist, type_dist_disc) # for i in range(num_bidders)] # bidders = [WeberBidder(i, num_rounds, num_bidders, possible_types, type_dist, type_dist_disc) # for i in range(num_bidders)] learner = MDPBidderUAI(num_bidders, num_rounds, num_bidders, possible_types, type_dist, type_dist_disc) learner.learn_auction_parameters(bidders, num_mc) # Plot what the bidder has learned learner.valuations = [.2, .1] learner.calc_expected_rewards() learner.solve_mdp() plot_exp_payments(learner) plot_transition(learner) plot_prob_winning_and_transition(learner) plot_Q_values(learner) plot_price_pdf(learner) print(learner.place_bid(1)) # print(learner.place_bid(2)) # Compare learner to other agents