1
0
mirror of https://github.com/gsi-upm/soil synced 2024-11-25 04:12:29 +00:00

Probabilities and seed infection

This commit is contained in:
JesusMSM 2016-04-21 12:56:06 +02:00
parent a728ccdb61
commit ae01656ac3
6 changed files with 67135 additions and 2247 deletions

29576
data.txt

File diff suppressed because it is too large Load Diff

View File

@ -57,6 +57,8 @@ class ComportamientoBase(BaseNetworkAgent):
return final
class SpreadModelM2(ComportamientoBase):
init_states[random.randint(0,settings.number_of_nodes)] = {'id':1}
init_states[random.randint(0,settings.number_of_nodes)] = {'id':1}
def __init__(self, environment=None, agent_id=0, state=()):
super().__init__(environment=environment, agent_id=agent_id, state=state)

View File

@ -31,9 +31,16 @@ def init():
global variance_d_c
global variance_c_d
global standard_variance
global prob_neutral_making_denier
global prob_infect
global prob_cured_healing_infected
global prob_cured_vaccinate_neutral
global prob_vaccinated_healing_infected
global prob_vaccinated_vaccinate_neutral
global prob_generate_anti_rumor
network_type=1
number_of_nodes=50
number_of_nodes=1000
max_time=500
num_trials=1
timeout=20
@ -78,5 +85,19 @@ def init():
variance_c_d = 0.003
content_neutral = 0.088
standard_variance = 0.02
standard_variance = 0.055
#Spread Model M2
prob_neutral_making_denier = 0.055
prob_infect = 0.1
prob_cured_healing_infected = 0.055
prob_cured_vaccinate_neutral = 0.055
prob_vaccinated_healing_infected = 0.055
prob_vaccinated_vaccinate_neutral = 0.055
prob_generate_anti_rumor = 0.055

Binary file not shown.

22
soil.py
View File

@ -18,7 +18,7 @@ models.init() # Loads the models and network variables
if settings.network_type == 0:
G = nx.complete_graph(settings.number_of_nodes)
if settings.network_type == 1:
G = nx.barabasi_albert_graph(settings.number_of_nodes,3)
G = nx.barabasi_albert_graph(settings.number_of_nodes,10)
if settings.network_type == 2:
G = nx.margulis_gabber_galil_graph(settings.number_of_nodes, None)
# More types of networks can be added here
@ -27,7 +27,7 @@ if settings.network_type == 2:
# Simulation #
##############
sim = NetworkSimulation(topology=G, states=init_states, agent_type=SISaModel,
sim = NetworkSimulation(topology=G, states=init_states, agent_type=SpreadModelM2,
max_time=settings.max_time, num_trials=settings.num_trials, logging_interval=1.0)
@ -39,19 +39,25 @@ sim.run_simulation()
x_values = []
y_values = []
attribute_plot = 'status'
for time in range(0, settings.max_time):
value = settings.sentiment_about[0]
real_time = time * settings.timeout
activity= False
for x in range(0, settings.number_of_nodes):
if "sentiment_enterprise_BBVA" in models.networkStatus["agente_%s" % x]:
if real_time in models.networkStatus["agente_%s" % x]["sentiment_enterprise_BBVA"]:
value += models.networkStatus["agente_%s" % x]["sentiment_enterprise_BBVA"][real_time]
if attribute_plot in models.networkStatus["agente_%s" % x]:
if real_time in models.networkStatus["agente_%s" % x][attribute_plot]:
if models.networkStatus["agente_%s" % x][attribute_plot][real_time] == 1: ##Representar infectados
value += 1
activity = True
x_values.append(real_time)
y_values.append(value)
if activity:
x_values.append(real_time)
y_values.append(value)
activity=False
plt.plot(x_values,y_values)
#plt.show()
plt.show()
#################

39757
test.gexf

File diff suppressed because it is too large Load Diff