def __init__(self, t: int, graph: Network, source: TrafficNode = None, destination: TrafficNode = None, speed_multiplier=1): if source is None: source = choice(graph.get_nodes()) destination = choice(graph.get_nodes()) while graph.get_path(source, destination) is None: source = choice(graph.get_nodes()) destination = choice(graph.get_nodes()) # Uncomment when method is implemented to replace above brute-force # destination = choice(graph.get_reachable_nodes(source)) # Define object attributes self.source = source self.destination = destination self.path = graph.get_path(source, destination) self.speed_multiplier = speed_multiplier # Define mutable object state self.remaining_path = [n for n in self.path] self.time = t # self.time is the last value of simulation time that spent given self.location = source # self.location is the Traversable object that the vehicle is currently at self.last_node = source # self.last_node is the last node spent self.traversable = Component.NODE self.timeout = 0 # Stats to track self.time_traveled = 0 self.time_waiting = 0
for drug in network.get_nodes_by_label('Drug'): if not name_utils.node_names_synonym(drug.names): drug_multiple_names_count += 1 f.write( '<tr><td>%s</td><td>%s</td></tr>\n' % (node_ids_to_links(drug.ids), '<br/>'.join(drug.names))) f.write('</tbody>\n</table>\n') f.write( '<h1><a name="loss-distinction-section">Possible loss of distinction:</a></h1>\n' ) f.write( '<table border="1">\n<thead>\n<tr><th>Node type</th><th>Node IDs</th><th>Names</th></tr>\n</thead>\n' ) f.write('<tbody>\n') for node in network.get_nodes(): id_prefix = {} for node_id in node.ids: prefix, suffix = node_id.split(':') if prefix not in id_prefix: id_prefix[prefix] = 0 id_prefix[prefix] += 1 if any([id_prefix[prefix] > 1 for prefix in id_prefix]): f.write('<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n' % (node.label, node_ids_to_links(sorted( node.ids)), '<br/>'.join(node.names))) f.write('</tbody>\n</table>\n') f.write( '<h1><a name="single-id-nodes">Nodes with single IDs:</a></h1>\n') f.write(