anylogic

State transition not responding to condition change in AnyLogic


I have created an agent with a Boolean attribute. When this attribute is true, the agent will transit from state A to state B. I am trying to set this attribute to true for each agent that exits a delay block on the main agent. The code is under the On at Exit section of the delay block and looks something like this. agent.Attribute = true. The problem is the agent is not changing state. What am I doing wrong ?


Solution

  • Without checking the transition, it is not possible to do give you more feedback. But usually, you cannot have transitions on variable changes. Ideally, you would make a function on the agent setAttribute(newValue), and on this function you could do this.attribute=newValue; send("attribute_set_to_true", this);. And on the transition you have the transition triggered by message.

    Now, at the exit of the Delay block, you call the function, which will both change the attribute value and send the message to trigger the transition.