def check_bias(times=1000): """ Experiment to check if there is a bias in the setting. All buyers have an initial bidding factor random between 1 and 1.001 and the same increasing and decreasing factor. The result is presented as the number of times that each buyer wins the simulation. :param times: Number of times to execute the test """ max_profit = np.zeros(n_buyers) for n in range(times): auctioneer = Auctioneer( bidding_factor_strategy=2, R_rounds=100, ) auctioneer.bidding_factor = [] for buyer in range(n_buyers): bid_fact = np.random.uniform(1, 1.001, 3) auctioneer.bidding_factor.append(bid_fact) auctioneer.increase_bidding_factor = [1.2 for n in range(n_buyers)] auctioneer.decrease_bidding_factor = [0.8 for n in range(n_buyers)] auctioneer.start_auction() buyers_prof = auctioneer.cumulative_buyers_profits[:, auctioneer. r_rounds - 1] for buyer in range(n_buyers): if buyers_prof[buyer] == max(buyers_prof): max_profit[buyer] += 1 [ print("Buyer", buyer, "was the one with more profit", max_profit[buyer], "times") for buyer in range(n_buyers) ]
def check_price_stability_varying_ceiling(): """ Check the effect of modifying the ceiling for the strategy 2. The effect is presented with a plot where the x axis is the value of the ciling and the y axis the average difference between the initial prices and the market price of the last round. """ iterations = 500 ceilings = [top for top in np.arange(1.5, 5, 0.1)] # avg_market_prices = [] # diff_marketprice_start_prices = [] mrkt_price_starting_price_ratio = [] for iter in range(len(ceilings)): auctioneer = Auctioneer(K_sellers=3, N_buyers=10, R_rounds=100, debug=False, bidding_factor_strategy=[3 for x in range(10)]) auctioneer.ceiling = ceilings[iter] auctioneer.start_auction() mrkt_price_starting_price_ratio.append( np.mean(auctioneer.market_price[auctioneer.r_rounds - 1]) / np.mean(auctioneer.starting_prices)) # plt.plot(ceilings, diff_marketprice_start_prices) plt.plot(ceilings, mrkt_price_starting_price_ratio) plt.xlabel("Ceiling") plt.ylabel("Ratio between market price and starting price of last round") plt.legend() plt.show()
def test_real_case_scenario(self): starting_prices = [[40, 50, 20]] auctioneer = Auctioneer(starting_prices=starting_prices, M_types=2, K_sellers=3, N_buyers=5, R_rounds=2, level_comm_flag=False) auctioneer.increase_bidding_factor = [2, 3, 4, 5, 6] auctioneer.decrease_bidding_factor = [0.6, 0.5, 0.4, 0.3, 0.2] auctioneer.sellers_types = [1, 1, 0] # auctioneer.bidding_factor = np.array([ # # Buyer 0 # [ # # [1, 2, 3], # Type 0 # [4, 5, 6] # Type 1 # ], # # Buyer 1 # [ # [1.68791717, 1.43217411, 1.1566692], # [1.20532547, 1.05372195, 1.19885528] # ], # # Buyer 2 # [ # [1.71709178, 1.83604667, 1.4957177], # [1.50015315, 1.77615324, 1.00780864] # ], # # Buyer 3 # [ # [1.62403167, 1.51698165, 1.74709901], # [1.84536679, 1.29700791, 1.08997174] # ], # # Buyer 4 # [ # [1.81391097, 1.2531242, 1.01217679], # [1.15969576, 1.55215565, 1.34450197] # ] # ]) auctioneer.start_auction() self.assertEqual([], auctioneer.market_price)
"the decreasing factor while if it is lower multiply by the increasing factor.\n" strategy = request_integer_input(strat) level_commitment_activated = request_boolean_input( "Should use level commitment? y/n ") if level_commitment_activated: penalty_factor = request_float_input("Penalty factor: ") else: penalty_factor = 0 alpha = 0 while alpha != 1 and alpha != 2: alpha = request_integer_input( "Bidding factor depends on the sellers (1) or types of items (2): ") debug = request_boolean_input( "Print the debug information on every round? (y/n): ") # Execute with parameters auctioneer = Auctioneer( penalty_factor=penalty_factor, bidding_factor_strategy=[strategy for n in range(number_of_buyers)], use_seller=(alpha == 1), M_types=number_of_product_types, K_sellers=number_of_sellers, N_buyers=number_of_buyers, R_rounds=number_of_rounds, level_comm_flag=level_commitment_activated, debug=debug) auctioneer.start_auction() auctioneer.plot_statistics()