]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/commitdiff
Add get latst/maxs functions to gplot
authorJiri Hubacek <hubacji1@fel.cvut.cz>
Fri, 21 Sep 2018 07:13:56 +0000 (09:13 +0200)
committerJiri Hubacek <hubacji1@fel.cvut.cz>
Fri, 21 Sep 2018 07:13:56 +0000 (09:13 +0200)
Function `get_lasts_if_exist` returns the list of last values of some
element of trajectory (i. e. *cost*).

Function `get_maxs_if_exist` return the list of maximum values of some
element of trajectory (i. e. *cost*).

gplot.py

index abc9e9095a5890c4f3a6b4691326c6dbccddad4b..c3e89e30058cddfefe3e4a2ab68af62505e8a06b 100644 (file)
--- a/gplot.py
+++ b/gplot.py
@@ -67,6 +67,36 @@ def count_if_exist(trajectories, what):
             pass
     return occ
 
+def get_lasts_if_exist(trajectories, what):
+    """From multiple trajectories get the list of last values.
+
+    Keyword arguments:
+    trajectories -- The list of trajectories.
+    what -- The last values of what to take.
+    """
+    val = []
+    for t in trajectories:
+        try:
+            val.append(t[what][-1])
+        except:
+            val.append(9999)
+    return val
+
+def get_maxs_if_exist(trajectories, what):
+    """From multiple trajectories get the list of maximum values.
+
+    Keyword arguments:
+    trajectories -- The list of trajectories.
+    what -- The maximum values of what to take.
+    """
+    val = []
+    for t in trajectories:
+        try:
+            val.append(max(t[what]))
+        except:
+            val.append(9999)
+    return val
+
 def plot_successrate():
     """Plot success rate of single/multi-core implementations."""
     LOGF="logs_sq"