AnyLogic
Expand
Font size

Split

AnyLogic: The Split block

The Split block creates one or more other agents for each incoming agent (“original”) and outputs these new agents through the outCopy port. The newly created agent can be a copy, a sibling, or something else, and can be of any type. The number of new agents can be changed dynamically.

The whole process takes zero model time.

There are two “extension points” where you can set up a new agent: its construction code New agent (copy) and the On exit copy code. In both places, you can access the original agent as original and the index of the new agent as indexCopy.

In the On exit copy action, you can also access the new agent (copy) as agent. There, you can also set the properties of the new agents. For example, if you have defined the custom parameter attribute in both the original and copy agent types, you can assign the value of the original agent’s parameter to a copy by writing the following:

agent.attribute = original.attribute;

To mark the relationship between the original and the new agents, create a custom field (for example, id) and assign the ID of the original to the new agents. To have copies join the original later, use this ID as the criteria.
To implement the actual “reunion”, consider using one or more Match blocks, or some custom code. In the simplest case (there is only one copy per original, and their order is not changed in their flows), use the Combine block to create one agent from two.

Parameters

Number of copies
The number of new agents to be created for the current original agent.
Value type: int
Local variable: agent — the original agent
New agent (copy)
The new agent type or an expression that resolves to the new agent type created by this block. To reference it in other properties, use its TCopy alias.
Local variables:
T original — the original agent
int indexCopy — the index of the new agent (among others created for the current original, is 0 if one new agent per original is created)
Change dimensions
If the option is selected (true), you will be able to change the dimensions of the agent created by this block specifying the new Length, Width, and Height values.
Value type: boolean
Local variables:
TCopy agent — the new agent
int indexCopy — the index of the new agent (among others created for the current original, is 0 if one new agent per original is created)
T original — the original agent
Length
[Visible if Change dimensions option is selected]
The new length of the created agent.
Value type:double
Local variables:
TCopy agent — the new agent
int indexCopy — the index of the new agent (among others created for the current original, is 0 if one new agent per original is created)
T original — the original agent
Width
[Visible if Change dimensions option is selected]
The new width of the created agent.
Value type:double
Local variables:
TCopy agent — the new agent
int indexCopy — the index of the new agent (among others created for the current original, is 0 if one new agent per original is created)
T original — the original agent
Height
[Visible if Change dimensions option is selected]
The new height of the created agent.
Value type:double
Local variables:
TCopy agent — the new agent
int indexCopy — the index of the new agent (among others created for the current original, is 0 if one new agent per original is created)
T original — the original agent
Location of copy
Defines the place where the new agent (copy) will be placed. Options are:
Not specified — No location for the created copies.
Network / GIS node — New agents (copies) will be placed in the specified network node, GIS point, or GIS region.
Attractor — New agents (copies) will be placed in the specified attractor.
(x, y, z) — Copies will be placed in the point with the specified X, Y, Z coordinates.
(latitude, longitude) — Copies will be placed in the given point on the GIS map with the specified Latitude and Longitude.
Geographic place — Copies will be placed in the particular location on the GIS map. Define this place using the Name of place parameter.
Syntax: InitialLocationType locationType Valid values:
Split.LOCATION_NOT_SPECIFIED
Split.LOCATION_NODE
Split.LOCATION_ATTRACTOR
Split.LOCATION_XYZ
Split.LOCATION_LATLON
Split.LOCATION_GEO_PLACE
Node
[Visible if Location of copy: Network / GIS node]
The network node, GIS point, or GIS region where the agents created by this block will be placed.
Value type: INode
Local variables:
TCopy agent — the copy agent created by this block
int indexCopy — the index of the new agent (among others created for the current original, is 0 if one new agent per original is created)
Attractor
[Visible if Location of copy: Attractor]
The attractor where the agents created by this block will be placed.
Value type: Attractor
Local variables:
TCopy agent — the copy agent created by this block
int indexCopy — the index of the new agent (among others created for the current original, is 0 if one new agent per original is created)
X, Y, Z
[Visible if Location of copy: (x, y, z)]
X, Y, and Z coordinates of the point where the agents will be placed.
Value type: double
Local variables:
TCopy agent — the copy agent created by this block
int indexCopy — the index of the new agent (among others created for the current original, is 0 if one new agent per original is created)
... located in
[Visible and applies only if Location of copy: (x, y, z)]
Specifies where the agents created by this block will be added to: either Level or Network.
Syntax: boolean destinationInNetwork
Default value: false
Level
[Visible and applies only if ...located in: Level option is selected]
The level the agent created by this block will be added to.
Value type: Level
Local variable: TCopy agent — the copy agent created by this block
Network
[Visible and applies only if ...located in: Network option is selected]
The network the agent created by this block will be added to.
Value type: INetwork
Local variable: TCopy agent — the copy agent created by this block
Latitude, Longitude
[Visible if Location of copy: (latitude, longitude)]
The latitude and longitude of the point on the GIS map where the new agents (copies) will be placed.
Value type: double
Local variables:
TCopy agent — the copy agent created by this block
int indexCopy — the index of the new agent (among others created for the current original, is 0 if one new agent per original is created)
Name of place
[Visible if Location of copy: Geographic place]
The name of the particular location on the GIS map, where the new agents (copies) are placed. Enter the name as text in quotation marks, for example: "London". The GIS map will be searched for a location with the specified name. The first location in the list of GIS search results is used.
Value type: String
Local variables:
TCopy agent — the copy agent created by this block
int indexCopy — the index of the new agent (among others created for the current original, is 0 if one new agent per original is created)
Speed
[Visible if Location of copy is specified]
The speed of the new agents (copies) generated by the block.
Value type: double
Default value: 10 meters per second
Local variables:
TCopy agent — the copy agent created by this block
int indexCopy — the index of the new agent (among others created for the current original, is 0 if one new agent per original is created)

Advanced

Add copies to
Specifies where the agents created by this block are stored: in the default population of the top-level agent of the model, or in a custom population (specified in the Population property). The default population (the Java collection of type AgentList) contained in the top-level agent can be accessed with the getDefaultPopulation() function.
Syntax: boolean addToCustomPopulation
Population
[Visible if Add copies to: custom population]
The name of the agent population where the agents created by this block will be stored.
Value type: AgentList
Local variables:
TCopy agent — the new agent
int indexCopy — the index of the new agent (see above)
T original — the original agent

Actions

On enter
Code executed when the original agent enters the block.
Local variable: agent — the agent
On exit copy
Code executed for each new agent when it exits the block.
Local variables:
TCopy agent — the new agent
int indexCopy — the index of the new agent (see above)
T original — the original agent
On exit original
Code executed when the original agent exits the block.
Local variable: agent — the original agent

Ports

in
The input port.
out
The output port for the original agents.
outCopy
The output port for the new agents created by the block.
How can we improve this article?