Skip to content

read_schedule_file

Syntax

read_schedule_file("filename")

Parameters

filename
The relative path of the CSV file dictating the schedule to be read, surrounded by quotes.

Description

This action can only be invoked by the meta agent. It reads in a schedule that is stored in a CSV file, and sets the schedule for the associated site.

The CSV File

The CSV file is expected to be in the format:

ID,DAYS,OPEN,CLOSE

The values of the entries for each column are as follows:

ID
The ID of the site
DAYS
The days for which this schedule applies. Valid values are: - Everyday - Weekdays - Weekends - Sun - Mon - Tue - Wed - Thu - Fri - Sat
OPEN
The open time in a 24-hour clock format
CLOSE
The close time in a 24-hour clock format

Examples

schedule.csv

ID,DAYS,OPEN,CLOSE
555,Weekdays,9:00,17:00

agents.txt

ID
123

main.fred

simulation {
    start_date = 2022-May-01
    end_date = 2022-May-07
    locations = none
    default_model = none
}

startup {
    read_agent_file("agents.txt")
}

agent_startup {
    if (id()==123) {
        join(Work)
    }
}

group_startup {
    print("Group id is: ", id())
}

place Work {
    has_group_agent = 1
    site = 555,0,0
}

condition TEST {
    start_state = AgentStart
    group_start_state = Excluded
    meta_start_state = MetaStart

    state AgentStart {
        if (is_at(Work)) {
            print("Day ", day_of_week()," hour ",hour()," agent ",id()," is at workplace ", Work)
        }
        if (not(is_at(Work))) {
            print("Day ", day_of_week()," hour ",hour()," agent ",id()," is not at workplace ", Work)
        }

        wait(1)
        default(AgentStart)
    }

    state MetaStart {
        read_schedule_file("schedule.csv")
        wait(0)
        default(Excluded)
    }
}

See Also