[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[freehaven-cvs] Graphs for all cases except 5a and 5b. More scraps ...



Update of /home/freehaven/cvsroot/doc/e2e-traffic/src
In directory moria.mit.edu:/tmp/cvs-serv27439/src

Modified Files:
	analyze.py combine.py postproc.py 
Log Message:
Graphs for all cases except 5a and 5b.  More scraps data are forthcoming for 5a, 2, and 6.

Index: analyze.py
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/analyze.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- analyze.py	22 Jan 2004 03:52:25 -0000	1.6
+++ analyze.py	23 Jan 2004 00:34:19 -0000	1.7
@@ -79,6 +79,7 @@
     return int(x*100)
 
 class RecipientDistribution:
+    MAXIMUM = 2000000 #off the scale
     def __init__(self, M):
         self.M=M
         self.items = 0
@@ -99,15 +100,19 @@
     def addResult(self,res):
         got=len(res)-1
         self.items += 1
+        lastidx=0
         for idx, pos in self.positions:
             if got>=pos:
                 self.lst[idx].append(res[pos])
+                lastidx = idx
+        for idx in xrange(lastidx+1, len(self.positions)):
+            self.lst[idx].append(self.MAXIMUM)
         for r in res[1:]:
             try:
                 self.nGuessedAtRoundN[r] += 1
             except KeyError:
                 self.nGuessedAtRoundN[r] = 1
-    def getPercentile(self,pctile):
+    def getPercentile(self,pctile,maximum=2000000): # off the scale
         r = []
         p = int(math.ceil(self.items * (pctile/100.0)))
         for l in self.lst:
@@ -115,7 +120,7 @@
             if p < len(l):
                 r.append(l[p])
             else:
-                r.append(None)
+                r.append(maximum)
         return r
 
 class ResultSet:

Index: combine.py
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/combine.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- combine.py	22 Jan 2004 03:52:25 -0000	1.1
+++ combine.py	23 Jan 2004 00:34:19 -0000	1.2
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.3
+#!/usr/bin/env python2.3
 import sys
 
 f1 = sys.argv[1]

Index: postproc.py
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/postproc.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- postproc.py	22 Jan 2004 03:52:25 -0000	1.3
+++ postproc.py	23 Jan 2004 00:34:19 -0000	1.4
@@ -1,7 +1,12 @@
-#!/usr/bin/python
+#!/usr/bin/env python2.3
 # post-process a results file
 
+import os
 import re
+import sys
+
+MINSIZE = int(os.environ.get("MINSIZE", 0))
+CLIP = int(os.environ.get("CLIP", 0))
 
 def val(s):
     try:
@@ -9,7 +14,7 @@
     except ValueError:
         return s
 
-def pp(fn, fixed, xvar, yvar, gvars):
+def pp(fn, fixed, blocked, xvar, yvar, gvars):
     f = open(fn, 'r')
     data = {}
     for line in f.xreadlines():
@@ -18,44 +23,82 @@
         items = line.split()
         xval=yval=None
         gvals = []
+        skip = 0
+        drop = 0
         for item in items:
             c = item.split(":")
             if len(c) == 2:
                 if fixed.has_key(c[0]):
-                    if fixed[c[0]] != c[1]:
-                        continue
+                    if not fixed[c[0]].has_key(c[1]):
+                        #print >>sys.stderr, fixed[c[0]], '!=', c[1]
+                        skip = 1
+                        break
+                    #else:
+                    #    print >>sys.stderr, c[0], '==', c[1]
+                elif blocked.has_key(c[0]):
+                    if blocked[c[0]].has_key(c[1]):
+                        skip = 1
+                        break                        
                 if c[0] == xvar and xval is None:
                     xval = float(c[1])
                 elif c[0] == yvar:
-                    yval = float(c[1])
+                    if c[1] == 'None':
+                        yval = None
+                    else:
+                        yval = float(c[1])
                 elif c[0] in gvars:
                     gvals.append((gvars.index(c[0]),c[0],val(c[1])))
+        if skip: continue
         gvals.sort()
         if xval == None:
-            print "missing",xvar
+            print >>sys.stderr, "missing",xvar,"for",gvals
             continue
         if yval == None:
-            print "missing",yvar
+            print >>sys.stderr, "missing",yvar,"for",gvals
             continue
         data.setdefault(tuple(gvals), []).append((xval,yval))
     ks = data.keys()
     ks.sort()
     for group in ks:
-        print
-        print "# ","; ".join(["%s=%s"%(k,v) for idx,k,v in group])
         d = data[group]
         d.sort()
+        if CLIP:
+            values = [ v for k,v in d ]
+            values.reverse()
+            for i in xrange(1,len(values)):
+                if values[i] == values[0]:
+                    del d[len(values)-1-i]
+                else:
+                    break
+
+        if len(d) < MINSIZE:
+            continue
+        print "\n\n# ","; ".join(["%s=%s"%(k,v) for idx,k,v in group])
+
         for x,y in d:
-            print x,y
+            if y is None: 
+                continue
+            else:
+                print x,y
 
 if __name__ == '__main__':
     import sys
     fn = sys.argv[1]
     fixed = {}
-    while "=" in sys.argv[2]:
-        k,v= sys.argv[2].split("=")
-        fixed[k]=v
-        del sys.argv[2]
+    blocked = {}
+    while 1: 
+        if "=" in sys.argv[2]:
+            k,v= sys.argv[2].split("=")
+            for i in v.split(","):
+                fixed.setdefault(k,{})[i]=1
+            del sys.argv[2]
+        elif "#" in sys.argv[2]:
+            k,v= sys.argv[2].split("#")
+            for i in v.split(","):
+                blocked.setdefault(k,{})[i]=1
+            del sys.argv[2]
+        else:
+            break            
     xv = sys.argv[2]
     yv = sys.argv[3]
     gv = sys.argv[4:]
@@ -63,4 +106,14 @@
     print "# x variable:",xv
     print "# y variable:",yv
     print "# grouped by:",gv
-    pp(fn,fixed,xv,yv,gv)
+    for k,vals in fixed.iteritems():
+        vallist = vals.keys()
+        vallist.sort()
+        print "#     %s in %s"%(k,v)
+    for k,vals in blocked.iteritems():
+        vallist = vals.keys()
+        vallist.sort()
+        print "#     %s not in %s"%(k,vallist)
+    pp(fn,fixed,blocked,xv,yv,gv)
+    print
+    

***********************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe freehaven-cvs       in the body. http://freehaven.net/