Python Simulation Framework
creation date: 2025-02-24 13:53
modification date: 2025-02-24 13:53
https://www.udemy.com/user/harry-munro-4/
https://www.schoolofsimulation.com/
Why Python
- Complete Flexibility and control
- Clean, intuitive code
- Leverage the entire Python ecosystem
- "kind of like moving into a house where the fridge is already stocked"
- Low barriers, no license fees, its FREE
- Transparent an reproducible models
- Rapid iteration and innovation
- Transferable skills and lasting value
- "like getting a gym membership for your brain"
- Python is top dog in programming languages
The Framework
SimPy
Why SimPy
- It has the most users and biggest community aka great support
- Its simple, it doesnt over-extend, doesnt try to be everything to everyone, focuses on being a simulation library
- It is recognized in industry
Why SimPy is Perfect for Engineers
- Python-based and event-driven, intuitive
- "mirrors how events happen in the real world"
- Scalable: scales from simple examples to complex, multiprocess systems
- "start small and then iterate"
- Cost-Effective and Open-source
Impactful Models
"Use your model as a tool for stakeholder management"
- need a way to track the assumption list for our model
- reference of where the data came from is very important
- you have the ability to capture uncertainty
- sometimes youll have to guess some values for example: how long it takes someone to do something
- you could have a best, medium and worst case scenario and put that into a probability distribution function
- sometimes youll have to guess some values for example: how long it takes someone to do something
Manage the Simulation Lifecycle
2 different flavors of sim work
Projects
- Study with a defined start and end date
- Clear set of goals
Products
- Usually looser open ended goals that change overtime
- Ongoing dev such as an in-house sim model
Minimum Viable Product (MVP)
- define a clear set of goals and timeline
- The MVP is just a project
- So what's the difference between a project and a product? - With the product dev you will repeat the process again
- The standards you set for acceptance of the work (more rigorous beyond MVP for products)
Mind the Gap - Reducing Risk
- Get really clear on what the questions are that you are answering
- Dont boil the ocean - dont try to do everything at once
- Conduct a model qualification step
Model Qualification
What should I include?
What can I safely exclude?
Power of Visual Management
- important to see the whole scope so that everyone on the team is on the same page
- fosters an open culture because its being updated with an open cadence
The Book
![[Simulation in Python with SimPy Book.pdf]]
Python Example Scripts
Chapter 3
![[basic_examples.py]]
Chapter 4
![[car.py]]
Chapter 5
![[adding_resources_and_increasing_capacity.py]]
![[customer.py]]
![[event_scheduling.py]]
![[plotting_customer_queue.py]]
![[multiple_processes_sharing_resource.py]]
![[stochastic_delays.py]]
![[worker_task_resource.py]]