Mô phỏng Sự kiện Rời rạc bằng Python
Diogo Costa (PhD, MSc)
Adjunct Professor, University of Saskatchewan, Canada & CEO of ImpactBLUE-Scientific
LƯU Ý: Dùng thay thế “sự kiện” và “quy trình”.
Tính tất định của sự kiện (hoặc quy trình) là gì?
Vì sao quy trình tất định quan trọng?
Thế giới tự nhiên
Do con người điều khiển/khởi tạo
Quy trình tất định
Cần tính thời lượng quy trình vào thời gian mô phỏng
# Deterministic processes (time in hours) duration_process_1 = 10 duration_process_2 = 5while sim_time < total_sim_time:# Update simulation time: Process 1 sim_time += duration_process_1# Update simulation time: Process 2 sim_time += duration_process_2
Triển khai SimPy cho sự kiện tất định:
.timeout() ghi nhận thời lượng quy trình# Deterministic processes
duration_process_1 = 10
duration_process_2 = 5
while True:
# Update simulation time: Process 1
yield env.timeout(duration_process_1)
# Update simulation time: Process 2
yield env.timeout(duration_process_2)
Mô phỏng Sự kiện Rời rạc bằng Python