]> AND Private Git Repository - loba-papers.git/blobdiff - loba-besteffort/data/script.r
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
[sharelatex-git-integration Best effort strategy and virtual load for asynchronous...
[loba-papers.git] / loba-besteffort / data / script.r
index 236cfd036978c193b27093020ba767bf3e9e574d..20898f9735484acbd4b7737e9acb40da46bf4ab4 100644 (file)
@@ -88,7 +88,8 @@ draw <- function(dset = ds,
   ## finally, set title
   t <- paste0(dset$Mode[1], dset$Distrib[1], " / ",
               dset$Ratio[1], " / ",
-              dset$Platform[1], " / ", dset$Topo[1])
+              dset$Platform[1], " / ",
+              dset$Topo[1])
   title(main=t)
 
   ## restore the graphical parameters
@@ -106,6 +107,7 @@ draw2 <- function(dset = ds,
 
   ## extract desired data
   dset <- subset(dset,
+                 Algo != "makhoul_bookkeeping" & #HIDE#
                  Mode == draw_mode & Distrib == draw_distrib &
                  Ratio == draw_ratio &
                  Platform == draw_platform & Topo == draw_topo)
@@ -126,85 +128,130 @@ draw2 <- function(dset = ds,
                        idvar="Algo", timevar="Size")
 
   ## rename rows
-  rownames(dset.wide) <- sub("bookkeeping", "virtual", dset.wide$Algo)
+  names <- dset.wide$Algo
+#HIDE#  names <- sub("makhoul_plain",             "a: Bertsekas and Tsitsiklis, plain", names)
+  names <- sub("makhoul_plain",             "a: Bertsekas and Tsitsiklis", names)
+  names <- sub("besteffort_plain",          "b: best effort, plain", names)
+  names <- sub("besteffort-k2_plain",       "c: best effort, k=2, plain", names)
+  names <- sub("besteffort-k4_plain",       "d: best effort, k=4, plain", names)
+#HIDE#  names <- sub("makhoul_bookkeeping",       "e: Bertsekas and Tsitsiklis, virtual", names)
+#HIDE#  names <- sub("besteffort_bookkeeping",    "f: best effort, virtual", names)
+#HIDE#  names <- sub("besteffort-k2_bookkeeping", "g: best effort, k=2, virtual", names)
+#HIDE#  names <- sub("besteffort-k4_bookkeeping", "h: best effort, k=4, virtual", names)
+  names <- sub("besteffort_bookkeeping",    "e: best effort, virtual", names)
+  names <- sub("besteffort-k2_bookkeeping", "f: best effort, k=2, virtual", names)
+  names <- sub("besteffort-k4_bookkeeping", "g: best effort, k=4, virtual", names)
+  rownames(dset.wide) <- names
   #colnames(dset.wide) <- sub("^[^.]*\\.", "", colnames(dset.wide))
 
   ## remove first column (aka "Algo")
   dset.mat <- as.matrix(dset.wide[-1])
+  nc <- nrow(dset.mat)
 
   dset.plot <- dset.mat[, c(FALSE,FALSE,TRUE)]
   barplot(dset.plot, beside=TRUE,
-          names.arg=sub("^[^.]*\\.", "", colnames(dset.plot)),
-          col=rainbow(nrow(dset.mat), s=.5))
+          axisnames=FALSE,
+#          names.arg=sub("^[^.]*\\.", "", colnames(dset.plot)),
+          col=gray.colors(nc)
+#          col=rainbow(nc, s=.5)
+          )
 
   dset.plot <- dset.mat[, c(FALSE,TRUE,FALSE)]
   barplot(dset.plot, beside=TRUE,
           axes=FALSE, axisnames=FALSE, add=TRUE,
           legend.text=TRUE,
-          args.legend=list(x="topleft", inset=c(.02,0), title="Algorithms"),
-          col=rainbow(nrow(dset.mat)))
+          args.legend=list(x="topleft", inset=c(.02,0), x.intersp=0.5, title="Algorithms"),
+          col=gray.colors(nc)
+#          col=rainbow(nc)
+          )
 
   dset.plot <- dset.mat[, c(TRUE,FALSE,FALSE)]
   barplot(dset.plot, beside=TRUE,
           axes=FALSE, axisnames=FALSE, add=TRUE,
-          col=rainbow(nrow(dset.mat), v=.5))
+          col="white"
+#          col=gray.colors(nc)
+#          col=rainbow(nc, v=.5)
+          )
 
   ## finally, set titles
