Schedule

AnyLogic provides users with a Schedule - a special element allowing to define how some value changes in time according to the defined (optionally cyclic) pattern. 

Schedule is frequently used to define:

Moreover, you can use schedule in none AnyLogic objects but work with it programmatically, obtaining its value using the corresponding API.

The following demo model illustrates how Source generates agents according to the daily rate pattern defined by rate schedule:

Demo model: Source Arrival Modes


Schedule modes

Schedule works in one of two modes: it can either define intervals, or discrete time moments.

The first mode (intervals) is used when you need to define how some value continuously changes in time (usually according to some cyclic pattern). In the present case at any moment of time there is current value defined by the schedule. Intervals are used to define work timetables for worker shifts, cyclic pattern of pedestrian/agent arrival rate, etc.

The second mode (moments) is used when you need to define a sequence of key time moments and some values corresponding to this particular moments (or perform some actions, see the abstract below). The example - train arrival schedule: the specified number of pedestrians appears in the railway station model at the defined arrival moments. 

Moreover, you can associate actions with key moments of the schedule (either interval switch times, or time moments - it depends on the schedule mode), by typing Java code in the Action section of the schedule properties. Actions are executed in those key moments, so that you can use schedule as a perfect tool for scheduling an unlimited number of actions in the future (probably, mapped to the particular calendar dates).


Types of value defined by a schedule

Schedule can control values of the following types:

Views

You can define a schedule in one of three alternative views:


Schedule exceptions

Schedules defined in the calendar views (Week and Days/Weeks) may have exceptions - particular time intervals when the value defined by this schedule should have other values, differing from the ones specified in the schedule.

The most frequent use cases of exceptions are national holidays and workday transfers caused by the holidays. Exceptions can be also used for modeling less trivial tasks like the demand boost in the New Year's and Christmas Eve, or extension of the shop staff in those days.


Defining a schedule

In general, you define schedule similarly in all views: first, you select the type of the value that you want to control with this schedule (on/offinteger or real), and then define time intervals (or just time moments, it depends on the schedule mode) and specify values for each particular interval/moment. When defined the complete cycle of intervals/moments, you tell the schedule what is the recurrence time for this cycle. 

But since the schedule definition varies a bit depending on the currently used view, we decided to consider several examples of schedule definitions:

 Defining a weekly bank office timetable

 Defining a shift schedule in the (duration = 4 days, Duration type: Days/Weeks)

 Defining a device maintenance schedule (Duration type: Custom, no calendar mapping)


Schedule properties

General

Name – The name of the schedule. The name is used to access the schedule from object properties and from code.

Show name – If selected, the name of the schedule is displayed on the presentation diagram.

Ignore – If selected, the schedule is excluded from the model.

Visible – If selected, the schedule icon is visible on a presentation at runtime.

Data

Type – Type of the value defined by this schedule: on/off (the schedule defines the resource availability for ResourcePool), integerreal, or Rate (the schedule defines  time pattern of agent / pedestrian arrival rate for Source / PedSource). 

