AnyLogic
Expand
Font size

Assembler

The block allows a specified number of agents from several sources (5 or less) to be joined into a single agent. The type of the new agent, as well as its initialization, is specified by the user. The number of agents for each input required to produce one new agent is also specified using the block parameters (Quantity 1, Quantity 2, etc.). All arrived agents wait inside the block until all required agents arrive. Once the new agent can be built, the assembly operation starts. This operation takes the time specified in the Delay time parameter.

Assembly may involve resource usage — in this case you should specify what resource(s) are required to perform the assembly. For more detailed information on this topic, see Resources.

The new agent may be “completely new”, that is, a newly constructed agent whose properties possibly depend on the original agents, or it may be one of the original agents, again, possibly modified. If you want new agent to be exactly the same as the agent that arrived at the first input port, switch to the dynamic editor of the New agent parameter, and type there queue1.removeFirst().

Assembler may be used for a number of purposes. First, it can serve as a synchronization point to let one of the agents go further only after other ones arrive. Also this block can be used to combine different parts of a job.

In Assembler block agents may be disposed. However, the block does not know which of them will be disposed and doesn’t check if disposal is OK (that is, no resources, and so on). It is your responsibility to make sure the disposed agents are “clean”.

All agents that arrive into the block may be animated at the specified positions.

Parameters

Quantity 1, 2, …, 5
Number of agents required to arrive into in1, in2, …, in5 port to start producing a single new agent.
Syntax: int quantity1, quantity2, …, quantity5
New agent
The type of the agents exiting this block. Referred below as T.
Local variables: Queue queue1, queue2, …, queue5Assembler queues. You can access the agents stored there while generating new agent.
Default value: Agent
Change dimensions
If the option is selected, i.e. the value is 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 variable: T agent — the agent
Length
[Visible if the Change dimensions option is selected]
The new length of the assembled agent.
Value type: double
Local variable: T agent — the agent
Width
[Visible if the Change dimensions option is selected]
The new width of the assembled agent.
Value type: double
Local variable: T agent — the agent
Height
[Visible if the Change dimensions option is selected]
The new height of the assembled agent.
Value type: double
Local variable: T agent — the agent
Seize resources
Here you can choose whether the assembly requires resource(s) of just one single resource type (units of the same pool), or resources of different types ((alternative) resource sets). For more details, see Resources.
Syntax: boolean seizeFromOnePool
Resource sets
[Visible if Seize resources is set to (alternative) resource sets option]
Here you define set(s) of resources required to perform the assembly. You can define several alternative resource sets (add new list by clicking the Add list button). The resource set is chosen based on the availability of resource units. For more details, see Resources.
Value type: ResourcePool[][]
Local variable: T agent — the agent
Resource pool
[Visible if Seize resources is set to units of the same pool option]
ResourcePool block defining the resources requested to perform the assembly. For more details, see Resources.
Value type: ResourcePool
Local variable: T agent — the agent.
Number of units
[Visible if Seize resources is set to units of the same pool option]
Expression evaluated to obtain the required number of resource units for the agent.
Value type: int
Local variable: T agent — the agent
Delay time
Expression evaluated to obtain the delay time for the assembly operation.
Value type: double
Local variable: T agent — the current agent
Output buffer capacity
You can add a buffer where the assembled new agents (material items) can wait until the next block in the flowchart accepts them. For example, this might prove useful if the next block cannot accept the agents at the rate they are leaving the assembler block or if it requires the coordinates of the assembled agents. In this parameter you specify the maximum number of agents that can wait in this buffer. If you do not use the buffer (the value specified in this parameter is 0), the assembled agent will keep the seized resources (if any) and its animation will appear in the Location of assembled agent.
Syntax: int outputBufferCapacity

Animation

