def main(n): print(f'running for dataset {n}') matching_dict_1 = run_deferred_acceptance(n) write_matching(matching_dict_1, 'single', n) block_pairs_1 = count_blocking_pairs(f'matching_task_single_data_{n}.csv', n) welfare_1 = calc_total_welfare(f'matching_task_single_data_{n}.csv', n) print(f'Total welfare from the single matching: {welfare_1}') print(f'Number of blocking pairs from single matching: {block_pairs_1}') matching_dict_2 = run_deferred_acceptance_for_pairs(n) write_matching(matching_dict_2, 'coupled', n) block_pairs_2 = count_blocking_pairs(f'matching_task_coupled_data_{n}.csv', n) welfare_2 = calc_total_welfare(f'matching_task_coupled_data_{n}.csv', n) print(f'Total welfare from the coupled matching: {welfare_2}') print(f'Number of blocking pairs from coupled matching: {block_pairs_2}') matching_dict_3, prices_dict = run_market_clearing(n) write_matching(matching_dict_3, 'mcp', n) write_projects_prices(prices_dict, n) welfare_3 = calc_total_welfare(f'matching_task_mcp_data_{n}.csv', n) print(f'Total welfare from the MCP matching: {welfare_3}') matching_dict_comp = run_deferred_acceptance_for_pairs_comp(n) write_matching(matching_dict_comp, 'competition', n) block_pairs_comp = count_blocking_pairs_comp( f'matching_task_competition_data_{n}.csv', n) welfare_comp = calc_total_welfare_comp( f'matching_task_competition_data_{n}.csv', n) print(f'Total welfare from the coupled matching: {welfare_comp}') print( f'Number of blocking pairs from coupled matching: {block_pairs_comp}')
def run_paired_matching(n): """Running Paired matching DA""" print(f'\nTesting DA for pairs') matching_dict_2 = run_deferred_acceptance_for_pairs(n) write_matching(matching_dict_2, 'coupled', n) block_pairs_2 = count_blocking_pairs(f'matching_task_coupled_data_{n}.csv', n) stdnts_block_pairs_2_sol = hw2_part1_sol.count_blocking_pairs( f'matching_task_coupled_data_{n}.csv', n) block_pairs_2_sol = hw2_part1_sol.count_blocking_pairs( f'../../solutions/matching_task_coupled_sol_data_{n}.csv', n) welfare_2 = calc_total_welfare(f'matching_task_coupled_data_{n}.csv', n) stdnts_welfare_2_sol = hw2_part2_sol.calc_total_welfare( f'matching_task_coupled_data_{n}.csv', n) welfare_2_sol = hw2_part2_sol.calc_total_welfare( f'../../solutions/matching_task_coupled_sol_data_{n}.csv', n) return welfare_2, welfare_2_sol, stdnts_welfare_2_sol, block_pairs_2, block_pairs_2_sol, stdnts_block_pairs_2_sol
def run_mcp(n): """Running Market Clearing Prices""" print(f'\nTesting MCP for singles') matching_dict_3, prices_dict = run_market_clearing(n) write_matching(matching_dict_3, 'mcp', n) write_projects_prices(prices_dict, n) welfare_3 = calc_total_welfare(f'matching_task_mcp_data_{n}.csv', n) stdnts_welfare_3_sol = hw2_part2_sol.calc_total_welfare( f'matching_task_mcp_data_{n}.csv', n) welfare_3_sol = hw2_part2_sol.calc_total_welfare( f'../../solutions/matching_task_mcp_sol_data_{n}.csv', n) block_pairs_3 = count_blocking_pairs(f'matching_task_mcp_data_{n}.csv', n) stdnts_block_pairs_3_sol = hw2_part1_sol.count_blocking_pairs( f'matching_task_mcp_data_{n}.csv', n) block_pairs_3_sol = hw2_part1_sol.count_blocking_pairs( f'../../solutions/matching_task_mcp_sol_data_{n}.csv', n) return welfare_3, welfare_3_sol, stdnts_welfare_3_sol, block_pairs_3, block_pairs_3_sol, stdnts_block_pairs_3_sol
def run_single_matching(n): """Running Single Matching DA""" print(f'\n---------- running for dataset {n} ----------\n') print(f'\nTesting DA for singles') matching_dict_1 = run_deferred_acceptance(n) write_matching(matching_dict_1, 'single', n) block_pairs_1 = count_blocking_pairs(f'matching_task_single_data_{n}.csv', n) stdnts_block_pairs_1_sol = hw2_part1_sol.count_blocking_pairs( f'matching_task_single_data_{n}.csv', n) block_pairs_1_sol = hw2_part1_sol.count_blocking_pairs( f'../../solutions/matching_task_single_sol_data_{n}.csv', n) welfare_1 = calc_total_welfare(f'matching_task_single_data_{n}.csv', n) stdnts_welfare_1_sol = hw2_part2_sol.calc_total_welfare( f'matching_task_single_data_{n}.csv', n) welfare_1_sol = hw2_part2_sol.calc_total_welfare( f'../../solutions/matching_task_single_sol_data_{n}.csv', n) return welfare_1, welfare_1_sol, stdnts_welfare_1_sol, block_pairs_1, block_pairs_1_sol, stdnts_block_pairs_1_sol