]> rtime.felk.cvut.cz Git - hubacji1/iamcar2.git/blobdiff - scripts/print_json_objects_scenaris_statistics.py
Fix private member name
[hubacji1/iamcar2.git] / scripts / print_json_objects_scenaris_statistics.py
index 5d01907d6149509485115b6b200439ef26cba138..96dd4c3e516e4bff89b861b78c60d23a07cb267f 100644 (file)
@@ -63,12 +63,28 @@ def compute_stats(sl={}, what="time"):
     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]
@@ -78,7 +94,7 @@ def compute_stats(sl={}, what="time"):
         wl.sort()
         wl_med = wl[round(len(wl) / 2)]
     return {
-        "err": 100 * (len(sl) - len(wl)) / len(sl),
+        "err": 100 * (len(sl) - len(el)) / len(sl),
         "avg": wl_mean,
         "std": wl_std,
         "med": wl_med,
@@ -160,7 +176,7 @@ if __name__ == "__main__":
         col = compute_stats(sl, "connecteds-in-path")
         nl = compute_stats(sl, "nodes")
         print(gos().format(
-                tl["err"], sl[0]["dn"], sl[0]["fn"],
+                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"],