Location of assembled agent
Defines the place where the new assembled agent will be placed. There are six alternative options:
Not specified — You do not specify the new location for assembled agents.
Network / GIS node — Assembled agents are placed in the given network node, GIS point, or GIS region.
Attractor — Assembled agents are placed in the specified attractor.
(x, y, z) — Assembled agents are placed in the point with the specified coordinates X, Y, Z.
(latitude, longitude) — Assembled agents are placed in the given point on the GIS map with the specified Latitude and Longitude.
Geographic place — Assembled agents 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: Assembler.LOCATION_NOT_SPECIFIED
Assembler.LOCATION_NODE
Assembler.LOCATION_ATTRACTOR
Assembler.LOCATION_XYZ
Assembler.LOCATION_LATLON
Assembler.LOCATION_GEO_PLACE
Node
[Visible if Location of assembled agent is set to Network / GIS node option]
Network node, GIS point, or GIS region where the agents created by this block are put.
Value type: INode
Local variable: T agent — the agent created at this block
Attractor
[Visible if Location of assembled agent is set to Attractor option]
Attractor where the agents created by this block are put.
Value type: Attractor
Local variable: T agent — the agent created at this block
X, Y, Z
[Visible if Location of assembled agent is set to (x, y, z) option]
X,Y,Z coordinates of the point where the agents created by this block will be put.
Value type: double
Local variable: T agent — the agent created at this block
... located in
[Visible and applies only if the Location of assembled agent option is set to (x, y, z) option]
Specifies where the new assembled agent will be added to upon exiting the assembler block: either Level or Network.
Value type: boolean destinationInNetwork
Default value: false
Level
[Visible and applies only if the ...located in Level option is selected]
The level the agent will be added to once it exits the assembler block.
Value type: Level
Local variables: T agent — the agent
Network
[Visible and applies only if the ...located in Network option is selected]
The network the agent will be added to once it exits the assembler block.
Value type: INetwork
Local variables: T agent — the agent
Latitude, Longitude
[Visible if Location of assembled agent is set to (latitude, longitude) option]
Latitude and longitude of the point on the GIS map where the assembled agents will be placed.
Value type: double
Local variable: T agent — the agent
Name of place
[Visible if Location of assembled agent is set to Geographic place option]
The name of the particular location on the GIS map, where the assembled agents will get on generation. 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 variable: T agent — the agent
Speed
[Visible if Location of assembled agent is specified]
The speed of the assembled agents.
Value type: double
Default value: 10 meters per second
Local variable: T agent — the agent
Agent location (delay)
Space markup shape (node or path) where the agents are located while being in the internal Delay block.
Syntax: AnimationStaticLocationProvider entityLocationDelay
Agent location (queue 1, .. , queue 5)
Space markup shape (node or path) where the agents are located while being in the internal queue1, queue2, ... queue5 block.
Syntax: AnimationStaticLocationProvider entityLocationQueue1, entityLocationQueue2, ...

Priorities / preemption

Task priority
The priority of the task for the incoming agent (the larger the higher).
Value type: double
Default value: 0
Local variable: T agent — the agent
Task may preempt
If the option is selected, this task may preempt other tasks of the requested resource units.
Value type: boolean
Default valuetrue
Local variableT agent — the agent
Task preemption policy
Here you can choose what is done when a different task incomes for the resource unit(s) currently busy with the assembly operation.
No preemption — the current task continues executing.
Wait for original resource — the task is interrupted and waits for the same resource unit to finish it.
Terminate serving — the task is interrupted and never continued.
Seize any resource — the task is interrupted and tries to seize any resource of the specified type.
Continue without resource — the task is finished without resources assistance.
Default value: No preemption
Value type: TaskPreemptionPolicy
Valid values:
Assembler.PP_NO_PREEMPTION
Assembler.PP_WAIT_FOR_ORIGINAL_RESOURCE
Assembler.PP_TERMINATE_SERVING
Assembler.PP_SEIZE_ANY_RESOURCE
Assembler.PP_CONTINUE_WITHOUT_RESOURCE
Local variable: T agent — the agent
Auto suspend/resume agents
[Visible if Task preemption policy is set to Wait for original resource or Seize any resource option]
This parameter defines whether the agent whose task is suspended should be automatically suspended in its current flowchart block and automatically resumed at the time when the resources become available.
Syntax: boolean suspendResumeEntities
Default value: true
Enter for terminated agents
[Visible if Task preemption policy is set to Terminate serving option]
Enter block starting the flowchart branch for the agents which lost all obtained resource units because of Terminate serving preemption policy, when one of units in the resource set gets grabbed by another task with higher priority.
Value type: Enter
Local variables:
T agent — the agent
Agent unit — the resource unit which has originated termination

