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

[freehaven-cvs] Add ability to track how many rounds it took to put ...



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

Modified Files:
	Makefile simmain.cpp trials.cpp trials.h vec.h 
Log Message:
Add ability to track how many rounds it took to put M of the recipients in the top N.

Index: Makefile
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/Makefile,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Makefile	22 Nov 2003 23:36:24 -0000	1.5
+++ Makefile	23 Nov 2003 06:26:23 -0000	1.6
@@ -5,7 +5,7 @@
 	./test
 
 CXX=g++
-CFLAGS=-Wall -O2 -g -DFAST_RANDOM
+CFLAGS=-Wall -O2 -g -DFAST_RANDOM -DQUIET
 
 clean:
 	rm -f *.o *~ sim test

Index: simmain.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/simmain.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- simmain.cpp	22 Nov 2003 23:32:22 -0000	1.4
+++ simmain.cpp	23 Nov 2003 06:26:23 -0000	1.5
@@ -64,7 +64,7 @@
   s.setNRecipients(100).setNAliceRecipients(5).setPathLen(3).setPDelay(0.5)
     .setExpAlice(0.5).setPMessage(0.6).setPDummy(0.2).setBGVolMean(30)
     .setBGVolDev(3).setPadding(0).setGranularity(20)
-    .setPartial(true).setPObserve(.6).setCutoff(1000000);
+    .setPartial(true).setPObserve(.9).setCutoff(1000000);
   MixTrial trial(s);
   //MixTrial trial(100, 5, 3, 0.5, true, 0.6, 0.2, 30, 3, 0, 20, true, 0.4);
   percentiles p;

Index: trials.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/trials.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- trials.cpp	22 Nov 2003 23:32:22 -0000	1.3
+++ trials.cpp	23 Nov 2003 06:26:23 -0000	1.4
@@ -31,7 +31,8 @@
     out << ". observed rounds: "<<nRoundsObserved<<" (alice maybe in "
         << nRoundsMaybeAlice << ")";
   }
-  out << "]";
+  out << "] ";
+  pvec(out, roundsToGuessN);
 }
 
 std::ostream &
@@ -44,6 +45,9 @@
 BatchTrial::attempt()
 {
   TrialResult res;
+  unsigned int nGuessed = 0;
+  res.roundsToGuessN.reserve(truth.size()+1);
+  res.roundsToGuessN.push_back(0);
 
   mixnet->reset();
   attacker->reset();
@@ -80,7 +84,13 @@
       pvec(std::cout, recips.topN(truth.size()));
       std::cout << n << " ------ " << std::endl;
 #endif
-      if (truth == recips.topN(truth.size())) {
+      unsigned matches = nSortedVecMatch(recips.topN(truth.size()), truth);
+      while (matches > nGuessed) {
+	res.roundsToGuessN.push_back(n);
+	++nGuessed;
+      }
+      //if (truth == recips.topN(truth.size())) {
+      if (matches == truth.size()) {
 	res.nRounds = n;
         return res;
       }
@@ -177,6 +187,9 @@
 NonbatchTrial::attempt()
 {
   TrialResult res;
+  res.roundsToGuessN.reserve(truth.size());
+  res.roundsToGuessN.push_back(0);
+  unsigned int nGuessed = 0;
 
   attacker->reset();
   mixnet->reset();
@@ -205,7 +218,7 @@
 	attacker->guessAlice(recips);
 	res.nRounds = n;
 	res.failed = true;
-	std::cout << "Got only "<<nVecMatch(recips.topN(truth.size()),truth)
+	std::cout << "Got only "<<nSortedVecMatch(recips.topN(truth.size()),truth)
 		  << " / " << truth.size() << std::endl;
 	return res;
       }
@@ -216,8 +229,14 @@
       pvec(std::cout, recips.topN(truth.size()));
       std::cout << n << " ------ " << std::endl;
 #endif
-      if (truth == recips.topN(truth.size())) {
-        res.nRounds = n;
+      unsigned matches = nSortedVecMatch(recips.topN(truth.size()), truth);
+      while (matches > nGuessed) {
+	res.roundsToGuessN.push_back(n);
+	++nGuessed;
+      }
+      //if (truth == recips.topN(truth.size())) {
+      if (matches == truth.size()) {
+	res.nRounds = n;
         return res;
       }
     }

Index: trials.h
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/trials.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- trials.h	22 Nov 2003 23:32:22 -0000	1.3
+++ trials.h	23 Nov 2003 06:26:23 -0000	1.4
@@ -20,6 +20,7 @@
   long nMsgs;
   long nMsgsAlice; 
   long nMsgsAliceReal;
+  std::vector<int> roundsToGuessN;
 
   bool failed;
 

Index: vec.h
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/vec.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- vec.h	22 Nov 2003 23:32:22 -0000	1.2
+++ vec.h	23 Nov 2003 06:26:23 -0000	1.3
@@ -235,4 +235,28 @@
   return n;
 }
 
+inline int
+nSortedVecMatch(const std::vector<int> &a, const std::vector<int> &b)
+{
+  int n = 0;
+  typedef std::vector<int>::const_iterator iter;
+  iter i1 = a.begin();
+  iter i2 = b.begin();
+  if (i1 == a.end() || i2 == b.end()) 
+    return 0;
+  while (1) {
+    if (*i1 == *i2) {
+      ++n; ++i1; ++i2; 
+      if (i1 == a.end() || i2 == b.end()) 
+	return n;
+    } else if (*i1 < *i2) {
+      ++i1;
+      if (i1 == a.end()) return n;
+    } else {
+      ++i2;
+      if (i2 == b.end()) return n;
+    }
+  }
+}
+
 #endif /* _VEC_H */

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