Agents may represent very diverse things: vehicles, units of equipment, projects, products, ideas, organizations, investments, pieces of land, people in different roles, etc.
Agents are main building blocks of AnyLogic model. Agent is a unit of model design that can have behavior, memory (history), timing, contacts, etc.
Within an agent you can define variables, events, statecharts, System Dynamics stock and flow diagrams, you can also embed other agents, add process flowcharts. You can define as many agent types in your model as there are different types of agents.
Design of an agent typically starts with identifying its attributes, behavior, and interface with the external world. In case of large number of agents with dynamic connections (such as social networks) agents can communicate by calling functions.
The agent internal state and behavior can be implemented in a number of ways. The state of the agent can be represented by a number of variables, by the statechart state, etc. The behavior can be so to say passive (e.g. there are agents that only react to message arrivals or to function calls and do not have their own timing), or active, when internal dynamics (timeouts or system dynamics processes) of the agent causes it to act. In the latter case agents most probably would have event and/or statechart objects inside.
Agent is an instance of an agent type. Agent types are developed by the user. You create agents using the New Agent wizard that opens when you drag Agent element from the Agent palette on the diagram. On the first page of the wizard you choose whether you want to create a population of agents, just one agent, or only define the agent type and do not create any agents of this type as yet.
– The name of the agent type.
Since AnyLogic generates Java class for each agent type, you should follow Java naming guidelines. Please start name with an uppercase letter.
Ignore – If selected, the agent type is excluded from the model.
properties are available only when this agent type has any parameters.
Here you can rearrange parameters of this agent. Agents of this type will list parameters in their property view in this well-defined order.
On startup – Code to be executed after all agents throughout the whole model are constructed, connected, and initialized, and before anything else is done. This is a place for some additional initialization and starting agentt’s activities such as events. The order of execution of On startup code of different objects is not guaranteed.
On destroy – Code to be executed on destroying agent of this type (e.g. when the user terminates the experiment and the root object is destroyed, On destroy code of embedded objects are executed in some order).
On arrival to target destination – Code to be executed when the agent arrives at the destination.
On before step – Code to be executed for this agent before a step is taken in agent based model with synchronization. On before step actions are executed for agents in some deterministic order.
On step – Code to be executed for this agent on taking a step in agent based model with synchronization. On step actions are executed for agents in some deterministic order.
Use in flowcharts as
– Here you choose the role for this agent in the flowcharts. Selecting Agent here, you enable the agent passing through the Process Modeling library flowcharts, choosing Pedestrian enables it flowing through Pedestrian Library flowchart
blocks, etc. Depending on the chosen role, you will obtain access to role-specific API which extends beyond the API of a generic agent type.
On enter flowchart block – Here you can write the code to be executed when this agent enters the flowchart.
On exit flowchart block – Here you can write the code to be executed when this agent exits the flowchart.
On seize resource – Here you can write the code to be executed when this agent seizes the resource while being in the flowchart.
On release resource – Here you can write the code to be executed when this agent releases the resource while being in the flowchart.
Initial speed – [Visible if Space type is Continuous or GIS] The speed of the agent.
Rotate animation towards movement – [Visible if Space type is Continuous or GIS] The heading of the agent.
Rotate vertically as well (along Z-axis) – If selected, the agent shape will be headed towards the target during the agent movement.
Select the agents you want to place in the environment – Here you can select checkboxes in the list of agents that will live in this enviroment.
– The group of buttons, specifying the type of environment's space:
GIS map – [Visible if GIS Space type is chosen] The name of the GIS map that defines the geospatial space for the environment.
Width – [Enabled if Continuous, or Discrete Space type is chosen] The horizontal dimension of the area visualizing the space on presentation (in pixels). In discrete space, cell width is calculated by dividing the specified Width by number of Columns in the space.
– [Enabled if
Discrete Space type
is chosen] The vertical dimension of the area visualizing the space on presentation (in pixels). In discrete space, cell height is calculated by dividing the specified
by number of
in the space.
Columns – [Enabled if Discrete Space type is chosen] The number of columns in discrete space.Rows – [Enabled if Discrete Space type is chosen] The number of rows in discrete space.
– [Enabled if
is chosen] Sets a neighborhood model, that determines the way the agent neighbours are defined in the discrete space. There are two options:
– [Enabled if
Continuous Space type
is chosen] Defines the layout type (the way agents are initially located in the environment).
If you wish your agents to be placed according to the set layout when the model starts, check the Apply on startup checkbox to the right.
AnyLogic supports the following standard continuous layouts:
Connections per agent – [Enabled if Network type is Random, Small world, or Ring lattice] The average (or exact) number of connections per agent. Applies to random, ring lattice and small world networks.
Connection range – [Enabled if Network type is Distance based] Defines the radius of the connection area for the agent. The agent will be connected to all agents, who are within a radius of defined Connection range.
Neighbour link fraction – [Enabled if Network type is Small world] Parameter for Small world network type.
M – [Enabled if Network type is Scale free] Parameter for Scale free network type: either M and M0 (start number of hubs). For details please refer to Wikipedia.
– If selected, agent-based modeling is synchronous.
assumes discrete time steps and agents (and maybe environment) executing their actions synchronously at these time steps.
By adding such synchronization you do not restrict the dynamics of your model with discrete time steps. Your agents as well as other objects are still able to schedule events, execute state transitions and run other processes - this will go in parallel with steps execution.
You can customize the step duration using the Step duration property. Environment actions are defined using the On before step and On after step properties below.
Step duration (in model time units) – [Enabled if Enable steps is selected] This property enables the user to set some custom step duration in the case of synchronous modeling (the default step duration is 1 model time unit).
Imports section – import statements needed for correct compilation of the class code. When Java code is generated, these statements are inserted before definition of the Java class.
Implements (comma-separated list of interfaces) – Comma-separated list of interfaces implemented by the class.
Additional class code – Arbitrary member variables, constants, and functions are defined here. This code will be inserted into the class definition. You can access these class data members anywhere within this agent. The functions can be called on some agent activity; e.g., on event occurrence or on triggering statechart transition. You can place any Java code here, however, we recommend to use the Java class element instead of defining nested classes here, and use option lists instead of defining Java enumerations.
Parameterized type – If selected, you can define generic parameters for this agent type in the Type parameter field below.
Extends other agent – One agent type may extend some other agent type. This feature gives you an ability to expose the functionality common for agents of different types into one place, "base agent type". All agent types that extend the same "base agent type" will share this functionality.
Log to database - If selected, all information about agents of this agent type (their parameter values, statistics on movement and time spent in different states, etc.) will be saved into the model execution log (if logging is turned on in the model's Database properties).
Create datasets for dynamic variables
– If selected, AnyLogic creates datasets for all dynamic variables (stock,
variables), contained in this agent type and collects the well-defined number (specified in the
Limit the number of data samples up to first ... items
property) of latest samples of these variables in these datasets. Samples collection will start at either
First update time (absolute), or at the
if you select
Use calendar dates
to define the first update time. Samples are collected with the specified
that you can set up below.
If this option is not set, the user needs to create dataset for each dynamic variable by himself.
Recurrence time – [Enabled if Create datasets for dynamic variables is set] Defines the recurrence time for collecting samples of dynamic variables.
Limit the number of data samples up to the first ... items – [Enabled if Create datasets for dynamic variables is set] Defines the number of samples stored in each dataset automatically created by AnyLogic for dynamic variable.
Agent can represent a single agent or population of agents. A population represents a collection of agents of the same type.
At the top of the properties page of the agent population you can see the name of the agent type.