离散事件模拟简介

Python 中的离散事件模拟

Diogo Costa (PhD, MSc)

Adjunct Professor, University of Saskatchewan, Canada & CEO of ImpactBLUE-Scientific

离散事件模型 vs. 连续模型

连续模型

  • 以固定时间步运行

  • 时间是哑变量

    • 循环内不更新时间
  • 使用时间 for 循环

    for t in range(time_range):
    

离散事件模型

  • 以可变时间步运行

    • 随时间运行/调度不同时长的离散事件
  • 时间是状态变量

    • 在 while 循环内更新时间
    • 时间不是哑变量
  • 常用 while 循环

    while (time < 365):
    time += process_duration
    
Python 中的离散事件模拟

离散事件模型的组成

  • 状态变量
  • 时钟
  • 事件列表(或进程列表)
  • 结束条件
Python 中的离散事件模拟

模型组件

示例:出租车公司模型

while (time < 10):

    # Process 1
    time_duration_1 = manage_requests()
    time += time_duration_1

    # Process 2
    time_duration_2 = dispatch_taxi()
    time += time_duration_2

结束条件

while (time < 10)
  • 终止模拟的条件
Python 中的离散事件模拟

模型组件

示例:出租车公司模型

while (time < 10):

    # Process 1
    time_duration_1 = manage_requests()
    time += time_duration_1

    # Process 2
    time_duration_2 = dispatch_taxi()
    time += time_duration_2

时钟

time += time_duration_1
time += time_duration_2
  • time 跟踪当前模拟时间
  • 随模拟推进,时钟跳到下个事件开始时刻
  • 事件瞬时发生,时间"跳跃"
Python 中的离散事件模拟

模型组件

示例:出租车公司模型

while (time < 10):

    # Process 1
    time_duration_1 = manage_requests()
    time += time_duration_1

    # Process 2
    time_duration_2 = dispatch_taxi()
    time += time_duration_2

状态变量

time
  • 缩短从呼叫到送达的时间

  • 描述系统输出与效率的变量

Python 中的离散事件模拟

Passons à la pratique !

Python 中的离散事件模拟

Preparing Video For Download...