def run_model(param_updates, n_steps=200, lockdown_at=None): params = setup_params(param_updates) # Create an instance of the Model model = Model(params) m_out = [] for step in trange(n_steps): # Evaluate each step and save the results model.one_time_step() # LOGGER.info( # model.one_time_step_results() # ) # If we want to see the results as we go uncomment this block m_out.append(model.one_time_step_results()) if lockdown_at: if step == lockdown_at: model.update_running_params("lockdown_on", 1) LOGGER.info(f"turning on lock down at step {step}") LOGGER.info( f'lockdown_house_interaction_multiplier = {params.get_param("lockdown_house_interaction_multiplier")}' ) LOGGER.info( f'lockdown_random_network_multiplier = {params.get_param("lockdown_random_network_multiplier")}' ) for oc_net in OccupationNetworkEnum: LOGGER.info( f'lockdown_occupation_multiplier{oc_net.name} = {params.get_param(f"lockdown_occupation_multiplier{oc_net.name}")}' ) df = pd.DataFrame(m_out) model.write_output_files() return df
def test_run_model_read_prama_file_false(self): all_params = pd.read_csv("tests/data/baseline_parameters.csv") p = Parameters( read_param_file=False, input_households="tests/data/baseline_household_demographics.csv", ) for key in all_params: value = all_params[key][0] try: p.set_param(key, float(value)) except TypeError: p.set_param(key, int(value)) m = Model(p) m.one_time_step() assert m.one_time_step_results()["time"] == 1