【问题标题】:Simulate types of customers on a 9AM-6PM basis在上午 9 点到下午 6 点模拟客户类型
【发布时间】:2020-09-19 21:23:28
【问题描述】:

我开始在 Python 中通过 SimPy 进行模拟,但在模拟 A 类客户(占客户总数的 25%)、B 类客户(30%)、C 类客户(35%)和客户的均匀分布到达时卡住了D 型 (10%) 每天上午 9 点到下午 6 点。

有人知道如何处理吗?

提前谢谢你:)

【问题讨论】:

标签: python simulation simpy


【解决方案1】:

这是我如何模拟 100 名客户的到来。

import random

p = ['A', 'B', 'C', 'D']
w = [0.25, 0.30, 0.35, 0.10]

size = 100
customers = random.choices(
    population=p,
    weights=w,
    k=size)

counts = { x: 0 for x in p }

for x in customers:
    counts[x] += 1 

print({x: counts[x]/size for x in counts})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-20
    • 1970-01-01
    • 2015-11-22
    • 2015-01-29
    • 1970-01-01
    • 2010-09-17
    相关资源
    最近更新 更多