-
Notifications
You must be signed in to change notification settings - Fork 6
Creating, running and comparing scenarios
last updated: 04 April 2021 by Raphael ([email protected])
Most likely you want to compare different scenarios to evaluate different policies, the impact of infrastructure development or different climate change scenarios.
Here is how to create different scenarios, and rapidly compare them:
We use an example that applies to all data.
-
In "EnergyModule.xlsx", sheet "Hydropower" you see the list of hydropower plants and their parameters.
-
To define different scenarios of Hydropower plants (e.g. different development plans), insert a column to the left – the name given to this column (nhpscenario here) does not matter as long as it is not an existing one (preferably just leave blank).
-
Then you can name your scenarios, here: "base" and "hpdev".
TIP: The colors/lines do not matter, what matters is the position of the name
TIP2: You can also create a scenario that is an update of another scenario by referring to the existing scenario "newscenario*refscenario", here "hpdev*base" then you just need to define the new features or/and the one that changed (entire line must be completed)
-
Then in the "Info" sheet (first sheet of all data .xlsx files), specify that the "Hydropower" sheet has scenarios, by entering a scenario parameter "Scenario" column (here sHydropower). This parameter will then be used to communicate to the model which scenario to use in step 2.
TIP: Several data can have the same scenario parameter (sHydropower here), but then all scenarios need to exist for all these data (base, hpdev here). E.g. if you choose to link Reservoir and Hydropower scenarios, you proceed the same for Reservoirs, also give it the parameter sHydropower, and define a "base" and "hpdev" scenario.
- One exception is the definition of options scenarios. The options are defined in "MainFile.xlsx", sheet "Options". By default "sOptions" is defined as the scenario parameter in the Info sheet – this name is hardcoded and you should not change. For this data only – scenarios are defined by adding columns to the right of the existing one, the name of the scenario is the column header (optionsb here)
Tip: you need to proceed to step 2 before running the model
Now that we defined different scenarios in our data, we want to run those to compare them.
-
In "MainFile.xlsx", sheet "Scenarios" you can define a list of scenario combinations. By default, only "sOptions" and "sRefScen" exist. Now you need to add columns with the scenario parameters you created (e.g. sHydropower).
-
In "nscenario" you define the name of your global scenario (Hydropower_base, Hydropower_dev here), in your scenario parameter sHydropower, you define the specific (Hydropower) scenario data that should be used for that global scenario (hpdev, base here).
TIP: The global scenario name is used to generate output files – hence do not use special characters! (avoid in general)
-
The "WHATIF_main" is the default scenario if you run WHATIF_main.py – you can modify this within the script by changing 'WHATIF_main' by the name of the scenario you would like to run. (e.g. Hydropower_base, Hydropower_dev)
However, most likely, you want to run those scenarios in batch.
-
For this use the script "WHATIF_scenario.py" it will run all scenarios defined in the "Scenario" sheet (MainFile.xlsx) – you do not need to have WHATIF_main defined.
TIP: define all the scenarios of interest in a separate sheet e.g. Scenarios_save, and then paste only those you want to run in Scenarios).
-
In the script, the option PARALLEL_scenario enables you to runs scenarios in parallel (=1), or in series (=0). Parallel computing is only possible if you have several cores – or use a server.
-
By default WHATIF_scenario.py will create in the "Results" folder a folder with .txt and .xlsx files with the individual scenario results, and summary excel file "Scenario_compare.xlsx"
-
An additional feature you might want to use, is to assign a "reference" scenario to your different scenarios. This will show the indicators in the summary results as relative to this reference scenario (in addition to absolute values). To do this add a column "sRefScen" (if not existing), and define the reference scenarios. Here for example the reference scenario of Hydropower_dev is Hydropower_base, hence in the "Scenario_compare.xlsx" you will be able to visualize the relative impact of the new hydropower plants you defined previously.
If you ran scenarios individually or in different batches and want to compare them in a summarized file, follow step 3.
-
By default, when running scenarios (with WHATIF_main.py or WHATIF_scenario.py or WHATIF_scenario_mpc.py) .txt files are created with some selected key indicators for the scenario. These have the name of the global scenario, e.g. Hydropower_dev.txt and Hydropower_base.txt. If you want to compare those efficiently, you can combine the key indicators in a single excel output.
TIP: this is done by default when running scenarios in Batch as seen in step 2
-
To do so, drop all the corresponding .txt files in a same folder (by default script will assume this folder to be in the "Results" folder). Rmk: .xlsx files are not necessary.
-
In the "Scenarios_to_compare.xlsx" (by default located in the main folder) file create a sheet with the different scenarios (column "nscen") and their reference scenarios (column "refscen")."nscen" and "refscen" are hard coded (and at line 2), you can modify the other names.
-
Open WHATIF_scenario_to_xlsx.py and enter the sheetname and foldername to use, here: 'example' and 'exampleMon_18_05_2020_23h17'
-
Run the script. It should have created a file SCENARIO_compare.xlsx in this folder. If you want a method to compare scenarios in depth, look at Using-WHATIF_visualize