Removes agents from a given Queue object and adds them to the contents of the incoming agent ("container"). The Queue block may be either connected to the inPickup port of Pickup or specified in the parameter queue (the latter has priority over connected object). When an agent arrives at in port, Pickup iterates through the contents of the queue and selects the agents according to the given mode, which can be: all agents, first N agents, an exact quantity of agents (the block will wait until the specified number is reached), agents for which the given condition is true. The whole operation takes zero time.

In the mode where an exact quantity of agents is selected, not only the Queue block, but any other block can be connected to the inPickup port of the Pickup block.

The pickup condition is evaluated when the agent is still in the queue, but On pickup action is called after the agent has been removed from the queue and added to the container.

Some examples of pickup condition:

true - all agents in the queue will be picked up

container.contents().size() < maxSize - at most maxSize first agents will be picked up. Here we access the agents currently contained in the agent-container using the container's function contents(). This function returns these agents in the form of a collection. The current number of agents inside the container is obtained as container.contents().size()

agent instanceof Car & ((Car)agent).age < 3 - only cars younger than 3 years

Later on the added agents can be dropped off using the Dropoff object, or, with discarding the container agent, by Unbatch. Consider also using Batch instead of Pickup if you need just to group the agents.

Demo model: Pickup and Dropoff


Defines how the agents are selected to be picked up from the Queue object. You can set up this object to remove All available agents from the Queue, a Quantity (if available), wait until the specified number of agents has accumulaled (Exact quantity (wait for) or remove agents for which the specified boolean condition is true (While condition is true).
Get value: pickupType
Set new value at runtime:
set_pickupTime(new value)
Valid values: While condition is true - Pickup.BY_CONDITION
                      Quantity (if available) - Pickup.QUANTITY
Exact quantity (wait for) - Pickup.EXACT_QUANTITY
                      All available agents - Pickup.ALL
Condition [dynamic]
[Visible if agents are picked up While condition is true] Condition evaluated for each agent in the Queue to determine whether it should be picked up. The condition expression may depend on the contanter agent as well as on the "candidate" to be picked up.
Value type: boolean
Local variables: agent - the agent to be picked up
                          TContainer container - the container agent
Default value:   true - all agents are picked up
Quantity [dynamic]
[Visible if Quantity (if available) of agents are being picked up] Expression evaluated to determine how many agents should be picked up.
Value type: int
Local variable: TContainer container - the container agent
Pick from
Choose here how you specify the Queue block storing the agents to be added into the agent-container.
You can set the block to pick agents from the Queue connected to the port (namely, to the lower inPickup port), or from the Specified Queue object (in this case you specify the block in the Queue object field below).
Syntax: boolean queueIsConnectedToPort
Queue object [dynamic]
[Visible and applies only if the option Pick from is set to Specified Queue object] The Queue block from which the agents will be picked up. If specified, has priority over the connected Queue block graphically connected to the inPickup port.
Value type: Queue
Local variable: TContainer container - the container agent
Forced pushing
If the option is selected (true), when agents finish processing at the block, they are instantly pushed further regardless the state of the succeeding block.
If the option is not selected, agents are not pushed, but pulled: only when the succeeding block is ready to accept one more agent, it requests the agent from this block, and only then this agent passes further.
Syntax: boolean pushProtocol
Default value: false
On enter [code]
Code executed when the container enters this block.
Local variable: TContainer container - the container agent
On pickup [code]
Code executed for each agent that is removed from the queue and added to the container.
Local variables: agent - the agent being picked up
                          TContainer container - the container agent
On exit [code]
Code executed when the container exits this block.
Local variable: TContainer container - the container agent


The input port.
The input port that should be connected to the out port of a Queue object. The port can be left unconnected if the Queue block is specified in the properties of this Pickup block (the option Pick from is set to Specified Queue object).
The output port.