Skip to content

Commit

Permalink
got abc working with multiple parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
nickmalleson committed Nov 19, 2020
1 parent 7d07ef9 commit 52e5f33
Show file tree
Hide file tree
Showing 2 changed files with 272 additions and 21 deletions.
13 changes: 9 additions & 4 deletions experiments/opencl_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,17 +338,22 @@ def run_model_with_params(cls, input_params: List, return_full_details=False):
return fitness

@classmethod
def run_model_with_params0(cls, input_params_dict: dict):
def run_model_with_params_abc(cls, input_params_dict: dict):
"""TEMP to work with ABC. Parameters are passed in as a dictionary"""
if not cls.initialised:
raise Exception("The OpenCLRunner class needs to be initialised first. "
"Call the OpenCLRunner.init() function")

presymptomatic = input_params_dict["presymp"]
# Check that all input parametrers are not negative
for k, v in input_params_dict:
if v < 0:
raise Exception(f"The parameter {k}={v} < 0. "
f"All parameters: {input_params_dict}")

# Splat the input_params_dict to automatically set any parameters that have been inlcluded
params = OpenCLRunner.create_parameters(
parameters_file=cls.PARAMETERS_FILE,
presymptomatic=presymptomatic,
**input_params_dict
)

results = OpenCLRunner.run_opencl_model_multi(
Expand All @@ -360,7 +365,7 @@ def run_model_with_params0(cls, input_params_dict: dict):
summaries = [x[0] for x in results]
# Return the expexted counts in a dictionary
results = OpenCLRunner.get_cumulative_new_infections(summaries)
print(f"Ran Model. Presymp: {presymptomatic} ("
print(f"Ran Model. {str(input_params_dict)} ("
f"{[round(params.individual_hazard_multipliers[i],3) for i in [0,1,2] ]}) "
f"Sum result: {sum(results)}")
return {"data": results}
Loading

0 comments on commit 52e5f33

Please sign in to comment.