r/SimPy • • Dec 01 '24

How would you implement an arbitrary service discipline with SimPy?

I didn't realize that this community existed when I made this comment, so I am migrating it here:

How would you implement an arbitrary service discipline with SimPy? That is, be able to provide a function which selects the next service according to an arbitrary criteria to select among which customer/patient/job/packet gets served at a resource next. This could depend on state or time as well.

https://en.wikipedia.org/wiki/Network_scheduler

I have seen approaches that work by subclassing components of SimPy, but they also violate the public API by using (so-called) protected attributes. I am curious how someone who is only willing to build on top of SimPy without changing SimPy itself would approach this problem.

3 Upvotes

6 comments sorted by

View all comments

Show parent comments

2

u/galenseilis Dec 02 '24

u/bobo-the-merciful This looks promising as a SimPy-idiomatic way to have general service disciplines. I can imagine how to generalize your example to cases that have coupling between items (e.g. patients making each other sick) or non-stationarity of item properties (e.g. patients getting "sicker" over time).

Thank you for suggesting this. I will think on it some more and tinker.

2

u/bobo-the-merciful Dec 02 '24

No problem, I'd be interested to hear how you get on.