Commit 28784f40 authored by Grégoire Grzeczkowicz's avatar Grégoire Grzeczkowicz
Browse files

Draw ERT

parent 18bd67ed
from os import system
import json
import numpy as np
import matplotlib.pyplot as plt
Nb_run = 3
solvers = [
'-m num_greedy -n 45 -i 5 -r 0.08 -t 10000 -w 100 -a 0.01',
'-m bit_greedy -n 45 -i 5 -r 0.08 -t 10000 -w 100 -a 0.01'
]
datas = []
for solver in solvers:
print("python3 draw_ert.py --nb-run " + str(Nb_run) + " --save-proba " + solver)
system("python3 draw_ert.py --nb-run " + str(Nb_run) + " --save-proba " + solver)
with open('proba.json') as json_file:
data = json.load(json_file)
datas.append(data)
temps_max = 0
value_max = 0
value_min = np.inf
for data in datas:
for run in data:
m = max([int(k) for k,v in run.items()])
if m > temps_max:
temps_max = m
m = max([v for k,v in run.items()])
if m > value_max:
value_max = m
m = min([v for k,v in run.items()])
if m < value_min:
value_min = m
def probability(data,time,value):
num = 0
for attempt in data:
good = False
for t,v in attempt.items():
if int(t) <= time and v >= value:
good = True
break
if good:
num += 1
return num/len(data)
probability = np.vectorize(probability, excluded=[0])
j = 1
for v in [8379,8380,8400]:
for i in range(len(solvers)):
plt.subplot(320+j)
P = probability(datas[i],range(1,temps_max+1),v)
plt.bar(range(1,temps_max+1), P)
plt.title("ERT for target {} and solver\n{}".format(v, solvers[i]))
plt.xlabel('run')
plt.ylabel('probability')
plt.ylim(0,1)
j += 1
plt.tight_layout()
plt.show()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment