-
Notifications
You must be signed in to change notification settings - Fork 0
/
social_table.py
executable file
·73 lines (60 loc) · 2.99 KB
/
social_table.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
#!/usr/bin/python3
import argparse
import collections
import pandas as pd
import numpy as np
def get_max_k_time(df):
df = df.copy()
graph_groups = df.groupby('Graph')
df['max_k'] = graph_groups.k.transform(np.max)
max_k_df = df[df.k == df.max_k]
return max_k_df.groupby('Graph')[['k', 'Total Time [s]', 'Solved']].min()
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Generate the results table of the social instances")
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(
'--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)
filtered_df = df[df['Total Time [s]'] <= args.time_limit]
gurobi_df = pd.read_csv(args.gurobi_csv)
filtered_gurobi_df = gurobi_df[~gurobi_df.Algorithm.str.contains('Heuristic')]
gurobi_fpt_df = pd.read_csv(args.gurobi_fpt_comparison_csv)
filtered_gurobi_fpt_df = gurobi_fpt_df[gurobi_fpt_df['Total Time [s]'] <= args.time_limit]
fpt_algo = 'FPT-LS-MP'
ilp_algo = 'ILP-S-R-C4'
all_solutions = False
fpt_data = filtered_gurobi_fpt_df[(filtered_gurobi_fpt_df.Algorithm == fpt_algo) & (filtered_gurobi_fpt_df['All Solutions'] == all_solutions)]
ilp_data = filtered_gurobi_df[filtered_gurobi_df.Algorithm == ilp_algo]
general_data = fpt_data.groupby('Graph')[['n', 'm']].first()
solved_data = ilp_data.groupby('Graph')['Solved'].any()
fpt_st_data = get_max_k_time(fpt_data[~fpt_data.MT])
fpt_mt_data = get_max_k_time(fpt_data[fpt_data.MT])
ilp_st_data = get_max_k_time(ilp_data[~ilp_data.MT])
ilp_mt_data = get_max_k_time(ilp_data[ilp_data.MT])
df = pd.DataFrame(collections.OrderedDict([
(('', '', 'Graph'), general_data.index),
(('', '', 'n'), general_data.n),
(('', '', 'm'), general_data.m),
#(('', '', 'Solved'), solved_data),
(('FPT', '1 core', 'k'), fpt_st_data.k),
(('FPT', '1 core', 'Time [s]'), fpt_st_data['Total Time [s]']),
(('FPT', '16 cores', 'k'), fpt_mt_data.k),
(('FPT', '16 cores', 'Time [s]'), fpt_mt_data['Total Time [s]']),
# subtract one for unsolved graphs
(('ILP', '1 core', 'k'), ilp_st_data.k - (~ilp_st_data.Solved)),
(('ILP', '1 core', 'Time [s]'), ilp_st_data['Total Time [s]']),
(('ILP', '16 cores', 'k'), ilp_mt_data.k - (~ilp_mt_data.Solved)),
(('ILP', '16 cores', 'Time [s]'), ilp_mt_data['Total Time [s]']),
]))
df.sort_values(by=('FPT', '1 core', 'Time [s]'), inplace=True)
print(df.to_latex(index=False, formatters=
{('', '', 'Solved') : lambda x : 'Yes' if x else 'No'},
float_format=lambda x : "{:.2f}".format(x), na_rep=" "))