plot-node-selection.R 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ## Load in data files
  2. t1 = read.table("opt_1e-6.pickle.dat", header=TRUE)
  3. t2 = read.table("opt_1e-3.pickle.dat", header=TRUE)
  4. t3 = read.table("opt_1e-1.pickle.dat", header=TRUE)
  5. t4 = read.table("opt_0.75.pickle.dat", header=TRUE)
  6. t5 = read.table("opt_0.5.pickle.dat", header=TRUE)
  7. t6 = read.table("opt_0.25.pickle.dat", header=TRUE)
  8. t7 = read.table("opt_0.1.pickle.dat", header=TRUE)
  9. tt = read.table("opt_tor.pickle.dat", header=TRUE)
  10. ## Calculate selection probabilties that Tor uses
  11. o = t1$bw/sum(t1$bw)
  12. #plot(t1$bw, cumsum(t1$prob), col="red", type="l")
  13. #lines(t1$bw, cumsum(t2$prob), col="pink")
  14. #lines(t1$bw, cumsum(t3$prob), col="blue")
  15. #lines(t1$bw, cumsum(t4$prob), col="orange")
  16. #lines(t1$bw, cumsum(t5$prob), col="purple")
  17. #lines(t1$bw, cumsum(tt$prob))
  18. ## Plot probabiltieis
  19. pdf("optimum-selection-probabilities.pdf")
  20. col <- rainbow(8)
  21. plot(t1$bw, t1$prob, col=col[1], type="b", ylim=c(0,0.035),xlab="Bandwidth (cells/s)",
  22. ylab="Selection probability", frame.plot=FALSE)
  23. lines(t1$bw, t2$prob, col=col[2], type="b")
  24. lines(t1$bw, t3$prob, col=col[3], type="b")
  25. lines(t1$bw, t4$prob, col=col[4], type="b")
  26. lines(t1$bw, t5$prob, col=col[5], type="b")
  27. ## These are too messy
  28. ##lines(t1$bw, t6$prob, col=col[6], type="b")
  29. ##lines(t1$bw, t7$prob, col=col[7], type="b")
  30. lines(t1$bw, tt$prob,col=col[8], type="b")
  31. lines(t1$bw, o, type="l", lwd=2)
  32. ## Annotate graph
  33. title(main="Optimum node selection probability")
  34. x <- rep(8254.383, 4)
  35. y <- c(0.03453717, 0.02553347, 0.02219589, 0.02048830)
  36. par(xpd=TRUE)
  37. text(x,y,c("50%", "75%", "90%", ">99%"), adj=c(0,0.5))
  38. dev.off()
  39. ## Plot probabilities relative to what Tor does
  40. pdf("relative-selection-probabilities.pdf")
  41. plot(t1$bw, t1$prob-o, col=col[1], type="b", xlab="Bandwidth (cells/s)",
  42. ylab="Selection probability - Tor's selection probability", frame.plot=FALSE, ylim=c(-0.002,0.015))
  43. lines(t1$bw, t2$prob-o, col=col[2], type="b")
  44. lines(t1$bw, t3$prob-o, col=col[3], type="b")
  45. lines(t1$bw, t4$prob-o, col=col[4], type="b")
  46. lines(t1$bw, t5$prob-o, col=col[5], type="b")
  47. lines(t1$bw, tt$prob-o,col=col[8], type="b")
  48. lines(range(t1$bw), rep(0,2), lty=2)
  49. title(main="Selection probabilility compared to Tor")
  50. x <- rep(8111.669, 4)
  51. y <- c(1.396915e-02, 4.962766e-03, 1.635106e-03, 7.446809e-06)
  52. par(xpd=TRUE)
  53. text(x,y,c("50%", "75%", "90%", ">99%"), adj=c(0,0.5))
  54. dev.off()