AnyLogic
Expand
Font size

Accessing agent parameters from a flowchart

You can create custom agent types. They have their own diagrams where you can add parameters, statecharts, functions, etc.

To generate the agents of a custom type you should choose this type in the New agent parameter of the corresponding block, e.g. Source. Then the agents in the process flow will be of that specified type, and you will be able to use agent in the flowchart blocks to explicitly address the additional functionality of this custom type. You can check if the custom agent type has propagated across the flowchart from Source in the Advanced properties section of the blocks: the Agent type parameter will be pre-filled with your custom agent type.

For example, we specify Customer in the New agent parameter of the Source block of this flowchart below. Now all agents that pass through this flowchart are of the type Customer, and we can write code like agent.serviceTime = delayTime in On enter parameter of Delay and access the parameters of the Customer type.

If some agents in the flow have type Customer, and some, say, Staff, you should leave the New agent default value (Agent) and analyze the type manually by writing e.g.:

if( agent instanceof Customer ) ((Customer)agent).serviceTime = delayTime
How can we improve this article?