-
Notifications
You must be signed in to change notification settings - Fork 0
/
hillcar_mcts_plotting.py
170 lines (141 loc) · 5.51 KB
/
hillcar_mcts_plotting.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import os
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
from utils import cdf_points
ROOT = os.path.expanduser('~/data/hillcar/')
IMAGES = os.path.expanduser('~/Dropbox/Documents/Notes/images/hillcar/')
def cdf_plot_file(ax,filename,*vargs,**kwargs):
data = np.load(filename)
(x,F) = cdf_points(data)
ax.plot(x,F,*vargs,**kwargs)
def component_cdf_plot():
fig = plt.figure()
ax = plt.gca()
cdf_plot_file(ax,ROOT + 'hillcar.rollout.npy','-b',lw=2)
cdf_plot_file(ax,ROOT + 'hillcar.q_low.npy','-r',lw=2)
cdf_plot_file(ax,ROOT + 'hillcar.q_ref.npy','-g',lw=2)
ax.set_xlabel('Discounted Cost')
ax.set_title('Components of MCTS')
ax.legend(['rollout','16x16','64x64'],loc='best')
fig.savefig(IMAGES + 'mcts_components.png')
plt.close()
def mcts_cdf_plot():
fig = plt.figure()
ax = plt.gca()
cdf_plot_file(ax,ROOT + 'hillcar.rollout.npy','--k',lw=2.0)
cdf_plot_file(ax,ROOT + 'hillcar.q_low.npy','--b',lw=2.0)
cdf_plot_file(ax,ROOT + 'hillcar.q_ref.npy','--r',lw=2.0)
labels = ['rollout','16x16','64x64']
budgets = [4,8,16,32,64,128,256,512]
B = len(budgets)
colors = [cm.cool(x) for x in np.linspace(0,1,B)]
for (budget,color) in zip(budgets,colors):
cdf_plot_file(ax,ROOT + 'hillcar.mcts_low_{0}.npy'.format(budget),
lw=2.,color=color)
labels.append('MCTS ' +str(budget))
ax.set_xlabel('Discounted Cost')
ax.set_title('MCTS with various budgets')
ax.legend(labels,loc='best')
fig.savefig(IMAGES + 'mcts_low.png')
plt.close()
def mcts_pes_cdf_plot():
fig = plt.figure()
ax = plt.gca()
cdf_plot_file(ax,ROOT + 'hillcar.rollout.npy','--k',lw=2.0)
cdf_plot_file(ax,ROOT + 'hillcar.q_low.npy','--b',lw=2.0)
cdf_plot_file(ax,ROOT + 'hillcar.q_ref.npy','--r',lw=2.0)
labels = ['rollout','16x16','64x64']
budgets = [4,8,16,32,64,128,256,512]
B = len(budgets)
colors = [cm.cool(x) for x in np.linspace(0,1,B)]
for (budget,color) in zip(budgets,colors):
cdf_plot_file(ax,ROOT + 'hillcar.mcts_noq_pes_{0}.npy'.format(budget),
lw=2.,color=color)
labels.append('MCTS ' +str(budget))
ax.set_xlabel('Discounted Cost')
ax.set_title('Pessimistic MCTS with various budgets')
ax.legend(labels,loc='best')
fig.savefig(IMAGES + 'mcts_pes.png')
plt.close()
def mcts_opt_cdf_plot():
fig = plt.figure()
ax = plt.gca()
cdf_plot_file(ax,ROOT + 'hillcar.rollout.npy','--k',lw=2.0)
cdf_plot_file(ax,ROOT + 'hillcar.q_low.npy','--b',lw=2.0)
cdf_plot_file(ax,ROOT + 'hillcar.q_ref.npy','--r',lw=2.0)
labels = ['rollout','16x16','64x64']
budgets = [4,8,16,32,64,128,256,512]
B = len(budgets)
colors = [cm.cool(x) for x in np.linspace(0,1,B)]
for (budget,color) in zip(budgets,colors):
cdf_plot_file(ax,ROOT + 'hillcar.mcts_noq_opt_{0}.npy'.format(budget),
lw=2.,color=color)
labels.append('MCTS ' +str(budget))
ax.set_xlabel('Discounted Cost')
ax.set_title('Optimistic MCTS with various budgets')
ax.legend(labels,loc='best')
fig.savefig(IMAGES + 'mcts_opt.png')
plt.show()
plt.close()
def mcts_noflow_cdf_plot():
fig = plt.figure()
ax = plt.gca()
cdf_plot_file(ax,ROOT + 'hillcar.rollout.npy','--k',lw=2.0)
cdf_plot_file(ax,ROOT + 'hillcar.q_low.npy','--b',lw=2.0)
cdf_plot_file(ax,ROOT + 'hillcar.q_ref.npy','--r',lw=2.0)
labels = ['rollout','16x16','64x64']
budgets = [4,8,16,32,64,128,256,512]
B = len(budgets)
colors = [cm.cool(x) for x in np.linspace(0,1,B)]
for (budget,color) in zip(budgets,colors):
cdf_plot_file(ax,ROOT + 'hillcar.mcts_noflow_{0}.npy'.format(budget),
lw=2.,color=color)
labels.append('MCTS ' +str(budget))
ax.set_xlabel('Discounted Cost')
ax.set_title('Noflow MCTS with various budgets')
ax.legend(labels,loc='best')
fig.savefig(IMAGES + 'mcts_noflow.png')
plt.close()
def mcts_handicap_cdf_plot():
fig = plt.figure()
ax = plt.gca()
cdf_plot_file(ax,ROOT + 'hillcar.mcts_low_128.npy','--k',lw=2.0)
labels = ['MCTS 128']
flavours = ['noflow',
'noq_opt',
'noq_pes']
B = len(flavours)
colors = [cm.cool(x) for x in np.linspace(0,1,B)]
for (flavour,color) in zip(flavours,colors):
cdf_plot_file(ax,ROOT + 'hillcar.mcts_{0}_128.npy'.format(flavour),
lw=2.0,color=color)
labels.append('MCTS ' +str(flavour))
ax.set_xlabel('Discounted Cost')
ax.set_title('MCTS with various handicaps')
ax.legend(labels,loc='best')
fig.savefig(IMAGES + 'mcts_handicaps.png')
plt.close()
def mcts_shocking_64_cdf_plot():
fig = plt.figure()
ax = plt.gca()
cdf_plot_file(ax,ROOT + 'hillcar.mcts_low_512.npy','-k',lw=2.0)
cdf_plot_file(ax,ROOT + 'hillcar.mcts_noq_pes_64.npy','-r',lw=2.0)
cdf_plot_file(ax,ROOT + 'hillcar.mcts_noq_opt_64.npy','-g',lw=2.0)
cdf_plot_file(ax,ROOT + 'hillcar.mcts_noflow_64.npy','-b',lw=2.0)
ax.set_xlabel('Discounted Cost')
ax.set_title('Unusual behavior in No Q MCTS 64')
ax.legend(['MCTS 512',
'No Q MCTS 64 Pesimistic',
'No Q MCTS 64 Optimistic',
'No flow MCTS 64'],loc='best')
fig.savefig(IMAGES + 'mcts_shocking_64.png')
plt.show()
plt.close()
component_cdf_plot()
mcts_cdf_plot()
mcts_handicap_cdf_plot()
mcts_pes_cdf_plot()
mcts_opt_cdf_plot()
mcts_noflow_cdf_plot()
mcts_shocking_64_cdf_plot()