非确定性事件与过程

Python 中的离散事件模拟

Diogo Costa (PhD, MSc)

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

事件的非确定性

注意:术语"事件"和"过程"可互换使用。

什么是事件(或过程)的非确定性?

  • 过程无法被精确预测
  • 该过程称为"非确定性"

为何确定性过程重要?

  • 自然和人为活动常含非确定性过程
  • 每次发生的方式不同
  • 持续时间无法精确确定
  • 可能强烈影响系统输出
Python 中的离散事件模拟

非确定性过程或事件示例

自然界

  • 火山何时喷发
  • 何时下雨的准确时刻
  • 雷电击中的时间与地点
  • 龙卷风形成的时间与地点

人为或人触发的过程

  • 机器何时故障
  • 何时产生上厕所的需求
  • 婴儿何时开始哭泣
  • 商业航班是否会延误
Python 中的离散事件模拟

在离散事件模型中表示非确定性事件

非确定性过程

  • 对系统的影响不可重复
  • 精确持续时间未知

统计

  • 表示过程持续时间的变异性
  • random 包对此很有用

  • 例:random.randint(start, end)

import random

# Non-deterministic processes
process_1 = [5, 15]

while time < simulation_time:

   # Update simulation time: process_1
   time += random.randint(
               process_1[0], 
               process_1[1])

Python 中的离散事件模拟

使用 SimPy 表示非确定性事件

  • 无专门方法单独处理非确定性过程

  • 事件持续时间的变异性计算方式与非 SimPy 模型相同

  • 将正确的统计量传入 .timeout()

import random

# Non-deterministic processes
process_1 = [5, 15]

while True:

  # Update simulation time: process_1
  yield env.timeout(random.randint(
         process_1[0], 
         process_1[1]))
Python 中的离散事件模拟

让我们来练习!

Python 中的离散事件模拟

Preparing Video For Download...