14_MM1.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:chapter_codes 作者: advancedpythonprogramming 项目源码 文件源码
def sim_configuration(env,  num_machines,
                      washing_time,
                      arrival_time):
    ''' In this routine: washing machines are created, an initial number of
    vehicles (2) and then vehicles arrive at a rate of 1 / arrival_time'''

    # Create a washing machine
    machine = WashingMachine(env, num_machines, washing_time)

    # 2 vehicles are created and put in to the queue
    print('In the queue there are already 2 vehicles')
    for i in range(2):
        env.process(vehicle(env, 'Vehicle {0}'.format(i), machine))

    # While the machine runs vehicles arrive at a rate of 1 / arrival_time
    while True:
        yield env.timeout(round(random.expovariate(1 / arrival_time)))
        i += 1
        env.process(vehicle(env, 'Vehicle {0}'.format(i), machine))


# Simulation configuration
# random.seed(RANDOM_SEED)

# Simulation environment creation
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号