When we build simulations, we are often interested in simulating the future in order to make predictions that influence decision-making. In most cases, available data are past records or historic data. Thus it is important to effectively use the existing data in building realistic future simulations. One feature in GoldSim that helps with this is the time shifting function of the time series element. With this, you can run a Monte Carlo simulation where each realization takes a new starting point in the historic time series data.
If you want to see a basic example that employs time shifting, open the example that ships with GoldSim:
- Start GoldSim
- Click on the File and select Open Example...
- Browse to General Examples --> TimeSeries
- Select the file called TimeShifting.gsm
Three simple examples are provided in this TimeShifting.gsm example, which illustrate time shifting. If you would like to try building a new model with time shifting, follow the tutorial below.
Time Shifting Tutorial
This tutorial uses the shifting feature of a Time Series to rely on historical river flow data to represent the uncertain future. At the end of this tutorial, you will see how we can randomly and sequentially sample a historic time series to model future scenarios of the river. Follow these steps to complete the tutorial:
- Start a new GoldSim model and save it with a name like Time Shifting Example.gsm
- Change the Simulation settings to a future calendar year with the Time Basis set to Calendar Time.
- Create a new Time Series element and give it a name, description, and units
- Download the Excel file (link at the bottom of the article) and save it in the same directory as the model.
- Copy the data in the excel file to the clipboard
- Paste the date and value column into the time series (click the Edit Data... button). Don't forget to make sure the Time Unit of the data is set to Calendar Time as shown below.
- Click the More button in the Time Series properties.
- Check the checkbox to Enable Time Shifting of Time Series Data. The Shifting Time Series Origin settings dialog appears when you check the box.
- Select the Use random starting point option then choose annual for the Data periodicity. This option randomly samples a starting point in the data set for each realization, which matches the start time of the simulation.
- Click OK then Close to save the Time Series settings for the model.
- Go to the Monte Carlo settings for the model (Run --> Simulation Settings --> Monte Carlo) and set the number of realizations to run at 87, which is the number of years we have in the time series.
- Hook up a Time History Result to the time series output.
- Run the model and view the plot first with the Probabilities Display setting.
- Next, look at individual realizations to compare.
This model selects each historic year by finding a new random simulation year on each realization. If you would prefer to sequentially sample the time series, starting from the earliest year to the end as you iterate over the realizations, then follow the next steps.
Modify the Time Shift to Sample Sequentially
Follow these steps if you want the model to start the first realization on the first year of the historic record, then continue over each subsequent year on each realization of the model.
- Create a new Expression element and name it Shift_Year
- Enter the Expression:
- Since the historic record doesn't start until October, 1923 and our simulation starts in January, we need the first shift year to be year 1924.
- The model run property Realization counts, starting with a value of 1 and increments on each subsequent realization of the model (1-87).
- Link the Shift_Year output in the Time Series Shifting Settings.
- Run the model and view a table view of History 1. You should see that the first column (Realization 1) corresponds to the value recorded on 1/1/1924. You can repeat this check for subsequent years/realizations as well.
There are times when the end of the time series is hit during a simulation and will therefore wrap back around at the start of the time series. Note that the simulation year and the historic year do not always have exactly the same number of days so there can be times when the day of the year doesn't exactly match. For more information about this and ways to prevent a discrepancy, please see this article: Time Series Wrapping Behavior