I want to create an agent component "Event" that will trigger when two conditions are met simultaneously:
alarm == true
getPeopleInsideCount() == 0
The construction is as follows: alarm && getPeopleInsideCount() == 0
I have a button that, when pressed, sets alarm to true, and the value of the function getPeopleInsideCount() gradually decreases to 0. But when both conditions become true, the event still does not trigger.
I saw this construction in an example from Anylogic. In their example, everything works correctly.
Firstly, here is the link to my model.
I tried using a variable instead of the dynamically changing function value.
I created a variable peopleCount
of type int
, initially set to 0.
At the output of all pedSource
, I added peopleCount++;
.
At the input of all pedSink
, I added peopleCount--;
.
Then I changed the condition for triggering the event to alarm && peopleCount == 0
, but this also did not yield any results.
Fair question. AnyLogic does not constantly re-evaluate all possible conditions (else your model would run extremely slow).
So it is your responsibility to manually check.
In your case:
shouldItTrigger
true
, execute what you want to seeThis is clean OOP design, btw.
PS: Do not get tempted by statecharts and conditional transitions. They promise you this capability but can easily fail if you do not know exactly how they work :)