async def test_random_trace_sched(base): """Test tracing for random schedulers""" sched1 = gamesched.gamesched(gamegen.game_replace(base)) sched2 = gamesched.gamesched(gamegen.game_replace(base)) traces = await trace.trace_all_equilibria( schedgame.schedgame(sched1), schedgame.schedgame(sched2), style="one" ) verify_complete_traces(traces)
def test_maximal_restrictions(base): """Test maximal restrictions""" game = gamegen.game_replace(base) rests = restrict.maximal_restrictions(game) assert rests.shape[0] == 1, \ 'found more than maximal restriction in a complete game' assert rests.all(), \ "found restriction wasn't the full one"
def test_random_restriction_preserves_completeness(base, _): """Test that restriction function preserves completeness""" game = gamegen.game_replace(base) assert game.is_complete(), "gamegen didn't create complete game" rest = game.random_restriction() rgame = game.restrict(rest) assert rgame.is_complete(), \ "restriction didn't preserve game completeness" sgame = gamegen.gen_noise(game) redsgame = sgame.restrict(rest) assert redsgame.is_complete(), \ "restriction didn't preserve sample game completeness"
def test_missing_data_maximal_restrictions(base, prob): """Test missing data""" game = gamegen.game_replace(base, prob) rests = restrict.maximal_restrictions(game) if rests.size: maximal = np.all(rests <= rests[:, None], -1) np.fill_diagonal(maximal, False) assert not maximal.any(), \ 'One maximal restriction dominated another' for rest in rests: rgame = rsgame.empty_copy(game).restrict(rest) restprofs = restrict.translate(rgame.all_profiles(), rest) assert all(p in game for p in restprofs), \ "Maximal restriction didn't have all profiles" for dev in np.nonzero(~rest)[0]: devprofs = restrict.additional_strategy_profiles( game, rest, dev) assert not all(p in game for p in devprofs), ( # pragma: no branch 'Maximal restriction could be bigger {} {}'.format( dev, rest))
async def test_at_least_one(base, _): """inner loop should always find one equilibrium with at_least one""" game = gamegen.game_replace(base) eqa = await innerloop.inner_loop(asyncgame.wrap(game), style='one') assert eqa.size
async def test_random_trace_game(base): """Test tracing for random games""" agame1 = asyncgame.wrap(gamegen.game_replace(base)) agame2 = asyncgame.wrap(gamegen.game_replace(base)) traces = await trace.trace_all_equilibria(agame1, agame2, style="one") verify_complete_traces(traces)