AnyLogic
Expand
Font size

Release

AnyLogic: The Release block

The Release block releases a specified number of resource units that were previously seized by the Seize block. Moving resources can Return to home location (if they are not immediately seized by another agent) or Stay where they are after being released (this setting is configured with the Moving resources parameter).

The operation takes zero time.

All seized resources must be released before the agent is discarded by the Sink block.

Optionally, you can define the wrap-up task to be performed by the resource unit when it completes the main task and is released by the agent. The wrap-up task can be defined using the wrap-up flowchart (starting from the bottom wrapUp port and ending with the ResourceTaskEnd block).

A set of resources may have multiple tasks with different priorities and preemption policies.

  • If all tasks have the same priority, they will be executed in the usual way following their occurrence schedule. If there are enough resource units available, tasks can be executed simultaneously. If two tasks have the same priority, but one of them was suspended for some reason, this suspended task will be picked1.
  • If you have configured no preemption policy for the tasks, these tasks will be executed one after another following their occurrence schedule. If there are enough resource units available, tasks can be executed simultaneously.
  • The occurrence of one task does not reset the priorities for other tasks.
1 Each resource unit may receive requests from different sources. When a single resource unit receives multiple tasks, suspended and new, with identical priority values, some rules apply to the picking order:
  • The suspended tasks from the individual queue of the resource unit have the highest priority.
    This queue is formed by agents waiting in blocks that have the Task preemption policy set to Wait for original resource.
  • After that, the suspended tasks from the queue of the ResourcePool block are processed.
    This queue is formed by agents waiting in the blocks that have the Task preemption policy set to Seize any resource.

Once the suspended tasks from these queues are completed, the resource unit begins to process new tasks from their individual queues, and after that, the queue of the ResourcePool block.

If this order does not suit your needs, manually decrease the task’s priority by code, using the On task suspended action of the block.

Parameters

Release
Defines what resources are being released. There are five alternative choices: All seized resources (of any pool), All resources seized by given Seize block(s), All seized resources from given pool(s), Specified resources (list of pools), Specified quantity of resources.
Syntax: Release.ReleaseMode releaseMode
Valid values:
Release.ALL
Release.ALL_FROM_SEIZES
Release.ALL_FROM_POOLS
Release.SPECIFIED_RESOURCES
Release.SPECIFIED_QUANTITY
Seize blocks
[Visible if Release is set to All resources seized by given Seize block(s)]
Expression evaluated to obtain the resource pool where the units being released belong to. If left unspecified or returns null, the connected pool is assumed.
Value type: Seize[] seizeBlocks
Get value: seizeBlocks
ResourcePool objects
[Visible if Release is set to All seized resources from given pool(s) or Specified resources (list of pools)]
List of names of ResourcePool blocks whose units are being released. One unit will be released per pool name, so if you wish to release two or more units of the same pool, you should list that pool twice, e.g. { doctor, nurse, nurse }.
Value type: ResourcePool[]
Local variable: agent — the agent.
Resource pool block
[Visible if Release is set to Specified quantity of resources]
The name of ResourcePool block — resource pool where the units being released belong to.
Value type: ResourcePool
Local variable: agent — the agent.
Quantity released
[Visible if Release is set to Specified quantity of resources]
The number of resource units being released. In case the Quantity released evaluates to 0, the resource pool is not checked, and the agent just flows through the block.
Value type: int
Local variable: agent — the agent.
Moving resources
Defines whether moving resources should Return to home location (if they are not immediately seized by another agent) or Stay where they are after being released.
Value type: boolean
Default value: Return to home location (true)
Local variables:
agent — the agent.
Agent unit — the resource unit.

Wrap-up tasks

Wrap-up (e.g. move home)
Here you select in what case resource units will return home and optionally do the wrap-up task defined with the wrap-up flowchart (starting from wrapUp port and ending with the block ResourceTaskEnd).
There are three alternative options:
each time — wrap-up and/or “return” tasks will be done each time the resource unit finishes its main task and is released by the agent. In this mode, the wrap-up task cannot be preempted by any other task, including the Downtime tasks.
if no other tasks — wrap-up and/or “return” tasks are done only if there are no other tasks currently waiting for the resource unit.
custom — if you select this option, you can define the priority and preemption policy for wrap-up tasks using the parameters below. In this case the priority of the wrap-up task will be compared with priorities of other incoming tasks, and the specified preemption policy will be used to select the next task for this particular resource unit.
Value type: WrapUpPolicy
Valid values:
Release.WRAP_UP_ALWAYS — each time
Release.WRAP_UP_IF_NO_TASKS — if no other tasks
Release.WRAP_UP_PRIORITY_BASED — custom
Local variables:
agent — the agent.
Agent unit — the resource unit.
'Wrap-up' priority
[Visible and applies if the option Wrap-up (e.g. move home) is set to custom]
Sets the priority for wrap up task (see above).
Value type: double
Default value: 0
Local variables:
agent — the agent.
Agent unit — the resource unit.
'Wrap-up' preemption policy
[Visible and applies if the option Wrap-up (e.g. move home) is set to custom]
Specifies the policy for wrap up task preemption by some other task:
  • No preemption — wrap-up task cannot be preempted.
  • Terminate — wrap-up task will be preempted by the incoming task and terminated.
Value type: ResourcePreemptionPolicy
Valid values:
Release.PP_NO_PREEMPTION
Release.PP_TERMINATE
Local variables:
agent — the agent.
Agent unit — the resource unit.
'Wrap up' usage statistics are
Choose how the statistics for the wrap-up task should be collected: counted as 'busy', counted as 'idle', or not collected at all.
Value type: ResourceUsageState
Valid values:
Release.USAGE_BUSY
Release.USAGE_IDLE
Release.USAGE_NOT_COUNTED
Local variables:
agent — the agent.
Agent unit — the resource unit.

Actions

On enter
Code executed when the agent enters the block.
Local variable: agent — the agent.
On release
Code executed when the resource unit has been released. Note that a custom “wrap up” task can be assigned to this resource unit (either “move to home location” task, or a custom wrap-up task defined with a flowchart starting with wrapUp port and ending with ResourceTaskEnd block).
Local variables:
agent — the agent.
Agent unit — the resource unit.
On exit
Code executed when the agent exits the block.
Local variable: agent — the agent.
On 'Wrap-up' terminated
Code executed when resource's wrap-up task is terminated (preempted by some other task with higher priority).
Local variables:
agent — the agent which originally seized this resource unit.
Agent unit — the resource unit.

Ports

in
The input port.
wrapUp
The port where you can connect the block that starts the wrap-up process flowchart. This flowchart should end with ResourceTaskEnd block.
out
The output port.
How can we improve this article?