AnyLogic
Expand
Font size

Split

For each incoming agent (“original”) creates one or several other agents and outputs them via outCopy port. A new agent created may have a meaning of a copy, a sibling, etc. and can be of arbitrary type. The number of new agents can be changed dynamically.

The whole operation takes zero model time.

There are two “extension points” where you can setup a new agent: its construction code New agent (copy) and 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. It is your responsibility to set the properties of the new agents, so you can do it here. For example, if you have defined the custom parameter attribute in both original and copy agent types, you can assign the value of the original agent’s parameter to a copy: agent.attribute = original.attribute;

In case you wish to mark the relation between the original agent and the new ones, you can have a custom field (e.g. id) and assign the ID of the original to the new agents. If later on you wish the siblings/copies to join the original, you can use that ID as the criteria. The actual “reunion” may be implemented using one or several Match blocks or by a custom code. In the simplest case when there is just one copy per original and the order of them is not changed in their flows, you can use Combine block to compose 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)
New agent type (or expression returning the type of the new agent (copy)) created by this block. Referred below as TCopy.
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 below.
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. There are several alternative options:
Not specified — You do not specify the location for created copies.
Network / GIS node — New agents (copies) are placed in the given network node, GIS point, or GIS region.
Attractor — New agents (copies) are placed in the specified attractor.
(x, y, z) — Copies are placed in the point with the specified coordinates X, Y, Z.
(latitude, longitude) — Copies are placed in the given point on the GIS map with the specified Latitude and Longitude.
Geographic place — Copies are placed in the particular location on the GIS map. You define this place using the Name of place parameter below.
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]
Network node, GIS point, or GIS region where the agents created by this block are put.
Value type: INode
Local variables:
TCopy agent — the copy agent created at 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]
Attractor where the agents created by this block are put.
Value type: Attractor
Local variables:
TCopy agent — the copy agent created at 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,Z coordinates of the point where the agents will be put.
Value type: double
Local variables:
TCopy agent — the copy agent created at 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)]
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 at 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. You specify the name as text put in quotes, e.g. "London". GIS map will search for a location with such name. The first location from the list of GIS search results will be used.
Value type: String
Local variables:
TCopy agent — the copy agent created at 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 at 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
Here you specify where the agents created by this block will be stored: in the default population of the top-level agent of the model or in a custom population (specified below in the Population property). The default population (Java collection of type AgentList) contained in the top-level agent can be accessed with the function getDefaultPopulation().
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?