Beispiel #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()
Beispiel #2
0
def test_nonzero_profile_welfare():
    game = rsgame.Game([[[3.5, 2.5]]])
    assert np.isclose(regret.pure_social_welfare(game, [1, 1]), 6), \
        "Didn't properly sum welfare"
Beispiel #3
0
def test_two_player_zero_sum_pure_wellfare(strategies):
    game = gamegen.two_player_zero_sum_game(strategies)
    for prof in game.profiles:
        assert np.isclose(regret.pure_social_welfare(game, prof), 0), \
            "zero sum profile wasn't zero sum"
Beispiel #4
0
def test_non_zero_sum_profile_welfare():
    """Test nonzero profile welfare"""
    game = matgame.matgame([[[3.5, 2.5]]])
    assert np.isclose(regret.pure_social_welfare(game, [1, 1]), 6), \
        "didn't properly sum welfare"
Beispiel #5
0
def test_two_player_zero_sum_pure_wellfare(strategies):
    """Test pure welfare in zero sum games"""
    game = gamegen.two_player_zero_sum_game(strategies)
    for prof in game.profiles():
        assert np.isclose(regret.pure_social_welfare(game, prof), 0), \
            "zero sum profile wasn't zero sum"
Beispiel #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()