You can import schedule data from an external database.
You can retain the schedule data you have loaded from the database.
Suppose we have to specify a schedule for a shuttle bus arriving to airport terminal.
Your MS Excel table can look like this:
Note that timestamps contain not only time, but also date. Otherwise, after import to AnyLogic database a default date 31-12-1899 will be added to every timestamp.
To load the data for a schedule in the “Moments” mode
- First, you should import your data into the built-in AnyLogic database. The imported data in the database table will look like this:
- Open the schedule properties and adjust the parameters of Data section as shown in the figure below.
- Select the Loaded from database checkbox.
- From the Table drop-down list choose the table of the built-in database that contains bus arrival schedule. In this example it is named shuttle_schedule.
- From the Start column drop-down list choose the table column containing timestamps: time.
- From the Value column drop-down list choose the column containing values: number_of_passengers.
Note that ... column drop-down lists only contain names of columns where data of corresponding type is stored. Start column drop-down list contains names of columns with data of Date type, while Value column drop-down list contains names of columns containing data of the required type (could be integer, double, boolean).
Since in our example the schedule is of integer type, only columns of int type are listed in the Value column list.
Assume we have a daily schedule with two shifts and a lunch break.
Your table in MS Excel can look like this:
Note that timestamps contain not only time, but also date. Otherwise, after import to AnyLogic database a default date 31-12-1899 will be added to every time stamp.
To load the data for a schedule in the “Intervals” mode
- First, you should import your data into the built-in AnyLogic database. The imported data in the built-in database will look like this:
- Open the schedule properties and adjust the parameters of Data section as shown in the figure below.
- Select the Loaded from database checkbox.
- From the Table drop-down list choose the table of the built-in database that contains the shift schedule. In this example the table is named shift_schedule.
- From the Start column drop-down list choose the column that contains the timestamps marking the time interval start: start_of_shift.
- From the End column drop-down list choose the column that contains the timestamps marking the time interval end: end_of_shift.
- From the Value column drop-down list choose the column that contains values: number_of_operators.
Note that ... column drop-down lists only contain names of columns where data of corresponding type is stored. Start column and End column drop-down lists contain names of columns with data of Date type, while Value column drop-down list contains names of columns containing data of the required type (could be integer, double, boolean).
In our example the schedule is of integer type, therefore only columns of int type are listed in the Value column list.
Assume we are simulating airport shuttle service at an airport. There are two shuttle buses operating in two different airport terminals. Each shuttle is defined with an individual ResourcePool.
We have external database with just one table containing schedules for both shuttles. We will show you how to load a specific schedule data from such a table for a particular ResourcePool.
Your table in MS Excel can look like this:
Note that timestamps contain not only time, but also date. Otherwise, after import to AnyLogic database a default date 31-12-1899 will be added to every time stamp.
In this scenario, we only want to use the shuttle schedule for terminal 1, therefore we will fetch entries relevant to the terminal 1 from the table.
To fetch particular values from the DB
- First, you should import your data into the built-in AnyLogic database. The imported data will be displayed like this:
- Load the schedule data.
- Open the schedule’s properties and in the Data section click the Add choice condition button.
- In the Choice conditions group of controls, from the upper drop-down list choose the column that contains the value you will use to filter the data. In this example the column is named terminal.
- Leave the control next to this list set to equals. This control defines how two values relate to each other, and you can see all available options by clicking on it.
- In the combo box below select "terminal 1". We have specified the filter and now only the rows that contain values equal to "terminal 1" will be fetched from the built-in database table. You can type the value you need directly in the combo box. Since in our scenario we deal with entries of String type, we have to follow Java conventions and use quotation marks as shown in the image below.
Assume the model uses data from several external databases imported to the built-in database. Some of these we need to update on model startup which can be done automatically, but we also need the shuttle bus schedule data to remain unchanged.
To make the loaded data autonomous, after loading the schedule data to the AnyLogic database, in the schedule properties clear the Loaded from database checkbox. AnyLogic will offer an option to copy these data to a table.
Click the Yes button. The retained data will be displayed as shown in the image below:
-
How can we improve this article?
-