mirror of
https://github.com/gsi-upm/soil
synced 2024-11-22 03:02:28 +00:00
Beacons now affect the neighbors of the infected nodes
This commit is contained in:
parent
038d388afd
commit
f156e95293
Binary file not shown.
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
10
models.py
10
models.py
@ -156,10 +156,20 @@ class ControlModelM2(ComportamientoBase):
|
|||||||
|
|
||||||
def beacon_on_behaviour(self):
|
def beacon_on_behaviour(self):
|
||||||
|
|
||||||
|
# Cure (M2 feature added)
|
||||||
infected_neighbors = self.get_neighboring_agents(state_id=1)
|
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
|
||||||
|
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
|
# Vaccinate
|
||||||
neutral_neighbors = self.get_neighboring_agents(state_id=0)
|
neutral_neighbors = self.get_neighboring_agents(state_id=0)
|
||||||
|
Binary file not shown.
4
soil.py
4
soil.py
@ -27,7 +27,7 @@ if settings.network_type == 2:
|
|||||||
# Simulation #
|
# 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)
|
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')
|
cured_line = plt.plot(x_values,cured_values, label='Cured')
|
||||||
vaccinated_line = plt.plot(x_values,vaccinated_values, label='Vaccinated')
|
vaccinated_line = plt.plot(x_values,vaccinated_values, label='Vaccinated')
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.savefig('spread_model.png')
|
plt.savefig('control_model.png')
|
||||||
#plt.show()
|
#plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user