Douwe Jd avatar image
Douwe Jd asked Douwe Jd commented

use max wait time of 1 hour to acquire a resource immediately (and skip queue)

Hi everyone,

In my model, truck drivers have to acquire a dock door to load shipments. For this resource called 'DockDoors', I have set up a 'default query' to make sure that only certain doors can be acquired for certain shipment types and quantities. This all works perfectly fine. Then I also set up a 'queue strategy' to determine that if backorders arise, the trucks are sorted from lowest shipment quantity to highest, such that trucks with the shortest loading time are given priority. I found this to be an excellent way of reducing the truck congestion that happens in the yard otherwise.

My question is about the following. With the current settings, in case of backorders, the system will always give trucks with lower loading times priority. This could lead to situations where a certain truck and its driver are waiting the whole afternoon before there are no backorders anymore and finally the longer loading time trucks can be processed. It is unrealistic and impossible to ask this of truck drivers, and therefore i want to add a max wait time of 1 hour to be on the backorder list. After this hour, i want the truck/driver to be the first in line to acquire a door if one becomes available. In this way, shorter loading times still receive priority, but drivers never have to wait more than 1 hour, regardless of their loading time.

I have looked at the max wait time function but only found ways to send the token to another destination, and not the functionality i desire. I wonder if what i want is also possible. I had to attach my model as a zip as it gave an error message if i tried to upload it directly. I hope this explanation is clear and look forward to your help!

sequencing rules

FlexSim 22.1.3
acquire resourcemax wait timerbackorder queue strategy
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Mischa Spelt avatar image
1 Like"
Mischa Spelt answered Douwe Jd commented

Hi Douwe,

If I understand you correctly, you want to evaluate the back orders such that

  • .. if any drivers have been waiting for at least an hour, return the earliest one
  • .. if all drivers have been waiting for less than an hour, return the smallest loading time

You could solve this by adding a field which evaluates to a very large number (we can use INT_MAX which is equal to 2.147.483.647) if the waiting time has been less than an hour. If it is more than an hour, the field just returns the arrival time:

pushTime - Model.time < hours(1) ? INT_MAX : pushTime

SIDE NOTE: This is shorthand for

if(pushTime - Model.time < hours(1)) {
  return INT_MAX;
} else {
  return pushTime;

If you want you can use the Code Editor button and write it out like that.

You'll want to make sure that the field is dynamic (i.e. updated when the back orders are evaluated)


Now your sorting strategy will be

ORDER BY WaitTimePriority, LoadingTime

If any drivers have been waiting for at least an hour, their WaitTimePriority will be low and the lowest one will be used. If not, then WaitTimePriority will be INT_MAX for all available orders and the secondary sort by LoadingTime will ensure that the smallest one is picked.

1659449150889.png (17.9 KiB)
· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Douwe Jd avatar image Douwe Jd commented ·

Hi Mischa,

Thank you very much for your suggestion! You indeed understood correctly and I like the structure of your solution. I can imagine how it should work in other models, unfortunately, I haven't quite managed to make it work for mine.

I think i have found the source of the problem, however I am not skilled enough in the coding side to solve it. If my assessment is correct, I think that rather than measuring the waiting time of the driver (the puller) that is requesting the resource, the WaitTimePriority field is measuring the time since a door is available again, and in this way 'waiting to be acquired'. I have tried to put puller. in front of the pushtime and waittimepriority, but these attempts did not do the trick. Could you maybe take a look at my specific model on how to make sure it is measuring the waiting time of the puller rather than the resource itself? Thank you in advance!!

sequencing rules model

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Douwe Jd commented ·

Since the puller is a token, you can use its 'entryTime' property to read at what model time in entered the Acquire activity.


0 Likes 0 ·
1659522115742.png (11.6 KiB)
Douwe Jd avatar image Douwe Jd Felix Möhlmann commented ·
Thank you Felix (and Mischa)! That did the trick!
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.