def test_qvoter_model(self): g = nx.complete_graph(100) model = opn.QVoterModel(g) config = mc.Configuration() config.add_model_parameter("q", 5) config.add_model_parameter("percentage_infected", 0.6) model.set_initial_status(config) iterations = model.iteration_bunch(10) self.assertEqual(len(iterations), 10) iterations = model.iteration_bunch(10, node_status=False) self.assertEqual(len(iterations), 10)
def test_qvoter_model(self): for g in get_graph(): model = opn.QVoterModel(g) config = mc.Configuration() config.add_model_parameter("q", 5) config.add_model_parameter("fraction_infected", 0.6) model.set_initial_status(config) iterations = model.iteration_bunch(10) self.assertEqual(len(iterations), 10) iterations = model.iteration_bunch(10, node_status=False) self.assertEqual(len(iterations), 10)
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()) voter_iterations = voter_model.iteration_bunch(num_iterations) voter_trends = voter_model.build_trends(voter_iterations) visualize(voter_model, voter_trends, sub_dir='opinions') QVoter_model = op.QVoterModel(g.copy()) QVoter_model.set_initial_status(get_qvoter_params()) QVoter_iterations = QVoter_model.iteration_bunch(num_iterations) QVoter_trends = QVoter_model.build_trends(QVoter_iterations) visualize(QVoter_model, QVoter_trends, sub_dir='opinions') majority_rule_model = op.MajorityRuleModel(g.copy()) majority_rule_model.set_initial_status(get_majority_rules_params()) majority_rule_iterations = majority_rule_model.iteration_bunch( num_iterations) majority_rule_trends = majority_rule_model.build_trends( majority_rule_iterations) visualize(majority_rule_model, majority_rule_trends, sub_dir='opinions') sznajd_model = op.SznajdModel(g.copy()) sznajd_model.set_initial_status(get_sznajd_params())