1
0
mirror of https://github.com/gsi-upm/soil synced 2024-12-22 00:08:12 +00:00

Beacons now affect the neighbors of the infected nodes

This commit is contained in:
JesusMSM 2016-05-04 13:42:38 +02:00
parent 038d388afd
commit f156e95293
6 changed files with 34671 additions and 34661 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

24276
data.txt

File diff suppressed because it is too large Load Diff

View File

@ -156,10 +156,20 @@ class ControlModelM2(ComportamientoBase):
def beacon_on_behaviour(self):
# Cure (M2 feature added)
infected_neighbors = self.get_neighboring_agents(state_id=1)
for neighbor in infected_neighbors:
if random.random() < self.prob_generate_anti_rumor:
neighbor.state['id'] = 2 # Cured
neutral_neighbors_infected = neighbor.get_neighboring_agents(state_id=0)
for neighbor in neutral_neighbors_infected:
if random.random() < self.prob_generate_anti_rumor:
neighbor.state['id'] = 3 # Vaccinated
infected_neighbors_infected = neighbor.get_neighboring_agents(state_id=1)
for neighbor in infected_neighbors_infected:
if random.random() < self.prob_generate_anti_rumor:
neighbor.state['id'] = 2 # Cured
# Vaccinate
neutral_neighbors = self.get_neighboring_agents(state_id=0)

Binary file not shown.

View File

@ -27,7 +27,7 @@ if settings.network_type == 2:
# Simulation #
##############
sim = NetworkSimulation(topology=G, states=init_states, agent_type=SpreadModelM2,
sim = NetworkSimulation(topology=G, states=init_states, agent_type=ControlModelM2,
max_time=settings.max_time, num_trials=settings.num_trials, logging_interval=1.0)
@ -79,7 +79,7 @@ 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.savefig('spread_model.png')
plt.savefig('control_model.png')
#plt.show()

45042
test.gexf

File diff suppressed because it is too large Load Diff