def test_seis_model(self): g = nx.erdos_renyi_graph(1000, 0.1) model = epd.SEISModel(g) config = mc.Configuration() config.add_model_parameter('beta', 0.5) config.add_model_parameter('lambda', 0.2) config.add_model_parameter('alpha', 0.05) config.add_model_parameter("fraction_infected", 0.1) model.set_initial_status(config) iterations = model.iteration_bunch(10) self.assertEqual(len(iterations), 10) g = g.to_directed() model = epd.SEISModel(g) config = mc.Configuration() config.add_model_parameter('beta', 0.5) config.add_model_parameter('lambda', 0.8) config.add_model_parameter('alpha', 0.5) config.add_model_parameter("fraction_infected", 0.1) model.set_initial_status(config) iterations = model.iteration_bunch(10, node_status=False) self.assertEqual(len(iterations), 10)
def test_seis_model(self): for g in get_graph(True): model = epd.SEISModel(g) config = mc.Configuration() config.add_model_parameter('beta', 0.5) config.add_model_parameter('lambda', 0.2) config.add_model_parameter('alpha', 0.05) config.add_model_parameter("fraction_infected", 0.1) model.set_initial_status(config) iterations = model.iteration_bunch(10) self.assertEqual(len(iterations), 10) for g in get_directed_graph(True): model = epd.SEISModel(g) config = mc.Configuration() config.add_model_parameter('beta', 0.5) config.add_model_parameter('lambda', 0.8) config.add_model_parameter('alpha', 0.5) config.add_model_parameter("fraction_infected", 0.1) model.set_initial_status(config) iterations = model.iteration_bunch(10, node_status=False) self.assertEqual(len(iterations), 10)
############################################################### SIModel = ep.SIModel(g.copy()) SIModel.set_initial_status(get_si_params()) SI_iterations = SIModel.iteration_bunch(num_iterations) SI_trends = SIModel.build_trends(SI_iterations) visualize(SIModel, SI_trends, sub_dir='epidemics') SISModel = ep.SISModel(g.copy()) SISModel.set_initial_status(get_sis_params()) SIS_iterations = SISModel.iteration_bunch(num_iterations) SIS_trends = SISModel.build_trends(SIS_iterations) visualize(SISModel, SIS_trends, sub_dir='epidemics') SEISModel = ep.SEISModel(g.copy()) SEISModel.set_initial_status(get_seis_params()) SEIS_iterations = SEISModel.iteration_bunch(num_iterations) SEIS_trends = SEISModel.build_trends(SEIS_iterations) visualize(SEISModel, SEIS_trends, sub_dir='epidemics') SEIRModel = ep.SEIRModel(g.copy()) SEIRModel.set_initial_status(get_seir_params()) SEIR_iterations = SEIRModel.iteration_bunch(num_iterations) SEIR_trends = SEIRModel.build_trends(SEIR_iterations) visualize(SEIRModel, SEIR_trends, sub_dir='epidemics') ############################################################### voter_model = op.VoterModel(g.copy()) voter_model.set_initial_status(get_voter_params())