การจำลองเหตุการณ์แบบไม่ต่อเนื่องด้วย Python
Diogo Costa (PhD, MSc)
Adjunct Professor, University of Saskatchewan, Canada & CEO of ImpactBLUE-Scientific
การอธิบายระบบธรรมชาติหรือระบบที่มนุษย์สร้างขึ้นด้วยแนวคิดและภาษาทางคณิตศาสตร์
โมเดลแบ่งประเภทได้ดังนี้:
แบบจำลองทางคณิตศาสตร์อาจเรียบง่ายหรือซับซ้อนก็ได้
George Box: "All models are wrong, but some are useful."

แบบจำลองการไหลในแม่น้ำ

โมเดลนี้พยากรณ์ปริมาณน้ำท่าสำหรับสถานีอุทกวิทยา Goaya ในประเทศจีน
การพยากรณ์อิงข้อมูลปริมาณน้ำฝนที่ใช้เป็น input ของโมเดล
ตัวอย่างอื่น ๆ
การพยากรณ์เงินเฟ้อ

ตัวอย่างอื่น ๆ
# Define model parameters
processes = {"process_1": 5,
"process_2": 2,
"process_3": 3}
# Simulation period
simulation_time = 365
# Run model
discrete_model(processes, simulation_time)
def discrete_model(processes, simulation_time): # 1) Run end-condition while (time < simulation_time): process_names = list(processes.keys())# 2) Loop over all processes for p in range(len(process_names)): process_name_p = process_names[p]# 3) Account for effect of each process time += processes[process_name_p]
ตัวอย่าง output ของแบบจำลอง discrete-event สำหรับกิจกรรมการผลิต
=> START OF SIMULATION (Time = 0 days)
Time = 6.00 days | Process Complete: Transport of raw material
Time = 9.00 days | Process Complete: Building components
Time = 11.00 days | Process Complete: Assembling parts
Time = 14.00 days | Process Complete: Selling product
=> COMPLETED: Supply-Chain cycle #1 | Time = 15.5 days
Time = 21.50 days | Process Complete: Transport raw material
Time = 24.50 days | Process Complete: Building components
Time = 26.50 days | Process Complete: Assembling parts
Time = 29.50 days | Process Complete: Selling product
=> COMPLETED: Supply-Chain cycle #2 | Time = 31.0 days
การแสดงผลผลลัพธ์ของโมเดลช่วยระบุรูปแบบและจุดเปลี่ยนสำคัญในระบบ
การแสดงผลควรสอดคล้องกับวัตถุประสงค์ของการจำลอง
มีไลบรารีสำหรับการแสดงผลที่มีประโยชน์มากมาย: matplotlib, seaborn, plotly

ตัวอย่าง
y) เทียบกับค่าเวลา (x)plt.plot(x, y, color='green', marker='o',
markersize=12, linestyle='dashed',
linewidth=2)
x และนับจำนวนค่าในแต่ละกลุ่มplt.hist(x, 50, density=True,
facecolor='g', alpha=0.75)
การจำลองเหตุการณ์แบบไม่ต่อเนื่องด้วย Python