Unit – [Visible and applies when the schedule's Type is set to Rate] Here you define the units for the rate values defined in the schedule's table. The options are: per second, per minute, per hour, per day, etc.

The schedule defines – Here you can choose the schedule mode: whether it defines Intervals (Start, End), or discrete Time moments.

Intervals (Start, End) mode is used when you need to define how some value continuously changes in time (usually according to some cyclic pattern). In the present case at any moment of time there is current value defined by the schedule. Intervals are used to define work timetables for worker shifts, cyclic pattern of pedestrian/agent arrival rate, etc.
Moments is used when you need to define a sequence of key time moments and some values corresponding to this particular moments (or perform some actions). 

Duration type – Here you choose the duration type of the schedule. Depending on this choice, the schedule is defined in one of three alternative views:

Week - Choose this option in case your schedule has weekly recurrence, e.g. if you need to define a weekly schedule for employees. 
Days/Weeks - Choose this option if you need to define a schedule as a sequence of calendar dates and times, but it has nonweekly recurrence (some number of days or weeks). For instance, it is convenient for defining shift schedules, e.g. every third day (24 hours on, 48 hours off) - such schedule has 3-day recurrence.  
Custom (no calendar mapping) - There is no mapping to calendar dates in this view. Schedule intervals/moments are defined simply as number of time units (milliseconds, seconds, minutes, hours, days, or weeks) passed from the model start. This view is convenient e.g. for defining maintenance intervention times, failures, etc. for various devices. Define schedule in this view when only interval durations are important, not the exact calendar times.

Default value – [Visible if The schedule defines option is not set to Moments] Here you define the default value for the schedule - the value that will be used for the intervals not defined in the schedule.

Repeat schedule weekly – [Visible if Duration type is set to Week] Here you need to define the weekly schedule for employees, which week days are working and which are not, when the shift starts and ends. Select on / off vor Value for each weekly schedule variant. 

Repeat every – [Visible if the Duration type is set to Days/Weeks, or Custom (no calendar mapping)] Here you define the recurrence of the schedule.

Snap to – [Visible if the Duration type is set to Days/Weeks or Custom (no calendar mapping)] If you want your schedule to be applied not from its start moment on model launch, here you can define, what model time corresponds to the start moment of the schedule. Please note that this setting does not define the time when the schedule starts applying - it defines how the start of the schedule is shifted regarding the zero model time. 

Week starts from - [Visible if Repeat every is set to Weeks] The first day of the week in some countries (e.g. USA) is Sunday, while in some other (e.g. Russia) - Monday. Therefore if you will define a schedule with N-weekly recurrence considering that the first day of the week is Sunday and then send the model to the user from some other country, where the week starts from Monday, the schedule will be misinterpreted. So if you expect that your model will be used in other countries too, please define explicitly the first day of the week in your schedule so that this schedule will be locale-independent. And please do it before defining the schedule intervals, because all interval data in the table are deleted when you change the Weeks start from setting.

Loaded from database – [Visible if the Duration type is set to Days/Weeks, or Custom (no calendar mapping)] If checked, allows to load data from the existing AnyLogic database defined by the user.

Table - here you can specify the existing AnyLogic database. 
Choice conditions - here you define a condition that specifies the particular value to be selected from the specified table column. You can add , duplicate , delete and arrange the conditions ( , ).
Start column - here you define the start column of the database.
End сolumn - here you define the end column of the database.
Value column - here you define the value column of the database.

Action

Here you can type Java code to be executed in key moments of the schedule (either interval switch times, or time moments - it depends on the schedule mode). Actions are executed in those key moments, so that you can use schedule as a perfect tool for scheduling an unlimited number of actions in the future (probably, mapped to the particular calendar dates).

Exceptions

On this page you can define exceptions for the schedule - particular time intervals when the value defined by this schedule should have other values, differing from the ones specified in the schedule.

Preview

Here you can preview the schedule in the convenient way that is commonly used in digital diaries, organizers and office software tools. This may help you to check whether the schedule was defined correctly and the resulting picture is the one you have expected to see.

Advanced

System dynamics units – If selected, you will be able to specify units of measurements for the value returned by this schedule in the edit box to the right. Having specified units for elements of your model, you may perform unit checking to find out dimension inconsistencies in the model. 


Daylight Saving Time

In some countries Daylight Saving Time (DST) is practiced: time is temporarily adjusted to achieve longer evening daylight by setting the clocks an hour ahead of the standard time (you can find more information on DST in wikipedia). 

AnyLogic schedules consider DST automatically. The information about DST dates in the current country is taken from the computer's OS settings (the Current locale is taken into account). 


See also

 Weekly schedule

Schedule with N Days/Weeks duration

Schedule with no calendar mapping

 Schedule exceptions

 Schedule API

 Schedule preview