Skip to content

add_to_schedule

Syntax

If called by the meta agent:

add_to_schedule(place_type, day_string, open_hour, open_minute, close_hour, close_minute)

If called by a group agent:

add_to_schedule(day_string, open_hour, open_minute, close_hour, close_minute)

Parameters

place_type
The type of place for which scheduled open hours are to be added. Required if and only if this action is called by the meta agent.
day_string
The days of the week for which scheduled open hours are to be added. Valid values are: - Everyday - Weekdays - Weekends - Sun - Mon - Tue - Wed - Thu - Fri - Sat
open_hour
The hour for the place to open. This can be in form of a range on a 24 hour clock (0-23), or a 12-hour time string (e.g. 12am, 9pm, etc.).
open_minute
The minute for the place to open (0-59).
close_hour
The final hour of the range for which open hours to be added. This can be in form of a range on a 24 hour clock (0-23), or a 12-hour time string (e.g. 12am, 9pm, etc.)
close_minute
The final minute of the range for which open hours to be added (0-59).

Description

Adds a range of hours for a location to be open for a given place type.

Note that this does not necessarily mean that the place will close at the close time specified by this action's parameters. This action only adds open hours to the schedule.

If a place has a schedule that specifies that it is open after the times specified in close_hour and close_minute, the closing time will not be affected.

Examples

agents.txt

ID
123

main.fred

simulation {
    start_date = 2022-Jan-01
    end_date = 2022-Jan-03
    locations = none
    default_model = none
}

startup {
    read_agent_file("agents.txt")
    add_to_schedule(Work,Everyday,12am,0,3pm,59)
    print("-- Work is open from 0000-1559 --")
}

agent_startup {
    join(Work)
}

place Work {
    site = 555,0,0
}

condition IsOpenChecker {
    start_state = Start

    state Start {
        print("Work is open at ", mod(now, 24), "?: ", is_open(Work))
        wait(8)
        default()
    }
}

condition ScheduleAdjuster {
    meta_start_state = Start

    state Start {
        wait(24)
        default(OpenLater)
    }

    state OpenLater {
        remove_from_schedule(Work, Everyday, 12am, 00, 1am, 30)
        print("-- Work is now open from 0131-1559 --")
        wait(24)
        default(StayOpenTil6pm)
    }

    state StayOpenTil6pm {
        add_to_schedule(Work, Everyday, 12, 0, 18, 0)
        print("-- Work is now open from 0131-1800 --")
        wait()
        default(Excluded)
    }
}

Executing the above results in the following output:

-- Work is open from 0000-1559 --
Work is open at 0?: 1
Work is open at 8?: 1
Work is open at 16?: 0
-- Work is now open from 0131-1559 --
Work is open at 0?: 0
Work is open at 8?: 1
Work is open at 16?: 0
-- Work is now open from 0131-1800 --
Work is open at 0?: 0
Work is open at 8?: 1
Work is open at 16?: 1

See Also