diff options
author | Sander Vrijders <[email protected]> | 2017-03-24 10:51:46 +0000 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-03-24 10:51:46 +0000 |
commit | b770d57b11de901ee3665611e97194a82f2ec55e (patch) | |
tree | 0952be3fa006d140b91936db6c9697e321d1de76 | |
parent | 1b539c74fb11caa327087782d5660270daa5d135 (diff) | |
parent | 5f1aaa9c7bea51458385af7620bd847f059fa815 (diff) | |
download | rumba-b770d57b11de901ee3665611e97194a82f2ec55e.tar.gz rumba-b770d57b11de901ee3665611e97194a82f2ec55e.zip |
Merge branch 'vincenzo' into 'master'
model: store the enrollments as a global list to preserve global ordering
See merge request !12
-rw-r--r-- | rumba/model.py | 46 |
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)) |