-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbio_plot.py
executable file
·97 lines (78 loc) · 4.48 KB
/
bio_plot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/python3
import argparse
import pandas as pd
import matplotlib.pyplot as plt
from plot_functions import solved_instances_over_measure_plot, plot_speedup_per_instance_for_one_algorithm, plot_solutions
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Create plots out of the result data.")
parser.add_argument("csv", help="The CSV input file")
parser.add_argument("gurobi_csv", help="The Gurobi CSV input file")
parser.add_argument("gurobi_fpt_comparison_csv", help="The FPT results to compare to Gurobi")
parser.add_argument("output_dir", help="The output directory where plots shall be written")
parser.add_argument('--min-k', type=int, help="The minimum value of k to use, default: 10", default=10)
parser.add_argument('--solved-only', action="store_true", help="If only solved graphs shall be considered")
parser.add_argument('--time-limit', type=int, help="The maximum running time to use in seconds, default: 1000", default=1000)
args = parser.parse_args()
df = pd.read_csv(args.csv)
max_ks = df.groupby('Graph').max().k
larger_k_names = max_ks[max_ks >= args.min_k].index
df_filter = df.Graph.isin(larger_k_names) & (df['Total Time [s]'] <= args.time_limit)
if args.solved_only:
solved_graphs = df[df.Solved].groupby('Graph').first().index
filtered_df = df[df_filter & df.Graph.isin(solved_graphs)]
else:
filtered_df = df[df_filter]
df_st_4 = filtered_df[(filtered_df.MT == False) & (filtered_df.l == 4)]
fig, (ax1, ax2) = plt.subplots(1, 2, sharey=True, figsize=(9, 4))
solved_instances_over_measure_plot(df_st_4, 'Total Time [s]', ax1, args.time_limit)
solved_instances_over_measure_plot(df_st_4, 'Calls', ax2)
ax1.set_ylabel('Solved (Graphs $\\times$ Node Id Permutations)')
fig.tight_layout()
fig.legend(*ax1.get_legend_handles_labels(), ncol=5, loc='upper right', bbox_to_anchor=(0.99, 1.0))
fig.subplots_adjust(top=0.85)
fig.savefig('{}/bio_times_calls_st_min_k_{}.pgf'.format(args.output_dir, args.min_k))
plt.close(fig)
# fig, ax = plt.subplots(1, 1, figsize=(6, 4))
# solved_instances_over_measure_plot(df_st_4, 'Total Time [s]', ax, args.time_limit)
# ax.set_ylabel('Solved (Graphs $\\times$ Node Id Permutations)')
# ax.legend()
# fig.tight_layout()
# fig.savefig('{}/bio_times_st_min_k_{}.pdf'.format(args.output_dir, args.min_k))
fig = plot_solutions(df)
fig.tight_layout()
fig.savefig('{}/bio_solutions.pgf'.format(args.output_dir))
gurobi_df = pd.read_csv(args.gurobi_csv)
filtered_gurobi_df = gurobi_df[gurobi_df.Graph.isin(larger_k_names)]
gurobi_fpt_df = pd.read_csv(args.gurobi_fpt_comparison_csv)
filtered_gurobi_fpt_df = gurobi_fpt_df[
gurobi_fpt_df.Graph.isin(larger_k_names) &
(gurobi_fpt_df['Total Time [s]'] <= args.time_limit)
]
additional_comparison_df = filtered_df[(filtered_df.Threads == 16) & (filtered_df.Algorithm == "FPT-LS-MP") & (filtered_df.Permutation < 4)]
final_comparison_df = pd.concat([
filtered_gurobi_fpt_df,
filtered_gurobi_df[(filtered_gurobi_df.Algorithm == "ILP-S-R-C4")],
additional_comparison_df
])
fig, (ax1, ax2) = plt.subplots(1, 2, sharey=True, figsize=(9, 3.5))
solved_instances_over_measure_plot(final_comparison_df, 'Total Time [s]', ax1, args.time_limit)
solved_instances_over_measure_plot(final_comparison_df, 'Calls', ax2, args.time_limit)
ax1.set_ylabel('Solved (Graphs $\\times$ Node Id Permutations)')
ax2.legend()
fig.tight_layout()
fig.savefig('{}/bio_times_calls_gurobi_fpt_min_k_{}.pgf'.format(args.output_dir, args.min_k))
fig, ax = plt.subplots(1, 1, figsize=(4.5, 3.5))
#plot_speedup_per_instance_for_one_algorithm(filtered_df[filtered_df.Algorithm == "FPT-LS-M"], ax1)
#ax1.set_title('FPT-LS-M-All')
plot_speedup_per_instance_for_one_algorithm(filtered_df[filtered_df.Algorithm == "FPT-LS-MP"], ax)
ax.set_title('FPT-LS-MP-All')
ax.legend(title='Threads')
ax.set_ylabel('Speedup')
fig.tight_layout()
#fig.savefig('{}/biospeedupmink{}.pgf'.format(args.output_dir, args.min_k), dpi=300)
fig, ax = plt.subplots(1, 1, figsize=(4.5, 3.5))
solved_instances_over_measure_plot(filtered_gurobi_df[filtered_gurobi_df.MT == False], 'Total Time [s]', ax, args.time_limit)
ax.set_ylabel('Solved (Graphs $\\times$ Node Id Permutations)')
ax.legend()
fig.tight_layout()
fig.savefig('{}/bio_gurobi_times_min_k_{}.pgf'.format(args.output_dir, args.min_k), dpi=300)