def test_sc0_base_lockdown(self):
     params = get_default_params()
     params[nindividual_key] = 100
     params[nday_key] = 30
     env_dic = get_environment_simulation(params)
     stats_result = sc0_base_lockdown.launch_run(params, env_dic, display_progress=False)
     self.assertTrue(len(stats_result) > 0)
 def test_sc6_travelers(self):
     params = get_default_params()
     params[nindividual_key] = 100
     params[nday_key] = 30
     params[additional_scenario_params_key] = [5]
     env_dic = get_environment_simulation(params)
     stats_result = sc6_travelers.launch_run(params, env_dic, display_progress=False)
     self.assertTrue(len(stats_result) > 0)
 def test_sc2_yoyo_lockdown_removal(self):
     params = get_default_params()
     params[nindividual_key] = 100
     params[nday_key] = 30
     params[additional_scenario_params_key] = [14, 2, 7]
     env_dic = get_environment_simulation(params)
     stats_result = sc2_yoyo_lockdown_removal.launch_run(params, env_dic, display_progress=False)
     self.assertTrue(len(stats_result) > 0)
 def test_sc0_base_lockdown(self):
     params = get_default_params()
     params[nindividual_key] = 100
     params[nday_key] = 30
     env_dic = get_environment_simulation(params)
     ray_params = ray.put(params)
     ray_env_dic = ray.put(env_dic)
     pb = ProgressBar(params[nday_key])
     actor = pb.actor
     stats_l = [
         sc0_base_lockdown.do_parallel_run.remote(ray_env_dic, ray_params,
                                                  0, 0, actor)
     ]
     self.assertTrue(len(stats_l) > 0)
 def test_sc2_yoyo_lockdown_removal(self):
     params = get_default_params()
     params[nindividual_key] = 100
     params[nday_key] = 30
     params[additional_scenario_params_key] = [14, 2, 7]
     env_dic = get_environment_simulation(params)
     ray_params = ray.put(params)
     ray_env_dic = ray.put(env_dic)
     pb = ProgressBar(params[nday_key])
     actor = pb.actor
     stats_l = [
         sc2_yoyo_lockdown_removal.do_parallel_run.remote(
             ray_env_dic, ray_params, 0, 0, actor)
     ]
     self.assertTrue(len(stats_l) > 0)
 def test_sc5_rogue_neighborhood(self):
     params = get_default_params()
     params[nindividual_key] = 100
     params[nday_key] = 30
     params[additional_scenario_params_key] = [4, 2]
     env_dic = get_environment_simulation(params)
     ray_params = ray.put(params)
     ray_env_dic = ray.put(env_dic)
     pb = ProgressBar(params[nday_key])
     actor = pb.actor
     stats_l = [
         sc5_rogue_neighborhood.do_parallel_run.remote(
             ray_env_dic, ray_params, 0, 0, actor)
     ]
     self.assertTrue(len(stats_l) > 0)
Beispiel #7
0
import joblib
import numpy

from scenario.example import sc1_simple_lockdown_removal, sc2_yoyo_lockdown_removal, sc0_base_lockdown, \
    scx_base_just_a_flu, sc3_loose_lockdown, sc4_rogue_citizen, sc5_rogue_neighborhood, sc6_travelers, \
    sc7_nominal_lockdown_removal, sc8_innoculation, sc9_vaccination, sc10_variant
from scenario.helper.ray import launch_parallel_byday, launch_parallel_byvariant
from simulator.constants.keys import scenario_id_key, random_seed_key, draw_graph_key, ncpu_key, show_plot_key
from simulator.helper.environment import get_environment_simulation_p, get_clean_env_params
from simulator.helper.parser import get_parser
from simulator.helper.plot import chose_draw_plot
from simulator.helper.simulation import get_default_params

if __name__ == '__main__':
    params = get_default_params()

    args = get_parser().parse_args()
    for arg in vars(args):
        v = getattr(args, arg)
        if arg in params and v is not None:
            params[arg] = v
    random.seed(params[random_seed_key])
    numpy.random.seed(params[random_seed_key])

    t_start = time.time()

    params_env, key_env = get_clean_env_params(params)
    env_file = "env_models/env_" + key_env + ".joblib"

    if os.path.exists(env_file):