Discrete Event Simulation in Python
Diogo Costa (PhD, MSc)
Adjunct Professor, University of Saskatchewan, Canada & CEO of ImpactBLUE-Scientific
System optimization
Human-driven processes
Identifying processes with higher impact on system output
Monte-Carlo sampling
Objective functions
Math expression describing output target
Score simulation scenarios
Example
Total: 100%
Search & Stop: Run different model configurations and stop when desired condition is met
while total_duration < 24:
model_to_run()
Score & Rank: Score simulation results based on weighing criteria
for i in range(num_runs):
out_1, out_2 = model_to_run(i)
scores(i) = 0.3 * out_1 + 0.7 * out_2
Example
scenario_num = 0
while scenario_num == 0 or total_duration[s] > 40:
scenario_num += 1
env = simpy.Environment()
env.process(manufractoring_proc(env))
env.run()
plot_results()
Example: Manufacturing industry
Involving various sequential tasks (or processes), such as a car production line.
def objective_function_calc():
score_objfunc = np.ones(num_scenarios)
for s in range(num_scenarios):
for p in range(len(processes)):
score_objfunc[s] +=
processes[p]["duration_hours"]
* processes[p]["score_weight"]
Score
"RED": Low score; "BLUE": High score
Rank
Score-ranking simulation runs
Search & stop
"Blue" line met the "stop" criteria
Breakdown results of "best" simulation:
sum = 20 min
)sum = 20 min
)sum = 28 min
)sum = 30 min
)"Process 1" critical to achieve this goal
Score
Objective: lowest score = lowest duration
Rank
"Process 1" critical to achieve this goal
Discrete Event Simulation in Python