question

Rahul R avatar image
0 Likes"
Rahul R asked Rahul R commented

Zone Queue strategy

What takes priority (1) Order by statement in Queue strategy or (2) Enforce Queue Order

What I am trying to do is allow urgent tokens, then pick tokens belonging to a random order group from remaining tokens.


1665463483226.pngZone_test.fsm


FlexSim 22.2.0
zonequeue strategyzone advanced
1665463483226.png (15.2 KiB)
zone-test.fsm (36.0 KiB)
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

·
Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Rahul R commented

As far as I'm aware "Enforce Queue Order" only serves a purpose when the zone is partitioned or has subsets with limited quantities. In that case, only the token that is first in the queue can enter the zone, even though others could enter earlier because their partition would have space while the one of the first token doesn't.

If the zone is not partitioned, the queue order is always adhered to anyway.

If I understand you correctly, you are trying to let token with the "urgentFlag" enter in the order they arrive at the activity. If there are no such tokens, a random one is chosen from the non-urgent tokens.

To do that you can use a extra label that orders the urgent tokens, but is equal for all non-urgent tokens. If you then order by urgentFlag first, the extra label second and random third, this should result in the behaviour described above.

1665472730304.png

If urgentFlag is set, the "prioFIFO" label is set according to the activities input statistic (so later tokens will have a higher value). If not, the label is set to 0.

1665472824555.png

urgentOrder.fsm


1665472730304.png (26.7 KiB)
1665472824555.png (8.3 KiB)
urgentorder.fsm (153.6 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.

Rahul R avatar image Rahul R commented ·

Thanks for the response Felix! Probably I did not explain the non-urgent part clearly. Multiple tokens belong to an order and when I am picking a random non urgent token, I want to pick all the tokens associated with the selected (randomly selected) order. Adding an example for clarity

1665557161726.png

Would it be better to put all these tokens into a list? I started with a zone as I wanted to control the number of tokens in that portion of process flow.

0 Likes 0 ·
1665557161726.png (15.2 KiB)
Felix Möhlmann avatar image Felix Möhlmann Rahul R commented ·

Conceptually a list might be easier. You could build a logic that keeps pulling tokens while there is space in the zone, priotizing tokens with the same ID as the last pulled token over everything else, then by rules I use for the zone.

You can build the same logic with just the zone. It probably requires fewer activities but a bit of custom code.

The process flow itself gets two labels. An array label to keep track of the tokens that are still pending at the zone entry and a number (or string) label that holds the OrderID of the token that last entered the zone.

1665564580060.png

Before the tokens enter the "Enter Zone" activity they are added to the array and assigned a copy of the "LastOrderID" label of the process flow. This allows to use the expression "OrderID == LastOrderID" in the queue strategy. If the label values are equal, so if the token belongs to the same order as the token that last entered the zone, this evaluates to 1, otherwise to 0. Ordering by this expression is descending order first makes sure that tokens with the same ID have priority over all others.

1665564700235.png

Once an item enters the zone it updates the "LastOrderID" label on the process flow and each pending token, which is why the array is needed; to have a reference to the waiting tokens. The token also removes itself from the array.

1665564816681.png

This overall results in tokens of the same order always entering in direct succession, prioritized by the "urgentFlag" and otherwise random.

1665564910887.png

(The first urgent tokens are created after a delay, which is why OrderID 1 can enter first)

urgentOrder_1.fsm

0 Likes 0 ·
1665564580060.png (6.3 KiB)
1665564700235.png (9.6 KiB)
1665564816681.png (18.0 KiB)
1665564910887.png (6.0 KiB)
urgentorder-1.fsm (31.5 KiB)
Rahul R avatar image Rahul R Felix Möhlmann commented ·
Thank you!
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.