r-simmer / simmer

Discrete-Event Simulation for R

Home Page:https://r-simmer.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Which arrivals in which queue

jeras308 opened this issue · comments

Hi there!

I’d like to see at run time which arrival is in which queue and based on certain attributes of the arrivals in the queues I want to make decisions for new arrivals. Is there a convenient way to retrieve this ‘queue status’?

Basically, my arrivals have a certain attribute called ‘size’. Timeout() is dependent on this attribute. When a new arrival to the system occurs, I want to send the arrival to the work center with the ‘shortest’ queue. Where by ‘shortest’ I mean in terms of the sums of the timeouts (that depend on size) of the arrivals in the resource’s queue.

For this particular problem, solely retrieving the queue’s length does not suffice. I’d like to know at run time which arrivals are in which queue.

Thanks in advance!!

You can use a global attribute per resource to keep track of the cumulative timeouts for that resource. Just before seize, the arrival should add its size attribute to the corresponding global counter for the resource it's entering, and then just after seize, it should substract the same quantity (because it's not in the queue anymore). Then you can take the decision based on the values of such global attributes.

Thanks @Enchufa2 ! Such global attributes indeed do the trick for measuring queue length in terms of size. Still, for the purpose of my simulation, it would be desirable to know which arrivals are in a queue of a resource.

For example:
Suppose there are two arrival types (A and B). arrival of both types must be processed on res1 first and next, depending on the arrival type, either on res2a or on res2b.

Then, from res1's queue, I want to use global attributes res2aQueueLength and res2bQueueLength to have the arrival seize res1 that is directed to the res2. with the lowest value for the global attribute. If res2aQueueLength and res2bQueueLength are the same, I want to select the arrival in res1's queue with the lowest size.

Then, how to see at run time which specific arrivals are in the queue of res1?

If res2aQueueLength and res2bQueueLength are the same, I want to select the arrival in res1's queue with the lowest size.

I don't understand what you mean here. Enqueued arrivals are processed in order. You cannot "select" which one goes next, because then there's no queue.

Then, how to see at run time which specific arrivals are in the queue of res1?

See where, for what purpose?

I don't understand what you mean here. Enqueued arrivals are processed in order. You cannot "select" which one goes next, because then there's no queue.

Hope I can illustrate what I mean by means of the example below.

GithubExample

When looking at the queue at res1, I would like to process the blue arrival first as res2b has the shortest queue based on the global attributes. So, I want to decide which arrival to process when, based on the state of the environment, resources, and arrivals' attributes.

Perhaps "selecting" from the queue which one to process is not the right way for me to model it in simmer. I want to have something like a decision point that decides which job to process first on res1. Could you think of a way to model this behavior?

So you need a multi-queue resource, which is not currently supported. You can emulate this with two additional resources, res1a and res1b, for each kind of arrival, placed before res1, and then res1 doesn't need a queue.

The general idea is that, as soon as an arrival successfully seizes res1a or res1b, it sets their capacity to zero (using set_capacity) and enters res1. Then, when it gets processed and releases res1, sets the capacity of res1a or res1b depending on the size of the queues of res2a and res2b. It's like opening and closing a tap.

If arrivals within each of the arrival types were the same that would work for me . However, in a situation in which res2aQueueLength and res2bQueueLength are the same I want to 'select' the arrival to go to res1 based on a static arrival attribute size. The smallest job would then be preferred. See below:

Github example2

Additionally, I have attributes based on which I want to make decisions at runtime given the current simulation time now(). See below description:

Github example3

Then, how to emulate this behavior? Basically I want queues not to operate under FCFS but rather some custom policy that uses size and DueDate attributes to make some calculations to decide which arrival to 'select' to process on res1.

So basically you have so many corner cases that you need to implement your own queue. Unfortunately, that's not possible with simmer.

Ok. Thank you! Unfortunately the above is not yet possible. However, I really like simmer, looking forward to see the new releases!

To your knowledge, would be able SimPy support the above?

AFAIK, if you use standard resources, you have the same problem. Basically, you need to implement your own resources with quite special queues.

Closing this then. BTW, for the future, if you don't mind, I prefer to keep this issue tracker for bugfixes and feature requests, and the mailing list is better suited for general programming questions like this. Thanks!

Hey, it has occurred to me that you could you an scheme like this one to solve your problem. You wanted a custom selection function for your queues. The idea is to use renege_if() so that arrivals sitting in a queue leave the queue momentariliy to recompute their priorities and go back to the queue.

See this new section about the implementation of custom service policies.