import matplotlib.pyplot as plt
import numpy as np
+RUNS = 10000
+ITERS = 1000
+
def load(fn=None):
"""Load scenario from file.
raise ValueError("Directory name as argument needed")
scenarios = []
for d in listdir(dn):
+ if int(d) >= RUNS:
+ continue
s = load("{}/{}/{}.json".format(dn, d, fn))
s["dn"] = dn
s["subdn"] = d
result_dir = argv[1]
test_fn = argv[2]
scenarios = load_dir(result_dir, test_fn)
- L = 1000#len(scenarios[0]["log_path_cost"])
+ L = ITERS
err_hist = [0 for i in range(L)]
val_list = [[] for i in range(L)]
icnt_list = []
for s in scenarios:
lpc = s["log_path_cost"]
for i in range(L):
+ if len(lpc) <= i:
+ lpc.append(lpc[-1])
if lpc[i] == 0:
err_hist[i] += 1
else:
otime_list.append(s["otime"])
except:
pass
+ o_err_hist = list(err_hist)
+ err_hist = [i * 100.0 / RUNS for i in o_err_hist]
print("{} {}".format(min_s, max_s))
icnt_avg = np.average(icnt_list)
bcnt_avg = np.average(bcnt_list)
print("avg. rcnt = {}".format(rcnt_avg))
print("b/r avg. {}".format(br_avg))
- plt.rcParams["figure.figsize"] = [12, 12]
+ plt.rcParams["figure.figsize"] = [12, 8]
plt.rcParams["font.size"] = 24
plt.rcParams["font.family"] = "cmr10"
plt.rcParams["hatch.linewidth"] = 1.0
f, ax = plt.subplots()
eax = ax.twinx()
ax.set_title(scenarios[0]["fn"])
+ ax.set_title("Scenario 8: Final path cost after optimization")
+ #ax.set_title("Scenario 2: Final path cost after optimization")
+ #ax.set_title("Scenario 7: Final path cost after optimization")
ax.set_xlabel("Number of iterations [-]")
ax.set_ylabel("Cost [m]")
- eax.set_ylabel("Finished with no path [%]")
- ax.set_ylim([0, 100])
+ eax.set_ylabel("Success rate [%]")
+ #ax.set_ylim([20.1, 57]) # scenario 7
+ #ax.set_ylim([18, 43]) # scenario 2
+ ax.set_ylim([10, 60])
eax.set_ylim([0, 100])
eax.fill_between(
y2=[i for i in err_hist],
color="tab:red",
alpha=0.2,
- label="No path found",
+ label="Succes rate",
)
la = [
- "Minimum and maximum",
- "10 % and 90 % percentile",
- "20 % and 80 % percentile",
- "30 % and 70 % percentile",
- "40 % and 60 % percentile",
- "Median",
+ "Min. to max.",
+ "10 - 90 %",
+ "20 - 80 %",
+ "30 - 70 %",
+ "40 - 60 %",
+ #"Median",
]
- for j in range(6):
+ for j in range(5):
ax.fill_between(
x=range(L),
y1=[perc(val_list[i], 50 - (5-j)*10) for i in range(L)],
ax.minorticks_on()
ax.tick_params(axis='x', labelrotation=45)
- ax.legend(loc="upper left")
- eax.legend(loc="upper right")
+ h1, la1 = ax.get_legend_handles_labels()
+ h2, la2 = eax.get_legend_handles_labels()
+
+ h = h1 + h2
+ la = la1 + la2
+
+ ax.legend(h, la, loc="upper right", ncol=1)
plt.savefig("out.pdf", bbox_inches="tight")
plt.close()