question

Mark S2 avatar image
0 Likes"
Mark S2 asked Mark S2 commented

Wait for Event to Release Multiple Matching Tokens by Label

Wait for Event.fsm

Hello,

First I'll put the problem into context, in case you want to suggest another means of acheiving the same thing. An accession # indicates a patient batch of specimens. They only get accessioned once, no matter how many samples there are in the batch. Each specimen within an accession # has labels that must be stored for later in the simulation. Once the 'batch' has been accessioned all the unique specimens can now advance to the next simulation step.


I would like to release multiple tokens from a 'wait for event' upon a single token entering an activity but also matching the value label 'Index'. I would also like the source with multiple tokens per Index to keep whatever labels they were created with.

I am initializing all of the first source tokens at time 0 to avoid the issue of them getting stuck if they show up first.

Why doesn't this work?

1680705247480.png


I do not see the above table desribed in your manual, but Token seemed to be the self-explanatory field to use.

Thanks,

Mark


Edit: I attempted a list implementation based off another answer on the forum but 1) I generally have no idea how lists work, 2) It still doesnt' work as I expected.

Accession Batches with Lists.fsm

Edit 2: I think am one step closer, but why arent the labels maintained after pulling the token? I need GrossType to be carried forward. @Jason Lightfoot

Accession Batches with Lists Attempt 2.fsm


FlexSim 22.1.4
wait for eventmatch labelmatch
· 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.

Branden Gunn avatar image Branden Gunn commented ·

BTW, the table documentation is in the section "Label Matching/Assignment" under "Shared Process Flow Properties"
Docs

0 Likes 0 ·
Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered Jason Lightfoot edited

If you want to use wait for event then you can't match the token since you don't know it when you initialize the listener.

You can do this:

1680712120418.png

Another way is to push the waiting tokens to a list and then when the single token hits' the delay, pull all tokens with the correct index off the list. Of course there are many other ways too.

accession-batches-with-lists_jl.fsm

wait-for-event_jl.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.

Mark S2 avatar image Mark S2 commented ·
Thanks Jason - lists do seem like the better way to do it. However, I would like to carry the GrossType labels forward. Do you know how this might be accomplished?
0 Likes 0 ·
Mark S2 avatar image Mark S2 Mark S2 commented ·
To clarify...the wait for event solution does carry forward the label but I am curious how this would be accomplished via lists.
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Mark S2 commented ·

You can access information from the puller token by adding it as a pointer to the pushed token.

1680719632761.png


Attached is another example where I assume the Accession process takes place when all the specimen are ready and take a time to process. It leaves the tokens on the list until after the process and then pulls them off the list which allows them to continue.

1680721165333.png

Note here too that by listing the GrossType in the SELECT clause, the pulling label get's an array of all the GrossTypes for each specimen.

accession-batches-with-lists_jl2.fsm

This may not be your actual process but should show what you can do with lists.

0 Likes 0 ·
Branden Gunn avatar image
1 Like"
Branden Gunn answered Mark S2 commented

I have a version using lists (Based on your back and forth with @Jason Lightfoot) that I think does what you originally wanted. It is in 23.0.6, since I didn't have your version installed.

accession-batches-with-lists-bg.fsm

I can give more detail with more screenshots if you can't open it, but the gist is that the releasing token arrives at the Release Tokens activity, and then releases any matching tokens waiting in the list to a separate activity, which can have more complex condition/destination logic. This moves the actual original specimen tokens, so all labels are preserved.

This screenshot has the majority of the logic:1680714219564.png

Other notes: I removed the BatchQty column from the Batches source, since I think your intention was to simply release all matching tokens by Index.

Edit for more thoughts: The List is actually not even needed in this case, since you can release them from any activity. (Release Tokens acts kind of like a Move Object, but for tokens). One advantage to a list however is that you can have multiple sources all push to the same list, and a single release could release all of them. There may also be useful other tools and statistics that the lists will allow, such as querying, dashboard integration, or simply looking at the list of tokens as a table that you can export.

The original list implementation was pulling a reference to the sample tokens, so the other labels you wanted were buried down a level.

There are probably also interesting things you can do with Max Wait Timers and delays to allow specimens that arrive a moment too late to still get released, or to model samples getting damaged by waiting too long.


1680714219564.png (32.7 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.

Mark S2 avatar image Mark S2 commented ·
Hi Branden, this is perfect - thanks as well for the more in-deptth explanation. How did you acquire the knowledge to figure this out? The jump from real life logic to flexsim logic too often eludes me for even basic tasks like this one...
0 Likes 0 ·
Branden Gunn avatar image Branden Gunn Mark S2 commented ·

Mark,

I appreciate the kind words and assumptions about skill. Quite honestly I'm pretty new to FlexSim. I've been neck deep in it for about a month learning to simulate a factory design for work. My background is fairly heavily software based (around electrical and mechanical engineering), but not dedicated to any particular language for a very long time, so I have a lot of experience at being new to a language.

Back in the day, I used the 'ask for help' posts on a forum for a language I was learning (Autohotkey, FWIW) as a way to learn new things. Basically the approach is "I don't know the answer. but maybe I can figure it out." Over a few years I became the a moderator and the number 3 poster on that forum, and the vast majority of the 10k+ posts were trying to help someone and learn something in the process. I got very good at answering other people's questions (and seeing what they were probably trying to do), while also not really using the language for very much for myself.

I guess maybe my answer is that I'm not really trying to apply real-life logic, and just trying to work within what I understand about the FlexSim logic. I also spend a lot of time poking around in the Tree of my model. There is a lot of interesting information in there, and you can modify just about anything, or set breakpoints to pause the code in that spot. I managed to completely reverse engineer (using the Tree) the internal data collection for one of the "Output / Hour by Type" charts so that I could tweak the logic, only to discover that I could have saved 8+ hours by pressing the "Install" button in the chart properties...

If it is useful, I can promote my comment to an answer.

0 Likes 0 ·
Mark S2 avatar image Mark S2 Branden Gunn commented ·
Ah interesting, thanks for the response! My coding background is in R and stackexchange was a life-saver (and still is ha!). Yes please do promote your comment -- I think the main take away for me is that I should spend more time poking around the tree like you said.
0 Likes 0 ·
Branden Gunn avatar image
1 Like"
Branden Gunn answered Mark S2 commented

I think your original for seems close, and can be made to work. I think maybe Match Value instead of Match for the token operation? I didn't immediately get it working, so tried an alternative instead to see if at least it has the effect you want.

1680711145782.png

I was able to get the tokens coming down the right side flow to cause a matching token (already waiting in the Synchronize activity) to advance to the left side Delay as the right side token advanced to the right side delay.

I'm going to play a bit more with your wait for event version, which feels cleaner.
Edit: I don't think the sync version does exactly what you want, since only one sample from the batch proceeds, not all samples from the same batch. Lists are a good way to go as well. I might look at your list version.


1680711145782.png (18.6 KiB)
· 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.

Mark S2 avatar image Mark S2 commented ·

Hey Branden - thanks for looking into this! I thought of the synchronize solution as well, but sometimes there are quite a few unique specimens per Index and in that case I would need an unwieldy number of connections going into synchronize.

1 Like 1 ·