Search code examples
statetransitionanylogic

Agent Go Back to previous state. AnyLogic


I want my agent to change its state and go to a new state called interruption! I want the agent to stay in the interruption state for a while and then go back to the previous state that it comes from! I can use timeout transition if there was only one state leading to this interruption state! But there are three states that can be transit to this interruption state. Lets name them state A, State B, or State C.

For example, I want the agent go back to state A, if it initially came form Sate A! The same for state B, and C.

There are functions that shows the current state of the agent but what if I want to get its previous state not current one?

I think I should use a combination of timeout and condition transitions! But What I should write for the condition?

Looking forward to your help. Thank You, Neda


Solution

  • You don't need any of that... There's an object in the statechart or agent palette called history state... The help documentation explains the history state pretty well and it has deep and shallow options you can read there..

    statechart

    If you check the statechart above, if your agent is in state "state1" and it moves to state4, then when it get backs to "state3" it goes back through the history state that will take the agent back to its previous state "state1"

    This is how you can do it, and you can read the documentation for more info about it