question

Jon Abbott avatar image
0 Likes"
Jon Abbott asked Jon Abbott commented

Simultaneous all-or-nothing list pulls?

Is there a way in FlexSim to simultaneously pull from multiple lists in a way that is all-or-nothing for the overall request? I have multiple kinds of objects that need to be chosen at the same time, or not at all if any one of them is not available to be pulled. If this kind of approach is not available with lists, is there another preferred way to model this logic? Thank you in advance for any assistance you can provide!

FlexSim 20.0.10
listflexsim 20.0.10simultaneousall-or-nothingconcurrency
5 |100000

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

Jordan Johnson avatar image
4 Likes"
Jordan Johnson answered Jon Abbott commented

Hi Jon, I made an example model for you. And I made it very generic so that it should work in lots of situations.

The basic idea is that I treat all the components of a request like a recipe, 2 of these, 3 of those, etc. I batch together all those components into a single request. Then, that request checks for the availability of all components. If any are missing, it waits for those components before trying again. During this phase, nothing is pulled from any list; it's just a peek.

Once the token has confirmed that all are available, it executes the next phase of the process, which is to acquire everything. Since confirmation happens all at once, the items are guaranteed to be on the lists, so the actual pull (where items are removed from the list) is guaranteed to work.

The final phase is to basically put everything back where it came from. To do that, I save the request token, and have it wait until the parent releases it.

This flow should be generic enough to use in basically any model. I will say that if you are using a SELECT statement, you'd need to modify parts of it. But this should get you going.

MultiPullExample.fsm


· 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.

Jon Abbott avatar image Jon Abbott commented ·

Thank you @Jordan Johnson! This is tremendously helpful, and I can foresee it being used in a lot of situations where mutual resource reservation is required. One question: if a token is waiting at "Wait for Acquire" because both resources aren't available enough to meet its requirement, and another request arrives and enough resources are available for it, will that one "skip ahead" in line, or is it strictly FIFO? Thanks again for all of your help!

0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Jon Abbott commented ·

Right now, it's not strictly FIFO. A token that requires lots of resources may be blocked, while a token that requires few resources may be able acquire them and move forward. The token that requires many resources would have to wait until it could acquire all of those resources at once. So yes, tokens can skip ahead.

However, if there are multiple requests that happen simultaneously, then those tokens are ordered by their request time. The zone accomplishes this. The Zone has an option to wait for simultaneous tokens before allowing any to enter the zone. It also has an option to order those tokens. So if there happen to be multiple requests at the same (such as when many tokens are waiting on a resource, and it becomes available), those requests are ordered by age. So the oldest tokens get to check to see if they can get their resources first.

1 Like 1 ·
Jon Abbott avatar image Jon Abbott Jordan Johnson ♦♦ commented ·

Great, thanks again @Jordan Johnson for this very useful model and detailed write-up!

0 Likes 0 ·
Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jon Abbott commented

Hi @Jon Abbott - I'm pretty sure it could be done with the Table query across multiple tables using a SQL join. Perhaps it can also be done in a subflow where a number of sibling tokens trying to pull from different lists, leave the items on the list when they succeed but whenever one of them succeeds it also forces the other tokens to check again until all of them succeed at the same time at which point they all pull and remove the items from the lists - a bit convoluted perhaps.

I asked for this feature some years ago - I'm sure it hasn't been forgotten.

· 1
5 |100000

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

Jon Abbott avatar image Jon Abbott commented ·

Thank you @jason.lightfoot! I appreciate the suggestions.

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.