def welfare(game, serial, prof): """get the welfare of a profile or mixture""" if is_pure_profile(game, prof): return regret.pure_social_welfare(game, prof).item() else: return regret.mixed_social_welfare(game, prof).item()
def test_nonzero_mixed_welfare(): game = rsgame.Game([[[3.5, 2.5]]]) assert np.isclose(regret.mixed_social_welfare(game, [1, 1]), 6), \ "Didn't properly sum welfare"
def test_two_player_zero_sum_mixed_wellfare(strategies): game = gamegen.two_player_zero_sum_game(strategies) for prof in game.random_mixtures(20): assert np.isclose(regret.mixed_social_welfare(game, prof), 0), \ "zero sum profile wasn't zero sum"
def test_non_zero_sum_mixture_welfare(): """Test nonzero mixed welfare""" game = matgame.matgame([[[3.5, 2.5]]]) assert np.isclose(regret.mixed_social_welfare(game, [1, 1]), 6), \ "Didn't properly sum welfare"
def test_two_player_zero_sum_mixture_wellfare(strategies): """test welfare in zero sum game""" game = gamegen.two_player_zero_sum_game(strategies) for prof in game.random_mixtures(20): assert np.isclose(regret.mixed_social_welfare(game, prof), 0), \ "zero sum profile wasn't zero sum"
def welfare(game, prof): """get the welfare of a profile or mixture""" if is_pure_profile(game, prof): # pylint: disable=no-else-return return regret.pure_social_welfare(game, np.asarray(prof, int)).item() else: return regret.mixed_social_welfare(game, prof).item()