def test_parse_almost_solution(): file = "C:\\Users\\Sofia\\Documents\\level5project\\SRI_IP\\data\\outputs\\ASP\\almost-SRI\\output-almost-40-75.txt" solution = parse_answers(file)[0] assert solution == set([(10, 28), (38, 40), (32, 37), (3, 34), (33, 39), (27, 31), (21, 26), (7, 24), (11, 22), (5, 19), (17, 29), (13, 16), (12, 36), (1, 35), (6, 30), (20, 25), (18, 23), (9, 15), (4, 14), (2, 8)])
def test_can_get_better_than_1(): preferences = read_instance(60, 25, 5, 0) file = "C:\\Users\\Sofia\\Documents\\level5project\\SRI_IP\\data\\outputs\\ASP\\almost-SRI\\output-almost-60-25.txt" solution = parse_answers(file)[4] better_options = can_get_better_than_current_partner( preferences, get_partners(solution), 41) assert set(better_options) == set([23])
def test_feasibility_checker(): for size in [40, 60, 80]: for density in [25, 50, 75, 100]: if size == 40 and density == 25: continue blocking_pairs = parse_blocking_pairs(size, density, True) answers = parse_answers( "C:\\Users\\Sofia\\Documents\\level5project\\SRI_IP\\data\\outputs\\ASP\\almost-SRI\\output-almost-%d-%d.txt" % (size, density)) if size == 40 and density == 50: answers = [None] + answers blocking_pairs = [None] + blocking_pairs for i, answer in enumerate(answers): # Known non-existing/weird answers if (size == 40 and density == 50 and i == 0) or (size == 60 and density == 25 and i == 19): continue preferences = read_instance(size, density, i + 1, 0) print(size, density, i + 1) feasibility = check_feasibility(preferences, answer) assert (not feasibility and not blocking_pairs[i]) or (set( feasibility[0]) == blocking_pairs[i])
def test_verifier(): preferences = read_instance(40, 50, 2, 0) file = "C:\\Users\\Sofia\\Documents\\level5project\\SRI_IP\\data\\outputs\\ASP\\almost-SRI\\output-almost-40-50.txt" solution = parse_answers(file)[0] blocking_pairs = get_blocking_pairs(preferences, solution) assert set(blocking_pairs) == set()
def test_verifier(): preferences = read_instance(60, 25, 5, 0) file = "C:\\Users\\Sofia\\Documents\\level5project\\SRI_IP\\data\\outputs\\ASP\\almost-SRI\\output-almost-60-25.txt" solution = parse_answers(file)[4] blocking_pairs = get_blocking_pairs(preferences, solution) assert set(blocking_pairs) == set([(41, 23), (23, 41)])