问题描述
我不是simpy3仿真软件包的新手,但使用银行示例实现了仿真。如何解释仿真结果,我获得了使用容量4的客户“零”等待时间,以及如何在python中可视化simpy过程。为了进行可视化,我进行了搜索,但未找到任何特定答案。请帮我理解。
Source function:
Source function is like below. SRTFunc is used to get service time.
data =pd.read_csv(path)
data=data.head(10)
number = len(data) # Total number of customers
interval = data['timeBtArrival'] # Generate new customers in minutes
customerData = data
env = simpy.Environment()
counter = simpy.Resource(env,capacity=4)
def source(env,number,interval,counter,customerData):
"""Source generates customers randomly"""
for i in range(number):
value1 = SRTFunc(p1=customerData["col1"][i],p2=customerData["col2"]
[i],p3=customerData["col3"][i],p4= customerData['col4'][i])
c = customer(env,'customer%02d' %i,timetoService= (value1))
env.process(c)
t= customerData['timeBtArrival'][i] # Inter arrival time between the customers in minutes
yield env.timeout(t)
客户功能:
def customer(env,name,timetoService):
"""Customer arrives,is served and leaves."""
arrive = env.Now
print('%7.4f %s: Here I am' % (arrive,name))
with counter.request() as req:
yield req
wait = env.Now - arrive
print('%s waited %6.3f' % (name,wait))
yield env.timeout(timetoService)
print('%s Finished at %7.4f' % (name,env.Now))
运行模拟:
proc = env.process(source(env,patientData))
env.run()
输出:
Service time function
0.0000 customer00: Here I am
Service time function
0.0000 customer01: Here I am
customer00 waited 0.000
customer01 waited 0.000
Service time function
8.0000 customer02: Here I am
customer02 waited 0.000
customer00 Finished at 9.0000
customer01 Finished at 9.0000
Service time function
10.0000 customer03: Here I am
customer03 waited 0.000
Service time function
12.0000 customer04: Here I am
customer04 waited 0.000
customer02 Finished at 17.0000
customer03 Finished at 19.0000
customer04 Finished at 21.0000
Service time function
38.0000 customer05: Here I am
Service time function
38.0000 customer06: Here I am
customer05 waited 0.000
customer06 waited 0.000
customer05 Finished at 44.0000
Service time function
46.0000 customer07: Here I am
customer07 waited 0.000
Service time function
49.0000 customer08: Here I am
customer08 waited 0.000
customer06 Finished at 57.0000
customer07 Finished at 58.0000
customer08 Finished at 68.0000
Service time function
84.0000 customer09: Here I am
customer09 waited 0.000
customer09 Finished at 108.0000
下面是(当前模拟时间,用户数,排队的进程数)
(0,1,0),(0,2,(8,3,(9,(10,(12,(17,(19,(21,(38,(44,(46,(49,(57,(58,(68,(84,(108,0)]
How to interpret this?
请帮帮我。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)