def test_mixture_regret(base, num_mixes, num_boots): """Test bootstrap mixture regret""" game = gamegen.samplegame_replace(base) mixes = game.random_mixtures(num_mixes) boots = bootstrap.mixture_regret(game, mixes, num_boots, processes=1) assert boots.shape == (num_mixes, num_boots) assert np.all(boots >= 0) perc_boots = bootstrap.mixture_regret(game, mixes, num_boots, percentiles=[2.5, 97.5], processes=1) assert perc_boots.shape == (num_mixes, 2) assert np.all(perc_boots >= 0)
def test_mixture_regret(players, strategies): num_mixes = 5 num_boots = 200 game = gamegen.add_noise(gamegen.role_symmetric_game(players, strategies), 1, 3) mixes = game.random_mixtures(num_mixes) boots = bootstrap.mixture_regret(game, mixes, num_boots, processes=1) assert boots.shape == (num_mixes, num_boots) assert np.all(boots >= 0) perc_boots = bootstrap.mixture_regret(game, mixes, num_boots, [2.5, 97.5], processes=1) assert perc_boots.shape == (num_mixes, 2) assert np.all(perc_boots >= 0)
def test_mixture_regret_parallel(num_mixes, num_boots): """Test mixture regret run on multiple processors""" game = gamegen.samplegame([4, 3], [3, 4]) mixes = game.random_mixtures(num_mixes) boots = bootstrap.mixture_regret(game, mixes, num_boots) assert boots.shape == (num_mixes, num_boots) assert np.all(boots >= 0)
def test_mixture_regret_single_mix(base, num_boots): """Test bootstrap regret with a single mix""" game = gamegen.samplegame_replace(base) mix = game.random_mixture() boots = bootstrap.mixture_regret(game, mix, num_boots, processes=1) assert boots.shape == (1, num_boots) assert np.all(boots >= 0)
def test_mixture_regret_single_mix(players, strategies): num_boots = 200 game = gamegen.add_noise(gamegen.role_symmetric_game(players, strategies), 1, 3) mix = game.random_mixtures()[0] boots = bootstrap.mixture_regret(game, mix, num_boots, processes=1) assert boots.shape == (1, num_boots) assert np.all(boots >= 0)
def test_mixture_regret_parallel(): num_mixes = 5 num_boots = 200 game = gamegen.add_noise(gamegen.role_symmetric_game([4, 3], [3, 4]), 1, 3) mixes = game.random_mixtures(num_mixes) boots = bootstrap.mixture_regret(game, mixes, num_boots) assert boots.shape == (num_mixes, num_boots) assert np.all(boots >= 0)