0
votes

Is it possible to use a simple true/false statement in a Hold block's blocking condition to block an agent if condition is true and unblock if condition is false? If not, is there another way?

I need the Hold block to block if the condition resourcePool1.idle()==0 is true, otherwise I need it to unblock. I have tried a few different statements, but none of them are working.

2
What exactly have you tried? What you described seems reasonable. - Emile Zankoul
I have tried using statements like resourcePool1.idle()==0 ? true : false and using the setblocked() function, but it only blocks and does not seem to unblock if false. - KrisG125
Did the new answer below work? - Emile Zankoul
Yes, thank you! - KrisG125

2 Answers

0
votes

The hold block likely does not check dynamically for your condition but only once at the start. It is your responsibility to tell it about the condition having changed. (Else it would need to check constantly, which is bad design and computationally expensive).

So instead, redesign your model so it updates the Hold block explicitly (change to "manual" mode) when the situation arises. In your case, whenever a resource turns idle, it should check if all are idle and then change the Hold block manually.

0
votes

Since your condition is related to resources, I would recommend the following:

enter image description here

In the on seize and on release fields, write the following:

if(resourcePool.idle() == 0)
    hold.setBlocked(true);
else
    hold.setBlocked(false);

Note that since you are in the resource pool itself, you can replace its name by self.

This way, you optimize your model given that the block condition is only evaluated when its outcome might change i.e. when a resource is seized or released. No need to check the condition any other time.