Beacons now affect the neighbors of the infected nodes

models
JesusMSM 8 years ago
parent 038d388afd
commit f156e95293

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

18234
data.txt

File diff suppressed because it is too large Load Diff

@ -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.

@ -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()

39038
test.gexf

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save