Scheduler
convergence.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import matplotlib
3 #matplotlib.use('GTKAgg')
4 import matplotlib.pyplot as plt
5 import itertools
6 
7 allSteps = False
8 
9 def actionValuePlot(state, action):
10  rootfilename = "actionValuesForState"
11  print "Processing state", state, "...\n"
12  filename = rootfilename + str(state) + "action" + str(action)
13  with open(filename) as f:
14  if allSteps:
15  value = [float(line) for line in f]
16  labl = str(state) + "-" + str(action)
17  plt.plot(value, drawstyle='steps-post', label=labl)
18  else:
19  pair = [line.split(" ") for line in f]
20  time = [float(elem[0]) for elem in pair]
21  value = [float(elem[1]) for elem in pair]
22  labl = str(state) + "-" + str(action)
23  plt.plot(time, value, drawstyle='steps-post', label=labl)
24 
25 
26 
27 def main():
28  array = []
29  with open("rlfile.txt") as f:
30  splitlines = [line.rstrip().split(" ") for line in f]
31  for line in splitlines:
32  actions = [float(a) > -70000 for a in line]
33  array.append(actions)
34  #fig, ax = plt.subplots()
35  #for state in (0, 1, 2, 3, 4, 5, 6, 7):
36  for state in range(144):
37  for action in range(3):
38  if array[state][action]:
39  actionValuePlot(state, action)
40  plt.legend(loc='upper left', bbox_to_anchor=(1, 1), ncol=2, borderaxespad=0)
41  plt.show()
42 
43 
44 
45 if __name__ == '__main__':
46  main()
def main()
Definition: convergence.py:27
def actionValuePlot(state, action)
Definition: convergence.py:9