In AnyLogic, I am trying to make a little service loop based on a variable inside an agent. For some reason, my variables are not changing as I expect and I can't make it work.
In my block selectHowMany
i have the following code, that is supposed to modify the variable inside customer population:
ped.howMany = ped.howMany + 1.0
ped.howMany = ped.howMany + 2.0
ped.howMany = ped.howMany + 3.0
ped.howMany = ped.howMany + 4.0
ped.howMany = ped.howMany + 5.0
my model with selectHowMany block open
Then, I want the output to determine wether the ped should go to service or to sink, depending if the howMany
variable is greater than 1 or not. For that I have another boolean variable isItEnough
inside customer population and 'if' statement in output
block.
if(agent.howMany < 1.0){
agent.isItEnough = false;
}
Condition:
agent.isItEnough = true
Lastly, at the exit of each of the service blocks I have the following code, so that the variable is actually modifying based on pedestrian's actions:
ped.howMany = ped.howMany - 1.0
My intention was, that pedestrian entering the selectHowMany
block will define the variable inside the customer population determining how many times will this pedestrian use one of the service blocks.
No matter how I try the pedestrian is never seizing using blocks (no matter which selectHowMany output it exits), so something is not correct with modifying the variables. The ped is in continuous loop and it never reaches sink.
I hope someone will be able to help me.
Many thanks, Peter