if f not in s:
s[f] = []
s[f].append({
+ "dn": dname,
"fn": f,
"cnt": int(d),
"sc": get_scenario("{}/{}/{}".format(dname, d, f)),
return s
def compute_stats(sl={}, what="time"):
- """Return ``mean``, ``std``, ``max``, and ``min`` of ``what``.
+ """Return ``mean``, ``std``, ``med``, ``max``, and ``min`` of ``what``.
Keyword arguments:
sl -- Scenarios list.
what -- The variable in scenario stats to compute with.
"""
assert len(sl) > 0
- wl = [s["sc"][what] for s in sl if "sc" in s and what in s["sc"]]
+ wl = [
+ s["sc"][what] for s in sl
+ if "sc" in s
+ and what in s["sc"]
+ and (
+ "cost" in s["sc"]
+ and s["sc"]["cost"] != 9999
+ )
+ ]
+ el = [
+ 1 for s in sl
+ if "sc" in s
+ and "cost" in s["sc"]
+ and s["sc"]["cost"] != 9999
+ and s["sc"]["cost"] != -1
+ ]
if len(wl) == 0:
wl_mean = inf
wl_std = inf
wl_max = inf
wl_min = -inf
+ wl_med = inf
else:
wl_mean = sum(wl) / len(wl)
wl_tmp = [(x - wl_mean)**2 for x in wl]
wl_std = (sum(wl_tmp) / len(wl_tmp))**0.5
wl_max = max(wl)
wl_min = min(wl)
+ wl.sort()
+ wl_med = wl[round(len(wl) / 2)]
return {
- "err": 100 * (len(sl) - len(wl)) / len(sl),
- "mean": wl_mean,
+ "err": 100 * (len(sl) - len(el)) / len(sl),
+ "avg": wl_mean,
"std": wl_std,
+ "med": wl_med,
"max": wl_max,
"min": wl_min,
}
Keyword arguments:
h -- String for header?
"""
- pr = "{:<8.2f}" if not h else "{:<8}"
+ pr = "{:<16.2f}" if not h else "{:<16}"
pr += "{:<16}"
- for i in range(8):
- pr += " {:<16.6f}" if not h else " {:<16}"
+ pr += "{:<16}"
+ pr += "{:<16}"
+ pr += "{:<16}"
+ for i in range(30): # 5 (from compute_stats) x 6 (stats in README)
+ pr += "{:<16.6f}" if not h else "{:<16}"
return pr
scenarios = get_scenarios(SCEN_DIR)
key=lambda kv: int(kv[0]) if kv[0].isnumeric() else kv[0]
)
print(gos(True).format(
- "%err [%]",
- "filename",
- "max [s]",
- "min [s]",
- "avg [s]",
- "stddev [s]",
- "max [m]",
- "min [m]",
- "avg [m]",
- "stddev [m]",
+ "%--------------|", "---------------|", "---------------|",
+ "---------------|", "---------------|",
+
+ "----------------", "----------------",
+ "time",
+ "----------------", "---------------|",
+
+ "----------------", "----------------",
+ "iterations",
+ "----------------", "---------------|",
+
+ "----------------", "----------------",
+ "cost",
+ "----------------", "---------------|",
+
+ "----------------", "----------------",
+ "cusps-in-path",
+ "----------------", "---------------|",
+
+ "----------------", "----------------",
+ "connecteds-in-pa", "th",
+ "---------------|",
+
+ "----------------", "----------------",
+ "nodes",
+ "----------------", "---------------|",
+ ))
+ print(gos(True).format(
+ "%err [%]", "planner", "filename",
+ "-", "-",
+ "avg [s]", "std [s]", "med [s]", "max [s]", "min [s]", # time
+ "avg [-]", "std [-]", "med [-]", "max [-]", "min [-]", # iterations
+ "avg [m]", "std [m]", "med [m]", "max [m]", "min [m]", # cost
+ "avg [-]", "std [-]", "med [-]", "max [-]", "min [-]", # cusps-in-p
+ "avg [-]", "std [-]", "med [-]", "max [-]", "min [-]", # connecteds
+ "avg [-]", "std [-]", "med [-]", "max [-]", "min [-]", # nodes
))
print()
for (f, sl) in scenarios:
+ assert f == sl[0]["fn"]
tl = compute_stats(sl, "time")
+ il = compute_stats(sl, "iterations")
cl = compute_stats(sl, "cost")
+ cul = compute_stats(sl, "cusps-in-path")
+ col = compute_stats(sl, "connecteds-in-path")
+ nl = compute_stats(sl, "nodes")
print(gos().format(
- tl["err"],
- f,
- tl["max"],
- tl["min"],
- tl["mean"],
- tl["std"],
- cl["max"],
- cl["min"],
- cl["mean"],
- cl["std"],
+ tl["err"], sl[0]["dn"][:15], sl[0]["fn"],
+ "-", "-",
+ tl["avg"], tl["std"], tl["med"], tl["max"], tl["min"],
+ il["avg"], il["std"], il["med"], il["max"], il["min"],
+ cl["avg"], cl["std"], cl["med"], cl["max"], cl["min"],
+ cul["avg"], cul["std"], cul["med"], cul["max"], cul["min"],
+ col["avg"], col["std"], col["med"], col["max"], col["min"],
+ nl["avg"], nl["std"], nl["med"], nl["max"], nl["min"],
))