Downtime

Defines either maintenance, repairs, or any other kind of activity that differs from the usual activity of the resources defined by the ResourcePool block.

You can schedule the recurrent downtime activities either through different types of triggers or with the help of the AnyLogic Schedule element. You can also customize the moment of the first occurrence for this activity.

If you define several triggers for the first occurrence, then the first of them to fire will initiate the countdown for the triggers that define the period of recurrence for the this activity, provided that you have specified them.

If you don't define any triggers for the first occurrence and only specify the recurrence period, the first occurrence will take place when the specified period runs out. E.g., if you define the cycle of 50 working hours, the first downtime will take place once the resource has accumulated the 50 working hours from the start of the model run and will repeat with the same frequency until you stop the simulation.

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

The downtime tasks of a specific ResourcePool block can occur simultaneously with the end of shift specified by the properties of this block. In this case, these downtime tasks will move to the event queue of this ResourcePool. They will start upon the completion of the end of shift task, that is, the start of the next shift.

Demo model: Maintenance of a Coffee Machine

Parameters

In all dynamic parameters and code actions, the resource unit is available as a local variable unit.
Unit type [dynamic]
The type of resource units performing the task. This resource type is referred to below as T. To have different types of resources perform the same downtime task, select Agent here.
Default value: Agent
Type:
The type of downtime task performed by the resource units. The available options are Maintenance, Failure / Repair or Custom.
Syntax: Downtime.ActivityType activityType
Valid values: Downtime.ACTIVITY_MAINTENANCE; Downtime.ACTIVITY_FAILURE; Downtime.ACTIVITY_CUSTOM
Defined by [dynamic]
[Visible and applies only if the Type is defined as either Maintenance or Custom] Here you can choose whether you want to schedule tasks by defining the Triggers or you prefer to use AnyLogic Schedule instead.
Type of value: DowntimeDescriptor.TriggerType
Schedule [dynamic]
[Visible if the Defined by parameter is set to Schedule] - The schedule defining the occurrence pattern for the task. The schedule should be set to the "on/off" mode. During the "on" periods, the resource is on downtime.
Type of value: Schedule
Local variable: T unit - the resource unit
Total time between occurrences: [dynamic]
[Visible if the Defined by parameter is set to Triggers] Here you can specify the period of working time (when the resource unit services an agent) and idle time that must pass between the assignments of this task. If the field is left empty, this type of trigger will not be applied.
Type of value: double
Local variable: T unit - the unit
...countdown starts when: [dynamic]
[Visible if the Defined by parameter is set to Triggers] Here you can specify when the countdown for the Total time between occurrences parameter must start: either when the task starts or when the task finishes. If the downtime task has been started by a different trigger, the Total time between occurrences countdown will be restarted after the downtime task finishes.
Type of value: boolean
Working time between occurrences: [dynamic]
[Visible if the Defined by parameter is set to Triggers] Here you can specify the period of working time that must pass between the assignments of this task. Working time includes the time spent by the resource to reach the agent that seized it and the time of service itself. If the field is left empty, this type of trigger will not be applied.
Type of value: double
Local variable: T unit - the unit
Cycles between occurrences: [dynamic]
[Visible if the Defined by parameter is set to Triggers] The number of times this resource must be seized between the assignments of this task. If the resource work was interrupted after it had been seized but then resumed once again, this is counted as two cycles. If the field is left empty, this type of trigger will not be applied.
Type of value: int
Local variable: T unit - the unit
Custom first occurrence [dynamic]
[Visible if the Defined by parameter is set to Triggers] Enables the custom trigger values for the first downtime occurrence. If not enabled, the first downtime will occur when the recurrence period specified for the repeating downtime task runs out.
Type of value: boolean
Local variable: T unit - the unit
Total time to first occurrence: [dynamic]
[Visible if the Custom first occurrence option is selected] Here you can specify the amount of time that must pass from the appearance of the resource unit until this task is first assigned to the resource. It includes both working time (when the resource unit services an agent) and idle time. If the field is left empty, this type of trigger will not be applied.
Type of value: double
Local variable: T unit - the unit
Working time to first occurrence: [dynamic]
[Visible if the Custom first occurrence option is selected] Here you can specify the amount of working time that must pass until this task is first assigned to the resource. Working time includes the time spent by the resource to reach the agent that seized it and the time of service itself. If the field is left empty, this type of trigger will not be applied.
Type of value: double
Local variable: T unit - the unit
Cycles to first occurrence: [dynamic]
[Visible if the Custom first occurrence option is selected] The number of times this resource has been seized until this task is first assigned to the resource. If the resource work was interrupted after it had been seized and then resumed once again, it is counted as two cycles. If the field is left empty, this type of trigger will not be applied.
Type of value: int
Local variable: T unit - the unit
Downtime task
Task type [dynamic]
Here you can choose how you will model the downtime task:
Delay (timeout/schedule) - you can just set the duration of the task as a delay or use a schedule.
Delay (timeout/schedule) with resources - you can set the duration of the task as a delay or use a schedule and define the minimal logic for the resources that will execute this task. If the resources you are using for the downtime task are also used elsewhere, the priority of the downtask task will be 0. If you need to define a more complex logic including the prioritizing of resources, you should define it in a separate flowchart and select Go to flowchart option in this parameter.
Delay until stopTask() is called - the task will continue until its explicit termination by calling the stopTask() function.
Go to flowchart - Alternative to modeling a task just with a delay, you can model it with a flowchart describing the process. The flowchart start should start with the ResourceTaskStart block specified in the Task start block field below.
Valid values: Delay (timeout/schedule) - Downtime.TASK_DELAY
Go to flowchart - Downtime.TASK_FLOWCHART
Delay until stopTask() is called - Downtime.TASK_WAIT_CALLBACK
Task duration [dynamic]
[Visible if the Defined by parameter is set to Triggers and Task type is defined as Delay (timeout/schedule)] The duration of the task.
Value type:double
Default value: triangular(10, 20, 30) seconds
Local variable: T unit - the resource unit
Seize
[Visible if Task type is defined as Delay (timeout/schedule) with resources] Define the seize mode: (Alternative) resource sets or Units of the same pool.
For more details, please, refer here.
Syntax: boolean seizeFromOnePool
Resource sets (alternatives) [dynamic]
[Visible if Seize is set to (Alternative) resource sets] Here 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 units.
For more details, please, refer here.
Local variable: agent - the agent
Resource pool [dynamic]
[Visible if Seize is set to Units of the same pool] ResourcePool block from where the resources are requested.
For more details, please, refer here.
Local variable: agent - the agent
Number of units [dynamic]
[Visible if Seize is set to Units of the same pool] Expression evaluated to obtain the required number of resource units for the agent.
Value type: int
Local variable: agent - the agent
Default value: 1
Send seized resources [dynamic]
If selected (true), the seized resources will be sent to the specified location.
Value type: boolean
Default value: false
Local variables: agent - the agent
Agent unit - the resource unit
Destination is
[Visible if Send seized resources is selected]
Defines where the resources will be sent. The resources can be sent to:
Agent - resources are sent to the current agent location.
Network node - resources are sent to the specified network node.
Attractor
- resources are sent to the specified attractor.
Get value:destinationType
Default value: Agent (Service.DEST_ENTITY)
Valid values: self.DEST_ENTITY
self.DEST_NODE
self.DEST_ATTRACTOR
Node [dynamic]
[Visible if Destination is the Network node] Network node where the seized resources will be sent.
Valid value: Node
Local variables: agent - the agent
Agent unit - the resource unit
Attractor [dynamic]
[Visible if Destination is Attractor] Attractor where the seized resources will be sent.
Valid value: Attractor
Local variables: agent - the agent
Agent unit - the resource unit
After release resources [dynamic]
[Visible if Send seized resources is selected] - Here you can select the behavior of the resources after they are released: they will either Return to home location or Stay where they are.
Type of value: boolean
Local variables: T unit - the resource unit
Task start block [dynamic]
[Visible if Task type is defined as Go to flowchart] - ResourceTaskStart block that starts the flowchart defining the task process.
Local variable: T unit - the resource unit
Usage statistics are [dynamic]
Here you choose whether you consider this task in the collected usage statistics as 'busy' time, 'idle' time, or not take it into account at all.
Default value: Not collected
Priorities
Priority [dynamic]
Sets the priority of the task.
Type of value: double
Local variable:
T unit - the unit
May preempt other tasks [dynamic]
Sets whether this task may preempt the task currently being executed, if any. In other words, 'true' means that unit will "drop its work" when this task is activated. If 'false', then the unit will finish all its tasks with less Priority. Note that 'true' option has exceptions: current unit task may have a "non-interruptable" option No preemption.
Type of value: boolean
Local variable: T unit - the unit
Preemption policy [dynamic]
Specifies the policy for the task preemption:
No preemption - cannot be preempted (unit will be busy with this task until it is finished)
Terminate - may be preempted and will be terminated
Type of value: ResourcePreemptionPolicy
Local variable: T unit - the unit
Actions
On start [code]
Here you can type the code that will be executed when the task starts.
Local variables: unit - the resource unit
ResourceUnitTask task - the task
On finish [code]
Here you can type the code that will be executed when the task finishes.
Local variables: unit - the resource unit
ResourceUnitTask task - the task
On terminate [code]
[Visible if Preemption policy is defined as Terminate] Here you can type the code that will be executed when the task has been terminated because of preemption.
Local variables: unit - the resource unit
ResourceUnitTask task - the task

Functions

void restartTriggers(T unit) - Resets the countdowns of all triggers for the given resource unit and starts waiting for the next triggering events.

void stopTask(T unit)- Finishes the downtime task for the given resource unit and restarts all triggers according to their settings.

boolean isActive(Agent unit) - If the given resource is currently executing the downtime task, returns true. Otherwise, returns false.