question

Borja Lorenzo avatar image
0 Likes"
Borja Lorenzo asked Borja Lorenzo commented

Wait for Event with token's label match

Hello,

I have tried to find a solution to my problem, and despite reading numerous forum posts and information in the manual, I still can't find a solution for the "Wait for Event" activity. In the attached model, I have tried to replicate a simplified example. I have added as much detail as possible.

As you can see in Queue 1, two containers appear, which triggers the token creation event in Source BL. When one of the tokens in that queue leaves the Delay activity, it should trigger the event for the associated token (same queue and reference) that is waiting in the "Wait for Event" to be released.

The linkage must come from the queue since the same reference can be contained in several queues. Currently, only one type of reference per queue.

I have proposed a second alternative with Lists (pull and push). According to what I have read, this option would be equally valid, providing more options for more complex logic and faster execution. I had to create a custom code that returns a query, which comes from a composed string.

I would like to understand if my list proposal is well thought out and if there is any other way to do it without custom code. Additionally, I would like to learn how to do it with the "Wait for Event" method. It seems more intuitive to me. When this case is applied to the real case, the occurrence in the delay will be linked to 245 tokens (= number of queues). It may happen that more than one token is released at the same time. Could this generate difficulties when listening to the event with the "Wait for Event" method?

In the attached model, both alternatives are included. As you can see in the image, in the "Wait for Event" method, I can't get any token to be released with the corresponding Origin or Reference label.

In the list method, I have achieved it as I said, but I would like to know if it could be done without using custom code.

Also, thinking about the scalability of the model, if the initial condition that there is only one reference per queue is changed... I understand that in the query I could add an AND operator to also extract by the reference filter and solve it... This double match condition could be achieved in the "Wait for Event" activity.

1737927292264.png


How could I do it?

Sumary:
I provide a solution for the pull and push list method. I add a new scenario and conditions for the containers. My reference in more than one queue. A single type of reference in a queue / propose a scalability evolution and make the query evolve to a new condition of more than one reference per queue. Would this more complex filter condition be supported by the "Wait for Event"? The possibility of more than one event occurring at the same time could generate a conflict in any of the methods.

Thanks in advance for your help.

Simplificacion Wait For Event.fsm


FlexSim 24.2.1
processs flowwait for eventmatch labeltoken labelmatch value
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

Paula LG avatar image
1 Like"
Paula LG answered Borja Lorenzo commented

Hi Borja,

First of all, your list approach is correct and it also would make facing more complex matches between tokens easier, as you anticipated. However, a custom code is not needed, since you can write the query directly onto the field:

1737967183477.png

You could add as many labels as needed to get the desired token.

On the other hand, it is not possible to match a token label directly using the "Label Matching/Assignment" table on the Wait for Event activity, but there's another easy way to do so. On the Token field, save the token that triggers the event on a label of the current token (I named it otherToken) and then write a condition on the "Send Token To" field, so that the token will only leave the activity through connector 1 when a condition of your choosing is met. Then, add a second connection (2) that goes back to the activity.

1737967610444.png1737967630241.png1737967683102.png

In this case, you could also add as many conditions as you need on the conditional decide, replicating the list behavior.

As per why the matching can't be done directly, it's because what you're trying to match on that field is the token triggering the event (the one I'm assigning to the otherToken label) with a label of the current token. So, as you had set it up, the activity understood that on your "Referencia" label you had previously saved the token that would later trigger the event. Obviously, that match wouldn't ever happen because the Referencia label is used for a completely different purpose.

Events happening at the same time isn't an issue because even if they occur at the same model time, they are different steps inside the simulation and don't happen all at once. That's how the software operates internally and you can observe how it works if you open the "Event List" on your model.

Moreover, another suitable approach is using a Zone with limited content. It could be more complex to limit depending on how your logic evolves and your needs, but that would have been my first thought when building it.

1737968448347.png

I attach here a new version of your model with everything that's mentioned above: simplificacion-wait-for-event.fsm

I hope it helps!


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

Borja Lorenzo avatar image Borja Lorenzo commented ·

Hi Paula,


Thank you very much for your detailed explanation. My doubts about my proposals have been clarified. However, my proposal with the list strategy as I have it configured or the Wait for Event with your clarifications presents a problem when deploying it in the real global logic.


Your Zone proposal avoids this circumstance since it does not depend on a token to trigger/launch the token that is saved in the list or that is waiting in the Wait for Event.


Although your proposal saves what I want to do, I would like to know in more depth if there would be any way to solve this situation with the Wait for Event or List.


I forced the simplified model a bit to recreate the situation (it is not a model that makes much sense, I only worried about forcing the events that I cannot control with the commented methods. It is mainly seen in queue 1). The situation is as follows:


Queue of two containers, one is consumed (red) so its pull activity has already been done, at a later time that new container (blue) is replenished. It should start to be consumed at the same time it enters the queue because the other one is red (empty) but for this it depends on there being a token that generates the exit event and this is not always possible.


I tried with the list configuration of "Keep back order on early release" but it doesn't work either. The pull token stays in the sink and I understand that the pull would be pending but it doesn't.


Thank you in advance for your comments.
Simplificacion metho wait for event with List.fsm

0 Likes 0 ·
Paula LG avatar image Paula LG Borja Lorenzo commented ·

Hi Borja,

In order to achieve what you're describing, you need to have a conditional value for the "ID_Contenedor" label. The condition I have established is only to separate the particular case you mentioned: when you have a container inside the queue that has already been emptied. In that case, the ID_Contenedor for the new container should strictly be 1, so that it begins its consumption the moment it enters the queue. In every other scenario, the value should be the one you already had for the label.

1738051634364.png

I hope it helps!

simplificacion-metho-wait-for-event-with-list.fsm

1 Like 1 ·
Borja Lorenzo avatar image Borja Lorenzo Paula LG commented ·

Very helpful, Paula, thank you. I hadn't thought of adding a condition to the ID_Contenedor label of the restocking basket.

0 Likes 0 ·