def test_ilp(): try: import gurobipy as _ except ImportError as e: logging.exception(e) logging.warning("Continuing with tests, gurobi not installed") return from checkmate.core.solvers.strategy_optimal_ilp import solve_ilp_gurobi for graph_length in test_points: g = gen_linear_graph(graph_length) assert g.size == 2 * graph_length + 1 total_cost = sum(g.cost_ram.values()) scheduler_result = solve_ilp_gurobi(g, total_cost, print_to_console=False, write_log_file=None) assert scheduler_result.feasible if SAVE_DEBUG_PLOTS: for budget in np.arange(0, 1, 0.25): scheduler_result = solve_ilp_gurobi(g, total_cost * budget, print_to_console=False, write_log_file=None, time_limit=15) if scheduler_result.feasible: plot_schedule( scheduler_result, save_file="/tmp/test_checkmate/plot_ilp/{}_{}.png". format(graph_length, budget))
def test_checkpoint_all_ap(): for graph_length in test_points: g = gen_linear_graph(graph_length) assert g.size == 2 * graph_length + 1 scheduler_result = solve_checkpoint_all_ap(g) assert scheduler_result.feasible if SAVE_DEBUG_PLOTS: plot_schedule(scheduler_result, save_file="/tmp/test_checkmate/plot_checkpoint_all_ap/{}.png".format(graph_length))
def test_chen_sqrtn(): for graph_length in test_points: g = gen_linear_graph(graph_length) assert g.size == 2 * graph_length + 1 total_cost = sum(g.cost_ram.values()) scheduler_result = solve_chen_sqrtn(g, total_cost) assert scheduler_result.feasible if SAVE_DEBUG_PLOTS: plot_schedule(scheduler_result, save_file="/tmp/test_checkmate/plot_chen_sqrtn/{}.png".format(graph_length))
def test_chen_greedy_ap(): for graph_length in [2, 4, 5, 7, 8]: g = gen_linear_graph(graph_length) assert g.size == 2 * graph_length + 1 total_cost = sum(g.cost_ram.values()) scheduler_result = solve_chen_greedy(g, total_cost, True) assert scheduler_result.feasible if SAVE_DEBUG_PLOTS: for budget in np.arange(0, 1, 0.1): scheduler_result = solve_chen_greedy(g, total_cost * budget, False) if scheduler_result.feasible: plot_schedule( scheduler_result, save_file="/tmp/test_checkmate/plot_chen_greedy_ap/{}_{}.png".format(graph_length, budget), )