# [tor-commits] [metrics-tasks/master] Consider excluded relays as well

karsten at torproject.org karsten at torproject.org
Tue Oct 23 16:32:57 UTC 2012

```commit 1dae123586ad3ccf1a8c9756770dbfb483da14d1
Author: Sathyanarayanan Gunasekaran <gsathya.ceg at gmail.com>
Date:   Tue Oct 23 19:01:01 2012 +0530

Consider excluded relays as well
---
1 files changed, 17 insertions(+), 8 deletions(-)

index 1f7187a..3bc6de1 100644
@@ -107,7 +107,7 @@ def run(file_name):
if len(routers) <= 0:
return

-    # Find probability of each relay in pristine consensus
+    # Find probability of each relay in pristine consensus
total_bw = 0
for router in routers:
total_bw += router.bandwidth
@@ -118,7 +118,10 @@ def run(file_name):
# sort list of routers based on adv_bw

-    while(len(routers)>1):
+    omitted_routers = 0
+
+    while(omitted_routers<=len(routers)):
total_bw = 0

# this is the difference btw probability of choosing a relay in pristine
@@ -126,24 +129,30 @@ def run(file_name):
# consensus; prob_diff is the list of such differences for all relays
prob_diff = []

-
for router in routers:
total_bw += router.bandwidth

for router in routers:
-            new_prob = float(router.bandwidth)/float(total_bw)
+            if router.bandwidth > 0:
+                new_prob = float(router.bandwidth)/float(total_bw)
+            else:
+                new_prob = 0
diff = abs(new_prob - router.prob)
prob_diff.append(diff)

result_string.append(','.join([valid_after,
-                                      str(len(routers)),
+                                      str(len(routers)-omitted_routers),
str(max(prob_diff))]))

# remove routers with min adv_bw
-            del routers[0]
+        for router in routers:
+                omitted_routers += 1
+                router.bandwidth = 0