question

Manuel Sinco avatar image
0 Likes"
Manuel Sinco asked tannerp commented

Tokens Priority to advance

Hello,

I have a question about if there is any way to control the way tokens advance. For example, lets say that I have plenty of tokens in different 'wait for event' activities but the condition is the same for all of them. So after the condition is met, all the tokens should advance. They'll be advancing based on the order they arrived at the activity, but I want them to advance in a certain order based on a priority number. Is there a way to control them based on this priority?

I made a simple example of what I want to do, basically, I have 4 tokens on a 'wait for event' activity which is waiting for a message. I'll show when does each token arrives and it's own priority.

  • Token 1 arrives at time 0 with a priority value of 200.
  • Token 2 arrives at time 20 with a priority value of 1.
  • Token 3 arrives at time 60 with a priority value of 1000.
  • Token 4 arrives at time 200 with a priority value of 20.

The last token will be the one that will force to send the message, so all of them will be able to advance "at the same time". Obviously, they'll be advancing one by one, but I want that the first token to advance should be the token 3, followed by 1,4 and finally 2.

I added a breath activity with a debug to show that they'll be advancing in the order that they arrived. Is there any way to do it in the way that I want?

This is the model: TokenPriority.fsm

Thanks.

Manuel.

FlexSim 19.1.2
flexsim 19.1.2token order
tokenpriority.fsm (26.1 KiB)
· 2
5 |100000

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

tannerp avatar image tannerp commented ·

@Manuel Sinco,

This might be a long shot of a solution and someone may have a better idea, but you could potentially use a Batch activity after the Wait For Event. In the Batch activity, you can make a label array for all the tokens "priority" labels. Then, when you need to reference/pull the one with the highest priority, you can do so through custom code.

Alternatively, you could push the tokens to a list that utilizes the "priority" label, then pull based on the highest priority.

If you have questions about either of these, let me know. I think the list option might be easiest overall, but might require more setup. I'm not sure though.

0 Likes 0 ·
Manuel Sinco avatar image Manuel Sinco tannerp commented ·

Hi @tanner.p, thanks for your answer. I think that a global list will help me, however, I wouldn't know when to pull them, based on that it should be always that they are able to advance. I updated the question to display better what I want to do, please let me if I'm more clear with that example.

Thanks.

0 Likes 0 ·

1 Answer

tannerp avatar image
0 Likes"
tannerp answered tannerp commented

@Manuel Sinco,

This might be kind of a shady technique, but it seems to work. All I did to know when to pull was add an Event-Triggered Source that listens to the List: On Push event.


Then that token pulls the other tokens in order of Priority. Once the original tokens are pulled, they are released and move on to the next activity. It seems to work, but let me know if you run into any issues with it. You should be able to sink the tokens that are pulling, but I sent them to a Custom Code for now so you can see how they work.

tokenpriority_2.fsm


list-on-push.png (13.6 KiB)
tokenpriority-2.fsm (30.6 KiB)
· 4
5 |100000

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

Manuel Sinco avatar image Manuel Sinco commented ·

Thank @tanner.p, actually I think it might work, it was a simple but useful idea, thanks. However, I'm still having my doubts based on the breath after the Event-Triggered Source. In my simulation, there are plenty of breaths and the reason that in the example I sent the message without time was based on that I don't want to interfere with them. Do you think that I should add the push to list also after the Breaths that I have?

Thanks.

0 Likes 0 ·
tannerp avatar image tannerp Manuel Sinco commented ·

After experimenting with this, I determined that it will only work with a Breathe activity before the Pull from List as shown below. Otherwise, the Event-Triggered Source releases the tokens to pull from the list before the items are pushed on the list (or something like that), and the tokens don't move on from the Push to List.

The good news is that you can set the time of the Breathe activity to 0.00 seconds. So this all happens in "zero" time.

I don't think you need a breathe before or after the Push to List activity, though. Only the one shown after the Event-Triggered Source and before the Pull from List.

tokenpriority-2 (1)_1.fsm

1 Like 1 ·
Manuel Sinco avatar image Manuel Sinco tannerp commented ·

Great, thanks @tanner.p I also did some testing and, in the same way as you, my plan was to do the breath with 0.00 time, but I also had different breaths in my model and I didn't want to interfered between them.

The solution was to use the Breath as you suggested and give to the breaths that I already had a time of 0.00001 and it works properly.

I think that the right answer is the comment that where you suggested using the push to list idea, so if you can change it to the main answer that would be great or I can accept the initial one if you prefer.

Thank you!

0 Likes 0 ·
Show more comments