aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincenzo Maffione <[email protected]>2017-03-24 11:42:24 +0100
committerVincenzo Maffione <[email protected]>2017-03-24 11:42:24 +0100
commit5f1aaa9c7bea51458385af7620bd847f059fa815 (patch)
tree58ca4841923225947da2f8fc4e62781cb1a331d1
parentdeb35ef8497e1f792a6b84afe9d9b5da424f22b3 (diff)
downloadrumba-5f1aaa9c7bea51458385af7620bd847f059fa815.tar.gz
rumba-5f1aaa9c7bea51458385af7620bd847f059fa815.zip
model: store the enrollments as a global list to preserve global ordering
-rw-r--r--rumba/model.py46
1 files changed, 21 insertions, 25 deletions
diff --git a/rumba/model.py b/rumba/model.py
index 6d6ffee..4f3e72a 100644
--- a/rumba/model.py
+++ b/rumba/model.py
@@ -302,14 +302,11 @@ class IPCP:
self.node = node
self.dif = dif
self.registrations = []
- self.enrollments = []
def __repr__(self):
- return "{IPCP=%s,DIF=%s,N-1-DIFs=(%s),enrollments=(%s)}" % \
+ return "{IPCP=%s,DIF=%s,N-1-DIFs=(%s)}" % \
(self.name, self.dif.name,
- ' '.join([dif.name for dif in self.registrations]),
- ' '.join(['{neigh=%s,N-1-DIF=%s}' % (e['enroller'].name,
- e['lower_dif'].name) for e in self.enrollments])
+ ' '.join([dif.name for dif in self.registrations])
)
def __hash__(self):
@@ -345,7 +342,7 @@ class Experiment:
self.testbed = testbed
self.enrollment_strategy = 'minimal' # 'full-mesh', 'manual'
self.dif_ordering = []
- self.enrollments = dict()
+ self.enrollments = [] # a list of per-DIF lists of enrollments
# Generate missing information
self.generate()
@@ -439,10 +436,10 @@ class Experiment:
print("DIF topological ordering: %s" % self.dif_ordering)
- # Compute per-DIF enrollments, to be called after compute_dif_ordering()
+ # Compute all the enrollments, to be called after compute_dif_ordering()
def compute_enrollments(self):
dif_graphs = dict()
- self.enrollments = dict()
+ self.enrollments = []
for dif in self.dif_ordering:
neighsets = dict()
@@ -471,7 +468,7 @@ class Experiment:
if node1 != node2:
dif_graphs[dif][node1].append((node2, lower_dif))
- self.enrollments[dif] = []
+ self.enrollments.append([])
if first == None:
# This is a shim DIF, nothing to do
@@ -493,33 +490,37 @@ class Experiment:
for edge in dif_graphs[dif][cur]:
if edge[0] not in enrolled:
enrolled.add(edge[0])
- self.enrollments[dif].append({'enrollee': edge[0],
- 'enroller': cur,
- 'lower_dif': edge[1]})
+ self.enrollments[-1].append({'dif': dif,
+ 'enrollee': edge[0],
+ 'enroller': cur,
+ 'lower_dif': edge[1]})
frontier.add(edge[0])
elif self.enrollment_strategy == 'full-mesh':
for cur in dif_graphs[dif]:
for edge in dif_graphs[dif][cur]:
if cur < edge[0]:
- self.enrollments[dif].append({'enrollee': cur,
- 'enroller': edge[0],
- 'lower_dif': edge[1]})
+ self.enrollments[-1].append({'dif': dif,
+ 'enrollee': cur,
+ 'enroller': edge[0],
+ 'lower_dif': edge[1]})
else:
# This is a bug
assert(False)
- print("Enrollments for %s" % dif)
- for e in self.enrollments[dif]:
- print(" %s --> %s through N-1-DIF %s" % \
- (e['enrollee'].name,
+ print("Enrollments:")
+ for el in self.enrollments:
+ for e in el:
+ print(" [%s] %s --> %s through N-1-DIF %s" % \
+ (e['dif'],
+ e['enrollee'].name,
e['enroller'].name,
e['lower_dif']))
def compute_ipcps(self):
# For each node, compute the required IPCP instances, and associated
- # registrations and enrollments
+ # registrations
for node in self.nodes:
node.ipcps = []
# We want also the node.ipcps list to be generated in
@@ -536,11 +537,6 @@ class Experiment:
for lower in node.dif_registrations[dif]:
ipcp.registrations.append(lower)
- for e in self.enrollments[dif]:
- if e['enrollee'] == node:
- ipcp.enrollments.append({'enroller': e['enroller'],
- 'lower_dif': e['lower_dif']})
-
node.ipcps.append(ipcp)
print("IPCP for node %s: %s" % (node.name, node.ipcps))