]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/commitdiff
Add nothing done statistics
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 21 Jan 2019 11:47:58 +0000 (12:47 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Wed, 23 Jan 2019 15:38:34 +0000 (16:38 +0100)
base/main.cc
gplot.py

index 0a874317c38603f6e8a07d3d35b34e533e710298..4643254d558eda1bb90e3c2ddc7d20016fdbf0e6 100644 (file)
@@ -197,14 +197,19 @@ int main()
         p.p_goal_.tstart();
         pthread_create(&rt, NULL, &next_run, (void *) &ra);
         pthread_create(&gt, NULL, &next_run, (void *) &ga);
+        int tol = 0;
+        int ndl = 0;
+        bool ndone = true;
         while (!gf && p.elapsed() < TMAX &&
                         p.p_root_.nodes().size() < NOFNODES &&
                         p.p_goal_.nodes().size() < NOFNODES) {
                 // overlap trees
+                ndone = true;
                 for (int i = 0; i < IXSIZE; i++) {
                 for (int j = 0; j < IYSIZE; j++) {
                         if (p.p_root_.ixy_[i][j].changed() &&
                                         p.p_goal_.ixy_[i][j].changed()) {
+ndone = false;
 for (auto rn: p.p_root_.ixy_[i][j].nodes()) {
 for (auto gn: p.p_goal_.ixy_[i][j].nodes()) {
         if (rn->ccost() + gn->ccost() < mc &&
@@ -217,6 +222,9 @@ for (auto gn: p.p_goal_.ixy_[i][j].nodes()) {
         }
 }}
                         }
+                        tol++;
+                        if (ndone)
+                                ndl++;
                         p.tend();
                         if (p.elapsed() >= TMAX)
                                 goto escapeloop;
@@ -227,6 +235,12 @@ for (auto gn: p.p_goal_.ixy_[i][j].nodes()) {
 escapeloop:
         pthread_join(rt, NULL);
         pthread_join(gt, NULL);
+        float nodo = ((float) ndl / (float) tol);
+        std::cerr << "nothing done is " << 100.0 * nodo;
+        std::cerr << "%" << std::endl;
+        //std::cerr << "rgf is " << p.p_root_.goal_found() << std::endl;
+        //std::cerr << "ggf is " << p.p_goal_.goal_found() << std::endl;
+        //std::cerr << "cgf is " << p.goal_found() << std::endl;
         if (p.p_root_.goal_found() && p.p_root_.goal()->ccost() < mc) {
                 ron = p.p_root_.goal()->parent();
                 gon = p.p_root_.goal();
@@ -289,6 +303,7 @@ escapeloop:
 
         // JSON output
         jvo["elap"] = p.elapsed();
+        jvo["nodo"][0] = nodo;
         // log cost
         for (j = 0; j < p.clog().size(); j++)
                 jvo["cost"][j] = p.clog()[j];
index 69c1e902c8d5715a0bccec603f16996098d55d79..d675b395ae1399ce83d104a4da086bb9a58a4f99 100644 (file)
--- a/gplot.py
+++ b/gplot.py
@@ -184,6 +184,36 @@ def plot_maxtime():
     plt.legend()
     plt.show()
 
+def plot_nothingdone():
+    """Plot *nothing done* time of ``overlaptrees`` procedure."""
+    v = {}
+    for a in r.keys():
+        v[a] = get_lasts_if_exist(r[a], "nodo")
+
+    fig = plt.figure()
+    ax = fig.add_subplot(111)
+    ax.set_title("Histogram of nothing-done-time")
+
+    ax.set_ylabel("Occurences [-]")
+    ax.set_xlabel("Nothing-done-time percentage [-]")
+
+    for a in LOG:
+        plt.hist(
+                v[a["f"]],
+                alpha = 0.5,
+                label = a["l"],
+                bins = np.arange(0, 1, 0.1),
+                histtype = "step",
+                color = a["c"])
+        try:
+                X_WHERE = np.percentile(v[a["f"]], [95])
+                plt.axvline(X_WHERE, lw=1, color=a["c"], linestyle="--")
+        except:
+                pass
+
+    plt.legend()
+    plt.show()
+
 def print_nofnodes():
     """Print average number of nodes."""
     v={}