-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
69 lines (58 loc) · 1.57 KB
/
plot.py
File metadata and controls
69 lines (58 loc) · 1.57 KB
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
import argparse
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plot
import numpy
import algo_stat
import os
def _mkdir(s):
try:
os.mkdir(s)
except:
pass
_mkdir('./plots/')
def variant_to_string(v):
def sub(s):
return s.upper() \
.replace('C', 'Consistent') \
.replace('I', 'Inconsistent') \
.replace('S', 'Semi-Consistent') \
.replace('L', 'Low') \
.replace('H', 'High')
parts = map(lambda x: sub(x), v.split('-'))
return parts[0] + '/' + parts[1] + '-' + parts[2]
variants = []
for x in ['c', 'i', 's']:
for y in ['l', 'h']:
for z in ['l', 'h']:
var = x + '-' + y + '-' + z
variants.append(var)
parser = argparse.ArgumentParser('Plotter')
parser.add_argument('-v', choices=variants, dest='variant', help='The variant to plot', required=True)
args = parser.parse_args()
VARIANT = args.variant
algorithms = {}
algorithms['astar'] = 'A*'
algorithms['ga'] = 'GA'
algorithms['gsa'] = 'GSA'
algorithms['mct'] = 'MCT'
algorithms['minmin'] = 'Min-Min'
algorithms['olb'] = 'OLB'
algorithms['tabu'] = 'Tabu'
data = {}
for algo in algorithms.keys():
data[algo] = algo_stat.confidence_interval(algo_stat.makespans(algo, VARIANT))
labels = [ algorithms[algo] for algo in algorithms.keys() ]
means = [ data[algo][0] for algo in algorithms.keys() ]
error = [ data[algo][1] for algo in algorithms.keys() ]
plot.bar(
numpy.arange(len(algorithms)),
means,
yerr=error,
align='center',
alpha=0.4
)
plot.xticks(numpy.arange(len(algorithms)), labels)
plot.ylabel('Makespan')
plot.title(variant_to_string(VARIANT))
plot.savefig('./plots/' + VARIANT + '.png')