Repository navigation
Add a RunConfiguration class for parameter sweeps - #3753
Conversation
|
Make sense I think. The default use-case (for a single sweep) would be creating a single RunConfiguration, and then varying multiple Scenarios within that right? So if I'm doing two experiments (that each answer a different subquestion in my research), I probably have two RunConfigurations, with each a (larger) set of scenario's, that can be either created manually or using some sort of (external library for) sampling? (some use cases with minimal API examples might be useful here) |
Yes
Whether you need separate RunConfigurations will depend on the specifics. It is only needed if how you run the model or how you extract data is different
I did not want to repeat everything here so see #3483 (comment) |
|
If it is helps, the overall API will look roughly like this # generate samples with scipy.qmc or salib
scenarios = MyScenario.from_dataframe(samples, rng=42, replications=10)
run_config = RunConfig(MyModel, until=150)
with ProcessPoolExecutor() as executor:
results = run_scenarios(scenarios, run_config, executor=executor, store=InMemoryStore()) |
|
Looks great to me so far! Eagerly waiting for |
I hope to open a draft PR somewhere this week with |
|
A few nitpicks and a suggestion, I hope they are useful |
Thanks, those are useful and have all been addressed. |
This PR adds a new
RunConfigurationclass. This class encapsulates the logic of instantiating a model, running it for a single scenario, and extracting user specifiable output from the run. This PR is part of the larger project of replacing the batch runner with a more flexible and powerful alternative. For detailed background, see #3483, and specifically #3483 (comment)The
RunConfigurationclass is designed to be subclassable, but it makes some default assumptions and provides keyword arguments to control its basic behavior to cover the most common use cases.model.run_untilwith a user specifiable end timedata_recorderbut this is currently controllable via a keyword argumentRunConfiguration.User subclassing can be done by overriding any of the three methods:
instantiate_model- handles model instantiationrun_model- handles running the modelextract_output- handles the extraction and any post processing the user wants to do.It is likely that parts of this class will be refined in future PRs. Most notably, extract_output is currently a basic implementation which is likely to be expanded when working out the storage solution for parameter sweeps.