1
0
mirror of https://github.com/gsi-upm/soil synced 2024-11-13 06:52:28 +00:00

Fixed bug (nodes could change state twice in a step)

This commit is contained in:
JesusMSM 2016-04-28 13:17:44 +02:00
parent a321823078
commit 4c71949d44
5 changed files with 2061 additions and 6502 deletions

3764
data.txt

File diff suppressed because it is too large Load Diff

View File

@ -59,7 +59,6 @@ class ComportamientoBase(BaseNetworkAgent):
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}
def __init__(self, environment=None, agent_id=0, state=()):
super().__init__(environment=environment, agent_id=agent_id, state=state)
@ -78,11 +77,11 @@ class SpreadModelM2(ComportamientoBase):
if self.state['id'] == 0: #Neutral
self.neutral_behaviour()
if self.state['id'] == 1: #Infected
elif self.state['id'] == 1: #Infected
self.infected_behaviour()
if self.state['id'] == 2: #Cured
elif self.state['id'] == 2: #Cured
self.cured_behaviour()
if self.state['id'] == 3: #Vaccinated
elif self.state['id'] == 3: #Vaccinated
self.vaccinated_behaviour()
self.attrs['status'] = self.state['id']
@ -119,6 +118,7 @@ class SpreadModelM2(ComportamientoBase):
if random.random() < self.prob_cured_healing_infected:
neighbor.state['id'] = 2 # Cured
def vaccinated_behaviour(self):
# Cure
@ -126,7 +126,7 @@ class SpreadModelM2(ComportamientoBase):
for neighbor in infected_neighbors:
if random.random() < self.prob_cured_healing_infected:
neighbor.state['id'] = 2 # Cured
return
# Vaccinate
neutral_neighbors = self.get_neighboring_agents(state_id=0)
@ -135,11 +135,10 @@ class SpreadModelM2(ComportamientoBase):
neighbor.state['id'] = 3 # Vaccinated
# Generate anti-rumor
infected_neighbors = self.get_neighboring_agents(state_id=1)
for neighbor in infected_neighbors:
infected_neighbors_2 = self.get_neighboring_agents(state_id=1)
for neighbor in infected_neighbors_2:
if random.random() < self.prob_generate_anti_rumor:
neighbor.state['id'] = 2 # Cured
return
class SISaModel(ComportamientoBase):

View File

@ -40,10 +40,10 @@ def init():
global prob_generate_anti_rumor
network_type=1
number_of_nodes=100
max_time=500
number_of_nodes=20
max_time=50
num_trials=1
timeout=20
timeout=1
#Zombie model
bite_prob=0.01 # 0-1

Binary file not shown.

4778
test.gexf

File diff suppressed because it is too large Load Diff