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

Adaptando para un mayor numero de empresas

This commit is contained in:
JesusMSM 2016-01-22 13:07:01 +01:00
parent 75b4186332
commit 745b68776f
2 changed files with 18418 additions and 17704 deletions

22
soil.py
View File

@ -52,22 +52,19 @@ init_states = [{'id': 0, } for _ in range(settings.number_of_nodes)] # add keys
#################### ####################
class BigMarketModel(BaseNetworkAgent): class BigMarketModel(BaseNetworkAgent):
number_of_enterprises = 0
def __init__(self, environment=None, agent_id=0, state=()): def __init__(self, environment=None, agent_id=0, state=()):
super().__init__(environment=environment, agent_id=agent_id, state=state) super().__init__(environment=environment, agent_id=agent_id, state=state)
self.time_awareness = 0 self.time_awareness = 0
self.type = "" self.type = ""
number_of_enterprises = len(settings.tweet_probability_about)
if self.id == 0: #Empresa 1 if self.id < number_of_enterprises: #Empresas
self.state['id']=0 self.state['id']=self.id
self.type="Enterprise" self.type="Enterprise"
self.tweet_probability = settings.tweet_probability_enterprises[0] self.tweet_probability = settings.tweet_probability_enterprises[self.id]
elif self.id == 1: #Empresa 2
self.state['id']=1
self.type="Enterprise"
self.tweet_probability = settings.tweet_probability_enterprises[1]
else: #Usuarios normales else: #Usuarios normales
self.state['id']=2 self.state['id']=number_of_enterprises
self.type="User" self.type="User"
self.tweet_probability = settings.tweet_probability_users self.tweet_probability = settings.tweet_probability_users
self.tweet_relevant_probability = settings.tweet_relevant_probability self.tweet_relevant_probability = settings.tweet_relevant_probability
@ -79,7 +76,7 @@ class BigMarketModel(BaseNetworkAgent):
def run(self): def run(self):
while True: while True:
if(self.id < 2): # Empresa if(self.id < number_of_enterprises): # Empresa
self.enterpriseBehaviour() self.enterpriseBehaviour()
else: # Usuario else: # Usuario
self.userBehaviour() self.userBehaviour()
@ -91,7 +88,7 @@ class BigMarketModel(BaseNetworkAgent):
def enterpriseBehaviour(self): def enterpriseBehaviour(self):
if random.random()< self.tweet_probability: #Twittea if random.random()< self.tweet_probability: #Twittea
aware_neighbors = self.get_neighboring_agents(state_id=2) #Nodos vecinos usuarios aware_neighbors = self.get_neighboring_agents(state_id=number_of_enterprises) #Nodos vecinos usuarios
for x in aware_neighbors: for x in aware_neighbors:
if random.uniform(0,10) < 5: if random.uniform(0,10) < 5:
x.sentiment_about[self.id] += 0.1 #Aumenta para empresa x.sentiment_about[self.id] += 0.1 #Aumenta para empresa
@ -104,7 +101,10 @@ class BigMarketModel(BaseNetworkAgent):
if x.sentiment_about[self.id] < -1: if x.sentiment_about[self.id] < -1:
x.sentiment_about[self.id] = -1 x.sentiment_about[self.id] = -1
#Visualización #Visualización
#if self.id < number_of_enterprises:
if self.id == 0: if self.id == 0:
enterprise1Status[x.id][self.env.now]=x.sentiment_about[self.id] enterprise1Status[x.id][self.env.now]=x.sentiment_about[self.id]
if self.id == 1: if self.id == 1:

36100
test.gexf

File diff suppressed because it is too large Load Diff