Exemple #1
0
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()
Exemple #2
0
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"
Exemple #3
0
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"
Exemple #4
0
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"
Exemple #5
0
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"
Exemple #6
0
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()