Advanced

Customize resource choice
If the option is selected, you can choose some specific resource units for the operation (using the Resource choice condition below).
Syntax: boolean customizeResourceChoice
Default value: false
Resource choice condition
[Visible if Customize resource choice is selected]
Resource choice condition — The Boolean expression that is checked to find the specific resource unit(s) that can perform the operation. If no currently available resource units matches the specified condition (the condition returns false), Assembler will wait for the first resource unit that matches the condition.
For example, an agent can be assigned a helper resource unit that is stored in the myAssistant field within that agent. We need a particular resource unit, worker, to always be assigned to this specific agent. So in this case, the Resource choice condition is agent.myAssistant == worker.
Value type: boolean
Default value: true
Local variables:
T agent — the agent
Agent unit — the resource unit
ResourcePool pool — the resource pool
Resource selection
Specifies which resource units can be selected for the given agent.
Off (chooses some matching unit) — No specific preference for the selection.
Nearest to the agent — The resource unit that is closest to the current agent.
The most preferred — The resource unit is selected by comparing resources against each other. The comparison algorithm (or its call) is placed in the field "unit1 is preferred to unit2".
Unit with top rating — The resource unit with the highest rating is selected. The rating (or the algorithm that calculates it) is specified by the user in the Unit rating field.
If Off is selected, the first unit that satisfies the Resource choice condition is selected; AnyLogic checks the idle units against the condition first, then the busy units.
In all other cases, all units are scanned, including the busy ones, which means that this block’s task may displace theirs. If this does not suit you, consider using a more specific Resource choice condition.
Value type: ResourceSelectionMode
Default value: Off (chooses some matching unit)
Valid values:
Assembler.RESOURCE_SELECTION_SOME_UNIT
Assembler.RESOURCE_SELECTION_NEAREST
Assembler.RESOURCE_SELECTION_BASED_ON_COMPARISON
Assembler.RESOURCE_SELECTION_BASED_ON_RATING_VALUE
Local variables:
T agent — the agent
ResourcePool pool — the resource pool
"unit1 is preferred to unit2"
[Visible if Resource selection is set to The most preferred option]
The comparison algorithm (or its call) that is used for choosing a resource for the given agent. The algorithm compares resources to each other. It should return true if the resource unit1 has higher preference than the resource unit2 (and false otherwise, including the case of choice equality). The algorithm should provide transitiveness.
Value type: boolean
Default value: false
Local variables:
Agent unit1 — the first resource to be compared
Agent unit2 — the second resource to be compared
T agent — the current agent
Unit rating
[Visible if Resource selection is set to Unit with top rating option]
The rating value of this unit. The rating is used to choose a unit for the given agent (the larger the higher, unit with the top rating value will be chosen).
Usually an algorithm or a function call is placed here to calculate the rating with the help of the available local variables.
Value type: double
Local variables:
T agent — the agent
Agent unit — the resource unit
Add combined agents 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
Default value: default population(false)
Population
[Visible if Add combined agents to is set to custom population option]
The name of the agent population where the agents created by this block will be stored.
Value type: AgentList
Local variable: T agent — the agent created by this block.
Force statistics collection
This block contains internal blocks that collect statistics. If the statistics collection is turned off for all Process Modeling Library blocks in the model by the PML Settings block, this option enables you to override this setting and collect the statistics for this specific block. Otherwise, the statistics will be collected regardless this setting.
Syntax: boolean forceStatisticsCollection
Default value: false

