Containers with expiration time

43 views
Skip to first unread message

shahnaz ghafourzadeh

unread,
Feb 12, 2021, 8:58:44 PM2/12/21
to python...@googlegroups.com
Hi all,

I am working on a project which uses SimPy for simulation. We have a set of objects grouped in different groups (coded in python via a sorted dictionary). Each group has a specific capacity which can hold objects. The current implementation uses a dictionary like this:
def get_group_info():{
return SortedDict(
    {
1: {
"usable_cap": 70.2,
"remain_cap": 15.0,
"shape": "2",
"loc:": "CA-north-1",
"fraction": 0,
"spindles": 600 * 2,
},
....
   }
}
In a set of different operations objects get put into a container (which reduces "remain_cap") or gets deleted from a container (which adds to "remain_cap").
Now I have 2 questions: 
1- Why should I use SimPy containers over the current implementation via a dictionary?
2- Assume objects have an expiration time, meaning that once an objects put into a container it has a timestamp associated with it to show the put time (in days), once 30 days (expiration period) passes the put time that object has to be removed from the container. Is there a way I can model this scenario in SimPy?

I couldn't join the group as I kept getting an error ("An error happened while joining, try again!")!
Please send your responses to my personal email at (shahnaz.gh...@gmail.com).

I appreciate your help in advance!

Best,
Shah 

Michael Gibbs

unread,
Feb 12, 2021, 9:43:27 PM2/12/21
to python-simpy
1: containers will "queue" a request to add beyond a capacity, or take when the container is empty

2: add a expire process to you object that yields a time out for 30 days, and then removes itself from the container.  use env.process to kick off this process when you init the object
Reply all
Reply to author
Forward
0 new messages