-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modifying the workflow to enable the use of different methods (LHS, Sobol) allowing for scenario discovery applications #13
base: envs
Are you sure you want to change the base?
Conversation
…very applicaiton - e.g. LHS or Sobol
…ods for scenario discovery applications - depending on the method selected, the folder structure will be generated according to the number of scenarios generated
…iles depending on the sampling method of interest, to allow for scenario discovery applications
…thods - i.e. LHS, Sobol respectively. Need for testing if they are defined correctly
…S and Sobol methods
…erent sample methods
… keep consistency with generic naming
…fferent methods than Morris
…uns/0 folder does not get created and the sample.txt file cannot be saved
…consistency with other methods options
…o allow for switching between different sampling methods
Thanks to support from @HauHe, @willu47, and @camiloramirezgo, we seem to have now managed to fix the bugs I was encountering and the workflow should now be able to use different sampling methods (Morris, LHS, Sobol) to execute the workflow and produce results. This should allow for the use of the esom_gsa workflow also in scenario discovery analysis. Still pending: after having computed all scenarios and generated the results, the workflow proceed to compute some sensitivity analysis and fails to do so when LHS or Sobol are selected as methods. |
…ncertain parameters under analysis
…llow for using the user-specific choice of starting year of interpolation, as indicated in the config file under start_year
…ar of interpolation and pass it on to the create_modelrun.py script
… files to allow for using the user-specific choice of starting year of interpolation, as indicated in the config file under start_year this is now working also for parameters with no interpolation_index
I have now added also the option to specific a start_year for the interpolation, to allow for changing the start interpolation year to a year in the middle of the modelling period. This is of use for GLUCOSE SD application, but might be also useful for other cases. |
…g in also the MODE_OF_OPERATION and add it to typed_index
…ses with no interpolation_index
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest combining the create_sample_*.py
scripts into one, with one function per method, and then pass in the method, otherwise there is a fair amount of duplicate code and three files instead of one.
I found a few issues
- one with
len(PARAMETERS)
not working (wrong number of modelruns created when using Sobol) - suggest using
2**replicates
rather thanreplicates**2
, as only the first is guaranteed to be a power of 2 - non integer type of
start_year
was causing problems in thecreate_modelrun.py
script
config/config.yaml
Outdated
@@ -2,25 +2,32 @@ | |||
|
|||
# Populate the scenarios.csv file with a list of scenario names | |||
# and path (description optional) to the model csv data | |||
scenarios: config/scenarios.csv | |||
scenarios: resources/glucose/scenarios_glucose.csv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't modify this e.g. revert to config/scenarios.csv
|
||
# Tell the workflow which model results to plot | ||
results: config/results.csv | ||
results: resources/glucose/results.csv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert to config/results.csv
config/config.yaml
Outdated
|
||
# Filetype options: 'csv' or 'parquet' or 'feather' | ||
filetype: csv | ||
|
||
# Define the uncertain parameters used to define the Monte Carlo sample | ||
parameters: config/parameters.csv | ||
parameters: resources/glucose/parameters_glucose.csv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert to config/parameters.csv
|
||
# Path to the OSeMOSYS model file | ||
model_file: resources/osemosys_fast.txt | ||
model_file: resources/glucose/osemosys_fast.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert to resources/osemosys_fast.txt
workflow/Snakefile
Outdated
elif METHOD == 'LHS': | ||
MODELRUNS = range(config['replicates']) | ||
elif METHOD == 'Sobol': | ||
MODELRUNS = range((config['replicates']**2) * (len(PARAMETERS) + 2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len(PARAMETERS)
is always 1, you need:
PARAMETERS = pd.read_csv(config['parameters'])['name'].to_numpy()
and
MODELRUNS = range((2 ** REPLICATES) * (PARAMETERS.shape[0] + 2))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed partially, I did not see the reason for using PARAMETERS.shape[0] as the PARAMETERS have just one dimension. I also kept the PARAMETERS definition linked to the 'indexes', is there any specific reason why I should switch to the 'name'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the fastest way would be PARAMETERS = len(pd.read_csv(config['parameters']))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other issue is that this ignores grouping of parameters...
…in the parameters.csv file
… in the config file
…tainty parameters for variables with no yearly values
Hi @willu47, I have now started trying to modify the workflow to enable the option to choose between different methods for generating the model runs, so that I can opt for LHS or Sobol in case I am interested in doing Scenario Discovery.
I am sure there is plenty of mistakes, but I have tried to use the following approach:
Would be great to look into it together at our next meeting.