There are two principle means of loading time series data into a model, depending on whether it is desired to store the data in the model itself, in which case the table(…) function is used, or whether the data are to be read from an external file, in which case a scenario file is appropriate. It is also possible to enter the data directly into an array, which may be convenient if there are only a few rows of data.
Whichever way the data are provided, they are stored in an array. The following procedure is suitable for transforming the array into a time series.
element([time_series], time()+1)
where [time_series] is any array that is being used to store values for the time-series.
This procedure selects one value from the array, in the row corresponding to the current simulation time. Note that in the sub-expression time()+1, the +1 is to account for array indices starting at 1, whilst the simulation begins at time()=0.
The following procedure is used:
This last step is necessary to re-set the model to use the new parameters at zero time. If you do not do this, a warning will be issued. Note that the index can start from zero.
Time series values do not have to be at regular intervals - for example, if you give a variable parameter the time series:
#0: 1 #20: 2 #80: 3
then it will change on reset and at times 20 and 80 but keep its previous value (or respond to slider input) at other times.
If you want your time series values to be used again after a certain period of time, there are two ways to do this. If editing the list directly in the file parameter dialogue, you can end it with, e.g.,
#100: restart
to cause the values to restart from 0 at time 100. This must be at the end of the line.
If you are loading the values from a .csv file, then the load file dialogue will include an entry box labelled "Wraparound at:" into which you can enter a time at which to restart the time series. Doing either of these will cause the time series to repeat indefinitely over the specified period as the model runs.