예제 #1
0
    def loadBus(self, data, kernel):
        if 'bus' in data:
            bus_capacity = data['bus']['capacity']
            for line in data['bus']['lines']:
                name = line['name']
                transport_count = line['bus number']
                stops = line['stops']
                durations = line['durations']

                l = Line(name, transport_count, bus_capacity)

                l.addNode(stops[0])

                for node_name, duration in zip(stops[1:], durations):
                    l.addNode(node_name, duration)

                kernel.addLine(l)
            if 'connections' in data['bus']:
                for conn in data['bus']['connections']:
                    s1, s2 = conn['connection']
                    s1, s2 = f'{s1["line"]}_{s1["stop"]}', f'{s2["line"]}_{s2["stop"]}'
                    duration = conn['duration']
                    kernel.addInterconnection(s1, s2, duration)
예제 #2
0
def main():
    env = simpy.Environment()

    kernel = Kernel(env)

    l1 = Line('Line1', 10)
    l1.addNode('0')
    for i in range(1, 12):
        l1.addNode(str(i), randint(10, 15))

    kernel.addLine(l1)

    l2 = Line('Line2', 10)
    l2.addNode('0')
    for i in range(1, 12):
        l2.addNode(str(i), randint(5, 8))

    kernel.addLine(l2)

    kernel.addInterconnection('Line1_1', 'Line2_2', 20)
    kernel.addInterconnection('Line1_3', 'Line2_10', 20)
    kernel.addInterconnection('Line1_8', 'Line2_1', 20)

    kernel.buildPassengers(1000)

    kernel.graph.nodes['Line1_1'].shop = Sandwicherie(env)
    kernel.graph.nodes['Line2_2'].shop = Sandwicherie(env)

    kernel.graph.nodes['Line1_3'].shop = BoutiqueSouvenirs(env)
    kernel.graph.nodes['Line2_10'].shop = Sandwicherie(env)

    kernel.graph.nodes['Line1_8'].shop = BoutiqueSouvenirs(env)
    kernel.graph.nodes['Line2_1'].shop = BoutiqueSouvenirs(env)

    kernel.buildTransports()

    kernel.run()

    env.run(until=1000)