Actions

On enter 1, 2, ..., 5
Code executed when an agent enters the block at in1, in2, …, in5.
Local variable: T1, T2, ... T5 agent — the agent
On enter delay
Code executed when the agent enters the Delay.
Local variables: T agent — the agent
double delayTime — the delay time evaluated for the agent
On at exit
The callback executed when agent has finished its delay and ready to leave this block (if the subsequent block is not busy).
Local variable: T agent — the agent
On exit
Code executed when the resulting agent exits the block.
Local variable: T agent — the resulting agent that will exit the block
On task suspended
[Visible if Task preemption policy is set to Wait for original resource or Seize any resource option]
Callback for action executed when agent task is suspended because of Seize any resource and Wait for original resource preemption policy, when its unit gets grabbed by another task with higher priority.
Local variables:
T agent — the agent
Agent unit — the resource unit
On task resumed
[Visible if Task preemption policy is set to Wait for original resource or Seize any resource option]
Callback for action executed when agent resumes processing after it has been suspended because of Seize any resource and Wait for original resource preemption policy.
Local variables:
T agent — the agent
Agent unit — the resource unit
On task terminated
[Visible if Task preemption policy is set to Terminate serving option]
Callback for action executed when agent loses all units obtained in this Seize block because of Terminate serving preemption policy, when one of units in the resource set (defined in this Seize) gets grabbed by another task with higher priority.
Local variables:
T agent — the agent
Agent unit — the resource unit which has originated termination

Functions

Agent
Function Description
T remove(Agent agent) Removes the specified agent from the queue and returns it. If the agent is not contained in the queue, returns null.

agent — The agent to remove.
T resume(Agent agent) Resumes the specified suspended agent. If the agent is not suspended, throws an error.

agent — The agent whose flowchart movement is to be resumed.
T suspend(Agent agent) Suspends the specified agent.

agent — The agent to suspend.
Internal queue
Function Description
int queueSize(int n) Returns the number of agents in the queue with the given number.

n — The number of the queue.
Agent queueGet(int n, int index) Returns the agent with the given index from the queue with the given number.

n — The number of the queue.
index — The index of the agent.
Internal delay
Function Description
int delaySize() Returns the number of agents in the internal Delay block.
T delayGet(int index) Returns the agent at the index position in the internal Delay block (the oldest agent is at the position 0).

index — The position (index) of the agent to get.
Output buffer
Function Description
int outputBufferSize() Returns the number of agents in the internal output buffer.
T outputBufferGet(int index) Returns the agent (the already assembled material item) from the specified position in the output buffer (the oldest agent is at the position 0).

index — The position of the agent to get.
Resource choice
Function Description
void recalculateResourceChoiceConditions(Agent agent) Recalculates the choice conditions for the specified agent which is currently waiting in the queue of this block. You can use this function when some resource units that previously weren’t available for seizure by a particular agent may have become available due to changed conditions.

agent — The agent whose selection conditions are to be recalculated.
void recalculateResourceChoiceConditions() Recalculates the choice conditions for all agents currently waiting in the internal queue of this block. You can use this function when some resource units that previously weren’t available for seizure may have become available due to changed conditions.
Statistics
Function Description
double utilization() Returns the mean utilization of this block. The value returned is the average (collected over time) of the number of agents served.
boolean isStatisticsCollected() Returns true if the block collects statistics.
void resetStats() Resets the statistics collected for this block.

Internal blocks

Queue queue1, queue2, queue3, queue4, queue5
The internal queues.

Ports

in1, in2, in3, in4, in5
The input ports.
out
The output port.
How can we improve this article?