New to SimPy - Question of capability before I get too invested!

515 views
Skip to first unread message

Karl Duckett

unread,
Nov 8, 2021, 3:49:51 AM11/8/21
to python-simpy
Hi everyone,

As the title shows - I'm just dipping my toes into the world of SimPy and had a quick question regarding the capability. I work for airport companies and would like to model a security checkpoint. \

My question is around pairing items of luggage (multiple) to a passenger and that passenger separates from the luggage, goes through a few processes and then combines (collects their luggage) from the x-ray and then leaves the simulation....

I have seen this done in other 'off the shelf' simulation software, but would love to code one myself - if possible with SimPy. 

Thanks everyone - hope to see SimPy continue to grow :) 

-Karl Duckett

Dale Frakes

unread,
Nov 8, 2021, 4:16:42 AM11/8/21
to python...@googlegroups.com
Karl,

I like SimPy a lot but also use Simmer (similar DES package for R).

In our particular recent case (a warehouse simulation), we started in SimPy because it fit better in our existing stack and seemed to work well in our POC case with simpler code than the Simmer version.

The one problem we had was when we scaled up to realistic numbers of orders to the warehouse (from around 1k/day in our test case to 15k+/day, from 7 days to 60) the SimPy version bogged down tremendously as the simulation ran past 10 or so simulated days.  The SimPy version seemed to get slower in an exponential fashion and my guess is that because we needed full logging, there were data objects (lists or arrays) that were being fully copied as elements were added, thus getting slower slower as the size grew.

When I re-implemented the simulation in R/Simmer, we didn't have that exponential slow-down, so we had to go that route in the end, though the code base was slightly larger and more complex.

I'd recommend building up a simple case (with simple logic and simplified assumptions) that captures the data you need, then scale it up to the quantities and time-frame you need to see if the simulation runs in a reasonable amount of time.  If so, I'd probably stick with SimPy.

If anyone wants to explore this further, I'd be happy to share sanitized versions of the code to run tests with.

Dale
--
You received this message because you are subscribed to the Google Groups "python-simpy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-simpy...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python-simpy/86a40ff7-47db-4a1f-9471-ab732d79b2b6n%40googlegroups.com.

-- 
Dale Frakes
Adjunct Instructor, PhD Candidate
PSU Systems Science
dfr...@pdx.edu - http://web.pdx.edu/~dfrakes/

Omogbai Oleghe

unread,
Nov 8, 2021, 4:40:37 AM11/8/21
to Karl Duckett, python-simpy
Hi, 
absolutely you can build such a model. If you are just starting I would suggest you to go through the simpy documentation and example models. And there are some example models from the internet. see some additional links below, but search for others as well:

Depending on your python skills you can add complex logics to your model to mimic real-world processes.

Omo

--

Michael Gibbs

unread,
Nov 10, 2021, 11:38:31 PM11/10/21
to python-simpy
Here is a quick example where a passenger sends his luggage through a xray machine, goes through a scanner, and waits for all his luggage to finish being xrayed.  simpy is very basic but has what you need to do discreet simulation and agent base simulation.  simpy is open source so you can modify and add code as needed and you can use any of the ton of python libraries. There is some debate about how scalable python is and here are some scaling gotchas to avoid.  Also there is a way to compile you python code to C++ for maximum performance.  I have not done this myself so I do not know how hard that would be. There are a lot of post on how to optimize you code so I will not repeat them here.
checkpoint.py

Karl Duckett

unread,
Nov 11, 2021, 3:07:56 AM11/11/21
to python-simpy

Wow! Thank you so much Michael. This is fantastic - really love exploring that example model. This is exactly what I was looking for. That simpy.AllOf() function is great. There are some bits I still don't quite understand (which is fine). I'm reading some of the other resources that have been posted here.

I'm not worried with the constraints on extremely large/complex models performance at this stage.I hear similar complaints around data analysis in Python vs R yet I'm yet to see pandas struggle with any dataset I throw at it :)

Thanks again for the example model - if I add more bits to it I'll post back here in case anybody else is searching in the future. :) 

-KD

Karl Duckett

unread,
Nov 12, 2021, 3:07:40 AM11/12/21
to python-simpy
Hi all,

I've also asked a similar question of salabim users and received this awesome example below solving the pair luggage to passenger simulation. 

Thought I'd post it here too again in case somebody searches in the future (possibly even myself - it's happened before!) 

Thanks again to everyone for all the inputs - I will present this to my team next week - hopefully they give me some hours during work time to play some more, one can dream :) 

Happy Friday everyone! 

-KD
20211112 - Airport Checkpoint Salabim Example.py
Reply all
Reply to author
Forward
0 new messages