Python 中的离散事件模拟
Diogo Costa (PhD, MSc)
Adjunct Professor, University of Saskatchewan, Canada & CEO of ImpactBLUE-Scientific

示例:机场客流管理
确定性过程
示例:焊接机
加工时间 = 焊缝长度 × 焊接机速度
非确定性过程

示例:带焊接的装配线
welding_1welding_2
welding_1
过程名称:焊接部件A
加工时间:5 小时
welding_2length * hours_per_length为每个过程创建 dictionary:
welding_1 = {
"name": "Welding component A",
"time_hours": 5
}
length = 20 # meters
hours_per_length = 0.2 # hours
welding_2 = {
"name": "Welding component B",
"time_hours": length * hours_per_length
}
示例:装配线
manual_assembly_1manual_assembly_2
manual_assembly_1
平均加工时间:80 小时
标准差:5 小时
manual_assembly_220 小时2 小时为每个过程创建 dictionary:
manual_assembly_1 = {
"name": "Manual Assembly A",
"time_hours": 80,
"std_hours": 5
}
manual_assembly_2 = {
"name": "Manual Assembly B",
"time_hours": 20,
"std_hours": 2}
制造流程顺序

离散事件模型
# Initiate time-tracking variable time = numpy.zeros(number_of_processes)# Next-event time progression time[0] = 0 time[1] = time[0] + welding_1["time_hours"] time[2] = time[1] + rd.gauss(manual_assembly_1["time_hours"], manual_assembly_1["std_hours"]) time[3] = time[2] + rd.gauss(manual_assembly_2["time_hours"], manual_assembly_2["std_hours"]) time[4] = time[3] + welding_2["time_hours"] time[5] = time[4]
Python 中的离散事件模拟