1
0
mirror of https://github.com/gsi-upm/soil synced 2024-11-14 15:32:29 +00:00

Paper model 1

This commit is contained in:
JesusMSM 2016-04-27 13:30:31 +02:00
parent ae01656ac3
commit a321823078
6 changed files with 4667 additions and 65841 deletions

29516
data.txt

File diff suppressed because it is too large Load Diff

View File

@ -57,6 +57,7 @@ class ComportamientoBase(BaseNetworkAgent):
return final return final
class SpreadModelM2(ComportamientoBase): 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} init_states[random.randint(0,settings.number_of_nodes)] = {'id':1}
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=()): def __init__(self, environment=None, agent_id=0, state=()):
@ -125,6 +126,7 @@ class SpreadModelM2(ComportamientoBase):
for neighbor in infected_neighbors: for neighbor in infected_neighbors:
if random.random() < self.prob_cured_healing_infected: if random.random() < self.prob_cured_healing_infected:
neighbor.state['id'] = 2 # Cured neighbor.state['id'] = 2 # Cured
return
# Vaccinate # Vaccinate
neutral_neighbors = self.get_neighboring_agents(state_id=0) neutral_neighbors = self.get_neighboring_agents(state_id=0)
@ -133,9 +135,11 @@ class SpreadModelM2(ComportamientoBase):
neighbor.state['id'] = 3 # Vaccinated neighbor.state['id'] = 3 # Vaccinated
# Generate anti-rumor # Generate anti-rumor
infected_neighbors = self.get_neighboring_agents(state_id=1)
for neighbor in infected_neighbors: for neighbor in infected_neighbors:
if random.random() < self.prob_generate_anti_rumor: if random.random() < self.prob_generate_anti_rumor:
neighbor.state['id'] = 2 # Cured neighbor.state['id'] = 2 # Cured
return
class SISaModel(ComportamientoBase): class SISaModel(ComportamientoBase):

View File

@ -40,7 +40,7 @@ def init():
global prob_generate_anti_rumor global prob_generate_anti_rumor
network_type=1 network_type=1
number_of_nodes=1000 number_of_nodes=100
max_time=500 max_time=500
num_trials=1 num_trials=1
timeout=20 timeout=20
@ -88,16 +88,16 @@ def init():
standard_variance = 0.055 standard_variance = 0.055
#Spread Model M2 #Spread Model M2
prob_neutral_making_denier = 0.055 prob_neutral_making_denier = 0.035
prob_infect = 0.1 prob_infect = 0.075
prob_cured_healing_infected = 0.055 prob_cured_healing_infected = 0.035
prob_cured_vaccinate_neutral = 0.055 prob_cured_vaccinate_neutral = 0.035
prob_vaccinated_healing_infected = 0.055 prob_vaccinated_healing_infected = 0.035
prob_vaccinated_vaccinate_neutral = 0.055 prob_vaccinated_vaccinate_neutral = 0.035
prob_generate_anti_rumor = 0.055 prob_generate_anti_rumor = 0.035

Binary file not shown.

32
soil.py
View File

@ -37,26 +37,48 @@ sim.run_simulation()
# Results # # Results #
########### ###########
x_values = [] x_values = []
y_values = [] infected_values = []
neutral_values = []
cured_values = []
vaccinated_values = []
attribute_plot = 'status' attribute_plot = 'status'
for time in range(0, settings.max_time): for time in range(0, settings.max_time):
value = settings.sentiment_about[0] value_infectados = 0
value_neutral = 0
value_cured = 0
value_vaccinated = 0
real_time = time * settings.timeout real_time = time * settings.timeout
activity= False activity= False
for x in range(0, settings.number_of_nodes): for x in range(0, settings.number_of_nodes):
if attribute_plot in models.networkStatus["agente_%s" % x]: if attribute_plot in models.networkStatus["agente_%s" % x]:
if real_time in models.networkStatus["agente_%s" % x][attribute_plot]: if real_time in models.networkStatus["agente_%s" % x][attribute_plot]:
if models.networkStatus["agente_%s" % x][attribute_plot][real_time] == 1: ##Representar infectados if models.networkStatus["agente_%s" % x][attribute_plot][real_time] == 1: ##Representar infectados
value += 1 value_infectados += 1
activity = True
if models.networkStatus["agente_%s" % x][attribute_plot][real_time] == 0: ##Representar neutrales
value_neutral += 1
activity = True
if models.networkStatus["agente_%s" % x][attribute_plot][real_time] == 2: ##Representar cured
value_cured += 1
activity = True
if models.networkStatus["agente_%s" % x][attribute_plot][real_time] == 3: ##Representar vaccinated
value_vaccinated += 1
activity = True activity = True
if activity: if activity:
x_values.append(real_time) x_values.append(real_time)
y_values.append(value) infected_values.append(value_infectados)
neutral_values.append(value_neutral)
cured_values.append(value_cured)
vaccinated_values.append(value_vaccinated)
activity=False activity=False
plt.plot(x_values,y_values) infected_line = plt.plot(x_values,infected_values,label='Infected')
neutral_line = plt.plot(x_values,neutral_values, label='Neutral')
cured_line = plt.plot(x_values,cured_values, label='Cured')
vaccinated_line = plt.plot(x_values,vaccinated_values, label='Vaccinated')
plt.legend()
plt.show() plt.show()

40940
test.gexf

File diff suppressed because it is too large Load Diff