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 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)