question

Alejandro Huerta Torruco avatar image
0 Likes"
Alejandro Huerta Torruco asked Alejandro Huerta Torruco commented

How to end the simulation run?

Hello guys,

I want to end the simulation run when a given queue is empty. I tried this, but it didn´t work. Any suggestion?

Thanks in advance.

Alejandro

Choose One
simulation run modes
1.jpg (37.0 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.

Alejandro Huerta Torruco avatar image Alejandro Huerta Torruco commented ·

Hi @Jörg Vogel I tried that as well but it didn´t work. I attach the model. I want that when shipping queue is empty the simulation end, it should happen around second 930 000. But he clock still runs.

vsm-estado-actual.fsm

0 Likes 0 ·
Ralf Gruber avatar image
3 Likes"
Ralf Gruber answered Alejandro Huerta Torruco commented

Alejandro, Joerg,

OnExit of an object the content can never get zero, because while triggering the event the item is still considered part of the content. Therefore you have to check against "1", not "0", when you want to catch the last item before the Queue gets empty.

Best wishes

Ralf

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

Mischa Spelt avatar image Mischa Spelt commented ·

In addition to what Ralf said: you are now only ending the run when using the Experimenter.

If you want to also stop the clock when you are manually pressing Reset and Run, you should set "experimenter only" to "no".

0 Likes 0 ·
Alejandro Huerta Torruco avatar image Alejandro Huerta Torruco commented ·

Thank you all guys,

All your comments had helped me a lot. @Ralf Gruber in this model I am moving batches of 504 items every 27000s using Process Flow from the queue Shipping to the Sink Client. Based on what you said I set the following condition on Exit of Shipping

content(current)<=504 

but still didn´t stop at the right moment. It wait another 27000s, it stops at the second 972000 and it should stop at second 945000.

It is not cirtical for my model but I am still wondering what happened. Thank you for your support.

0 Likes 0 ·
Ben Wilson avatar image Ben Wilson ♦♦ Alejandro Huerta Torruco commented ·

Hi @Alejandro Huerta Torruco,

Think about that condition, content<=504. That means that any time there is an exit from the queue, and the content of the queue (before the item exits) is less than or equal to 504, that condition will be true. That means that this condition will be true 504 times (assuming the queue starts with a lot of content, and then just decreases).

So, with that in mind, consider what you are probably wanting. If the content of the queue during the exit trigger is 1, that means the last part in the queue is about to leave, and the queue will be empty. The condition you are probably going for is:

content(current)==1

This will be true right before the queue gets empty.

Keep in mind that depending on your simulation (I have not opened your model), you may have content coming and going from that queue, and it might be empty more than once. Perhaps that scenario does not occur in your model, but if it does, you probably need to base your model end time on something else.

0 Likes 0 ·
Alejandro Huerta Torruco avatar image Alejandro Huerta Torruco commented ·

Hi @Ben Wilson,

I see your point, with the code:

content(current)==1

it stops but only when the items leaves one by one, I am moving by batches. In my model the queue only gets empty once and that´s exactly the moment when I want it to stop, I have tried all that you mentioned but unfortunately it didn´t work out the way I wanted it. As I metioned it is not critical and I really aprecciate all your valuable comments.

Thank you very much.

Alejandro.

0 Likes 0 ·
Cameron Pluim avatar image
3 Likes"
Cameron Pluim answered

@Alejandro Huerta Torruco

It sounds like you have an expected number of items that will be moved through the model, or entering into the sink. If that is the case, I suggest you move the code to end the model to the OnEntry trigger of the sink and set it to trigger when:

current.stats.input.value == NumberOfBatches;
OR
current.stats.input.value == NumberOfItems;

Hopefully this helps.

5 |100000

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

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.