-  t <- paste0(dset$Mode[1], dset$Distrib[1], " / ",
+  c <- ncol(dset.plot) - 1
+  for (l in 0:6) {
+    t <- intToUtf8(utf8ToInt("a") + l)
+    for (a in 1.5 + l + 8 * 0:c)
+      mtext(t, side=1, at=a)
+  }
+  a=4.5
+  for (s in sub("^[^.]*\\.", "", colnames(dset.plot))) {
+    mtext(s, side=1, line=1.5, at=a)
+    a <- a + 8
+  }
+  t <- paste0(
+#HIDE#              dset$Mode[1],
+#HIDE#              dset$Distrib[1], " / ",
               dset$Ratio[1], " / ",
-              dset$Platform[1], " / ", dset$Topo[1])
+#HIDE#              dset$Platform[1], " / ",
+              dset$Topo[1])
+  t <- sub("hcube", "hypercube", t)
   title(xlab="Platform size",
         ylab="Simulated time (s)",
         main=t)
 
 }
 
-msg <- function(text,
-                wait = TRUE) {
-  if (wait)
-    readline("Press <Enter> to continue\n")
-  message(text)
-}
-
 if (FALSE) {
-msg("First test, with algorithms \"plain\"...", wait = FALSE);
-draw(subset(ds, grepl("[lt]_plain", Algo)), draw_distrib="N")
 
-msg("... with draw2()...")
-draw2(subset(ds, grepl("[lt]_plain", Algo)), draw_distrib="N")
+  if (TRUE) {
+    draw2(draw_distrib="1")
+    draw2(draw_distrib="N")
+  } else {
+    msg <- function(text, wait = TRUE) {
+      if (wait)
+        readline("Press <Enter> to continue\n")
+      message(text)
+    }
 
-msg("Second test, with algorithms \"bookkeeping\"...");
-draw(subset(ds, grepl("[lt]_bookkeeping", Algo)), draw_distrib="N")
+    msg("First test, with algorithms \"plain\"...", wait = FALSE);
+    draw(subset(ds, grepl("[lt]_plain", Algo)), draw_distrib="N")
 
-msg("... with draw2()...")
-draw2(subset(ds, grepl("[lt]_bookkeeping", Algo)), draw_distrib="N")
+    msg("... with draw2()...")
+    draw2(subset(ds, grepl("[lt]_plain", Algo)), draw_distrib="N")
 
-msg("Third test, with all algorithms...");
-draw(draw_distrib="N")
+    msg("Second test, with algorithms \"bookkeeping\"...");
+    draw(subset(ds, grepl("[lt]_bookkeeping", Algo)), draw_distrib="N")
 
-msg("... with draw2()...")
-draw2(draw_distrib="N")
-}
+    msg("... with draw2()...")
+    draw2(subset(ds, grepl("[lt]_bookkeeping", Algo)), draw_distrib="N")
 
-system("mkdir -pv graphs")
-for (m in c("R", "I")) {
-  for (d in c("1", "N")) {
-    for (r in c("10:1", "1:1", "1:10")) {
-      for (t in c("line", "torus", "hcube")) {
-        for (p in c("grid", "cluster")) {
-          message(sprintf(">>> Drawing: %s%s / %s / %s / %s", m, d, r, p, t))
+    msg("Third test, with all algorithms...");
+    draw(draw_distrib="N")
+
+    msg("... with draw2()...")
+    draw2(draw_distrib="N")
+  }
+
+} else {
+
+  pdf.options(colormodel="grey")
+  system("mkdir -pv graphs")
+  for (m in c("R", "I")) {
+    for (d in c("1", "N")) {
+      for (r in c("10:1", "1:1", "1:10")) {
+        for (t in c("line", "torus", "hcube")) {
+          for (p in c("grid", "cluster")) {
+            message(sprintf(">>> Drawing: %s%s / %s / %s / %s", m, d, r, p, t))
           filename <- sprintf("graphs/%s%s-%s-%s-%s.pdf", m, d, r, p, t)
-          pdf(file=filename)
-          draw2(#subset(ds, grepl("[lt]_plain", Algo)),
-                draw_mode=m, draw_distrib=d, draw_ratio=r,
-                draw_topo=t, draw_platform=p)
-          dev.off()
-          embedFonts(file=filename, options="-dPDFSETTINGS=/prepress")
+            pdf(file=filename)
+            draw2(#subset(ds, grepl("[lt]_plain", Algo)),
+                  draw_mode=m, draw_distrib=d, draw_ratio=r,
+                  draw_topo=t, draw_platform=p)
+            dev.off()
+            embedFonts(file=filename, options="-dPDFSETTINGS=/prepress")
+          }
         }
       }
     }
   }
-}
 
-## restore default options
-options(scipen=osp)
+  ## restore default options
+  options(scipen=osp)
+}