mirror of
https://github.com/gsi-upm/soil
synced 2024-11-22 11:12:29 +00:00
Settings modules
This commit is contained in:
parent
dd4ce15a3d
commit
f29f5fa5bf
@ -2,8 +2,6 @@ import settings
|
|||||||
from nxsim import BaseNetworkAgent
|
from nxsim import BaseNetworkAgent
|
||||||
from .. import networkStatus
|
from .. import networkStatus
|
||||||
|
|
||||||
settings.init()
|
|
||||||
|
|
||||||
|
|
||||||
class BaseBehaviour(BaseNetworkAgent):
|
class BaseBehaviour(BaseNetworkAgent):
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
import settings
|
|
||||||
import random
|
import random
|
||||||
from ..BaseBehaviour import *
|
from ..BaseBehaviour import *
|
||||||
from .. import sentimentCorrelationNodeArray
|
from .. import sentimentCorrelationNodeArray
|
||||||
|
|
||||||
settings.init()
|
|
||||||
|
|
||||||
|
|
||||||
class BassModel(BaseBehaviour):
|
class BassModel(BaseBehaviour):
|
||||||
"""
|
"""
|
||||||
@ -16,8 +13,8 @@ class BassModel(BaseBehaviour):
|
|||||||
|
|
||||||
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.innovation_prob = settings.innovation_prob
|
self.innovation_prob = environment.innovation_prob
|
||||||
self.imitation_prob = settings.imitation_prob
|
self.imitation_prob = environment.imitation_prob
|
||||||
sentimentCorrelationNodeArray[self.id][self.env.now] = 0
|
sentimentCorrelationNodeArray[self.id][self.env.now] = 0
|
||||||
|
|
||||||
def step(self, now):
|
def step(self, now):
|
||||||
@ -26,7 +23,7 @@ class BassModel(BaseBehaviour):
|
|||||||
|
|
||||||
def behaviour(self):
|
def behaviour(self):
|
||||||
# Outside effects
|
# Outside effects
|
||||||
if random.random() < settings.innovation_prob:
|
if random.random() < self.innovation_prob:
|
||||||
if self.state['id'] == 0:
|
if self.state['id'] == 0:
|
||||||
self.state['id'] = 1
|
self.state['id'] = 1
|
||||||
sentimentCorrelationNodeArray[self.id][self.env.now] = 1
|
sentimentCorrelationNodeArray[self.id][self.env.now] = 1
|
||||||
@ -40,7 +37,7 @@ class BassModel(BaseBehaviour):
|
|||||||
if self.state['id'] == 0:
|
if self.state['id'] == 0:
|
||||||
aware_neighbors = self.get_neighboring_agents(state_id=1)
|
aware_neighbors = self.get_neighboring_agents(state_id=1)
|
||||||
num_neighbors_aware = len(aware_neighbors)
|
num_neighbors_aware = len(aware_neighbors)
|
||||||
if random.random() < (settings.imitation_prob*num_neighbors_aware):
|
if random.random() < (self.imitation_prob*num_neighbors_aware):
|
||||||
self.state['id'] = 1
|
self.state['id'] = 1
|
||||||
sentimentCorrelationNodeArray[self.id][self.env.now] = 1
|
sentimentCorrelationNodeArray[self.id][self.env.now] = 1
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
import settings
|
|
||||||
import random
|
import random
|
||||||
from ..BaseBehaviour import *
|
from ..BaseBehaviour import *
|
||||||
|
|
||||||
settings.init()
|
|
||||||
|
|
||||||
|
|
||||||
class BigMarketModel(BaseBehaviour):
|
class BigMarketModel(BaseBehaviour):
|
||||||
"""
|
"""
|
||||||
@ -22,28 +19,27 @@ class BigMarketModel(BaseBehaviour):
|
|||||||
sentiment_about [Array]
|
sentiment_about [Array]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
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.enterprises = settings.enterprises
|
self.enterprises = environment.enterprises
|
||||||
self.type = ""
|
self.type = ""
|
||||||
self.number_of_enterprises = len(settings.enterprises)
|
self.number_of_enterprises = len(environment.enterprises)
|
||||||
|
|
||||||
if self.id < self.number_of_enterprises: # Enterprises
|
if self.id < self.number_of_enterprises: # Enterprises
|
||||||
self.state['id']=self.id
|
self.state['id']=self.id
|
||||||
self.type="Enterprise"
|
self.type="Enterprise"
|
||||||
self.tweet_probability = settings.tweet_probability_enterprises[self.id]
|
self.tweet_probability = environment.tweet_probability_enterprises[self.id]
|
||||||
else: # normal users
|
else: # normal users
|
||||||
self.state['id']=self.number_of_enterprises
|
self.state['id']=self.number_of_enterprises
|
||||||
self.type="User"
|
self.type="User"
|
||||||
self.tweet_probability = settings.tweet_probability_users
|
self.tweet_probability = environment.tweet_probability_users
|
||||||
self.tweet_relevant_probability = settings.tweet_relevant_probability
|
self.tweet_relevant_probability = environment.tweet_relevant_probability
|
||||||
self.tweet_probability_about = settings.tweet_probability_about # List
|
self.tweet_probability_about = environment.tweet_probability_about # List
|
||||||
self.sentiment_about = settings.sentiment_about # List
|
self.sentiment_about = environment.sentiment_about # List
|
||||||
|
|
||||||
def step(self, now):
|
def step(self, now):
|
||||||
|
|
||||||
if(self.id < self.number_of_enterprises): # Enterprise
|
if self.id < self.number_of_enterprises: # Enterprise
|
||||||
self.enterpriseBehaviour()
|
self.enterpriseBehaviour()
|
||||||
else: # Usuario
|
else: # Usuario
|
||||||
self.userBehaviour()
|
self.userBehaviour()
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
import settings
|
|
||||||
import random
|
import random
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from ..BaseBehaviour import *
|
from ..BaseBehaviour import *
|
||||||
|
|
||||||
settings.init()
|
|
||||||
|
|
||||||
|
|
||||||
class SISaModel(BaseBehaviour):
|
class SISaModel(BaseBehaviour):
|
||||||
"""
|
"""
|
||||||
@ -35,19 +32,20 @@ class SISaModel(BaseBehaviour):
|
|||||||
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.neutral_discontent_spon_prob = np.random.normal(settings.neutral_discontent_spon_prob,
|
self.neutral_discontent_spon_prob = np.random.normal(environment.neutral_discontent_spon_prob,
|
||||||
settings.standard_variance)
|
environment.standard_variance)
|
||||||
self.neutral_discontent_infected_prob = np.random.normal(settings.neutral_discontent_infected_prob,
|
self.neutral_discontent_infected_prob = np.random.normal(environment.neutral_discontent_infected_prob,
|
||||||
settings.standard_variance)
|
environment.standard_variance)
|
||||||
self.neutral_content_spon_prob = np.random.normal(settings.neutral_content_spon_prob, settings.standard_variance)
|
self.neutral_content_spon_prob = np.random.normal(environment.neutral_content_spon_prob,
|
||||||
self.neutral_content_infected_prob = np.random.normal(settings.neutral_content_infected_prob,
|
environment.standard_variance)
|
||||||
settings.standard_variance)
|
self.neutral_content_infected_prob = np.random.normal(environment.neutral_content_infected_prob,
|
||||||
|
environment.standard_variance)
|
||||||
|
|
||||||
self.discontent_neutral = np.random.normal(settings.discontent_neutral, settings.standard_variance)
|
self.discontent_neutral = np.random.normal(environment.discontent_neutral, environment.standard_variance)
|
||||||
self.discontent_content = np.random.normal(settings.discontent_content, settings.variance_d_c)
|
self.discontent_content = np.random.normal(environment.discontent_content, environment.variance_d_c)
|
||||||
|
|
||||||
self.content_discontent = np.random.normal(settings.content_discontent, settings.variance_c_d)
|
self.content_discontent = np.random.normal(environment.content_discontent, environment.variance_c_d)
|
||||||
self.content_neutral = np.random.normal(settings.content_neutral, settings.standard_variance)
|
self.content_neutral = np.random.normal(environment.content_neutral, environment.standard_variance)
|
||||||
|
|
||||||
def step(self, now):
|
def step(self, now):
|
||||||
if self.state['id'] == 0:
|
if self.state['id'] == 0:
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
import settings
|
|
||||||
import random
|
import random
|
||||||
from ..BaseBehaviour import *
|
from ..BaseBehaviour import *
|
||||||
from .. import sentimentCorrelationNodeArray
|
from .. import sentimentCorrelationNodeArray
|
||||||
|
|
||||||
settings.init()
|
|
||||||
|
|
||||||
|
|
||||||
class IndependentCascadeModel(BaseBehaviour):
|
class IndependentCascadeModel(BaseBehaviour):
|
||||||
"""
|
"""
|
||||||
@ -16,8 +13,8 @@ class IndependentCascadeModel(BaseBehaviour):
|
|||||||
|
|
||||||
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.innovation_prob = settings.innovation_prob
|
self.innovation_prob = environment.innovation_prob
|
||||||
self.imitation_prob = settings.imitation_prob
|
self.imitation_prob = environment.imitation_prob
|
||||||
self.time_awareness = 0
|
self.time_awareness = 0
|
||||||
sentimentCorrelationNodeArray[self.id][self.env.now] = 0
|
sentimentCorrelationNodeArray[self.id][self.env.now] = 0
|
||||||
|
|
||||||
@ -28,7 +25,7 @@ class IndependentCascadeModel(BaseBehaviour):
|
|||||||
def behaviour(self):
|
def behaviour(self):
|
||||||
aware_neighbors_1_time_step = []
|
aware_neighbors_1_time_step = []
|
||||||
# Outside effects
|
# Outside effects
|
||||||
if random.random() < settings.innovation_prob:
|
if random.random() < self.innovation_prob:
|
||||||
if self.state['id'] == 0:
|
if self.state['id'] == 0:
|
||||||
self.state['id'] = 1
|
self.state['id'] = 1
|
||||||
sentimentCorrelationNodeArray[self.id][self.env.now] = 1
|
sentimentCorrelationNodeArray[self.id][self.env.now] = 1
|
||||||
@ -46,7 +43,7 @@ class IndependentCascadeModel(BaseBehaviour):
|
|||||||
if x.time_awareness == (self.env.now-1):
|
if x.time_awareness == (self.env.now-1):
|
||||||
aware_neighbors_1_time_step.append(x)
|
aware_neighbors_1_time_step.append(x)
|
||||||
num_neighbors_aware = len(aware_neighbors_1_time_step)
|
num_neighbors_aware = len(aware_neighbors_1_time_step)
|
||||||
if random.random() < (settings.imitation_prob*num_neighbors_aware):
|
if random.random() < (self.imitation_prob*num_neighbors_aware):
|
||||||
self.state['id'] = 1
|
self.state['id'] = 1
|
||||||
sentimentCorrelationNodeArray[self.id][self.env.now] = 1
|
sentimentCorrelationNodeArray[self.id][self.env.now] = 1
|
||||||
else:
|
else:
|
||||||
|
@ -4,8 +4,6 @@ import numpy as np
|
|||||||
from ..BaseBehaviour import *
|
from ..BaseBehaviour import *
|
||||||
from .. import init_states
|
from .. import init_states
|
||||||
|
|
||||||
settings.init()
|
|
||||||
|
|
||||||
|
|
||||||
class ControlModelM2(BaseBehaviour):
|
class ControlModelM2(BaseBehaviour):
|
||||||
"""
|
"""
|
||||||
@ -36,16 +34,22 @@ class ControlModelM2(BaseBehaviour):
|
|||||||
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.prob_neutral_making_denier = np.random.normal(settings.prob_neutral_making_denier, settings.standard_variance)
|
self.prob_neutral_making_denier = np.random.normal(environment.prob_neutral_making_denier,
|
||||||
|
environment.standard_variance)
|
||||||
|
|
||||||
self.prob_infect = np.random.normal(settings.prob_infect, settings.standard_variance)
|
self.prob_infect = np.random.normal(environment.prob_infect, environment.standard_variance)
|
||||||
|
|
||||||
self.prob_cured_healing_infected = np.random.normal(settings.prob_cured_healing_infected, settings.standard_variance)
|
self.prob_cured_healing_infected = np.random.normal(environment.prob_cured_healing_infected,
|
||||||
self.prob_cured_vaccinate_neutral = np.random.normal(settings.prob_cured_vaccinate_neutral, settings.standard_variance)
|
environment.standard_variance)
|
||||||
|
self.prob_cured_vaccinate_neutral = np.random.normal(environment.prob_cured_vaccinate_neutral,
|
||||||
|
environment.standard_variance)
|
||||||
|
|
||||||
self.prob_vaccinated_healing_infected = np.random.normal(settings.prob_vaccinated_healing_infected, settings.standard_variance)
|
self.prob_vaccinated_healing_infected = np.random.normal(environment.prob_vaccinated_healing_infected,
|
||||||
self.prob_vaccinated_vaccinate_neutral = np.random.normal(settings.prob_vaccinated_vaccinate_neutral, settings.standard_variance)
|
environment.standard_variance)
|
||||||
self.prob_generate_anti_rumor = np.random.normal(settings.prob_generate_anti_rumor, settings.standard_variance)
|
self.prob_vaccinated_vaccinate_neutral = np.random.normal(environment.prob_vaccinated_vaccinate_neutral,
|
||||||
|
environment.standard_variance)
|
||||||
|
self.prob_generate_anti_rumor = np.random.normal(environment.prob_generate_anti_rumor,
|
||||||
|
environment.standard_variance)
|
||||||
|
|
||||||
def step(self, now):
|
def step(self, now):
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@ import numpy as np
|
|||||||
from ..BaseBehaviour import *
|
from ..BaseBehaviour import *
|
||||||
from .. import init_states
|
from .. import init_states
|
||||||
|
|
||||||
settings.init()
|
|
||||||
|
|
||||||
|
|
||||||
class SpreadModelM2(BaseBehaviour):
|
class SpreadModelM2(BaseBehaviour):
|
||||||
"""
|
"""
|
||||||
@ -31,16 +29,22 @@ class SpreadModelM2(BaseBehaviour):
|
|||||||
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.prob_neutral_making_denier = np.random.normal(settings.prob_neutral_making_denier, settings.standard_variance)
|
self.prob_neutral_making_denier = np.random.normal(environment.prob_neutral_making_denier,
|
||||||
|
environment.standard_variance)
|
||||||
|
|
||||||
self.prob_infect = np.random.normal(settings.prob_infect, settings.standard_variance)
|
self.prob_infect = np.random.normal(environment.prob_infect, environment.standard_variance)
|
||||||
|
|
||||||
self.prob_cured_healing_infected = np.random.normal(settings.prob_cured_healing_infected, settings.standard_variance)
|
self.prob_cured_healing_infected = np.random.normal(environment.prob_cured_healing_infected,
|
||||||
self.prob_cured_vaccinate_neutral = np.random.normal(settings.prob_cured_vaccinate_neutral, settings.standard_variance)
|
environment.standard_variance)
|
||||||
|
self.prob_cured_vaccinate_neutral = np.random.normal(environment.prob_cured_vaccinate_neutral,
|
||||||
|
environment.standard_variance)
|
||||||
|
|
||||||
self.prob_vaccinated_healing_infected = np.random.normal(settings.prob_vaccinated_healing_infected, settings.standard_variance)
|
self.prob_vaccinated_healing_infected = np.random.normal(environment.prob_vaccinated_healing_infected,
|
||||||
self.prob_vaccinated_vaccinate_neutral = np.random.normal(settings.prob_vaccinated_vaccinate_neutral, settings.standard_variance)
|
environment.standard_variance)
|
||||||
self.prob_generate_anti_rumor = np.random.normal(settings.prob_generate_anti_rumor, settings.standard_variance)
|
self.prob_vaccinated_vaccinate_neutral = np.random.normal(environment.prob_vaccinated_vaccinate_neutral,
|
||||||
|
environment.standard_variance)
|
||||||
|
self.prob_generate_anti_rumor = np.random.normal(environment.prob_generate_anti_rumor,
|
||||||
|
environment.standard_variance)
|
||||||
|
|
||||||
def step(self, now):
|
def step(self, now):
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
import settings
|
|
||||||
import random
|
import random
|
||||||
from ..BaseBehaviour import *
|
from ..BaseBehaviour import *
|
||||||
from .. import sentimentCorrelationNodeArray
|
from .. import sentimentCorrelationNodeArray
|
||||||
|
|
||||||
settings.init()
|
|
||||||
|
|
||||||
|
|
||||||
class SentimentCorrelationModel(BaseBehaviour):
|
class SentimentCorrelationModel(BaseBehaviour):
|
||||||
"""
|
"""
|
||||||
@ -22,11 +19,11 @@ class SentimentCorrelationModel(BaseBehaviour):
|
|||||||
|
|
||||||
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.outside_effects_prob = settings.outside_effects_prob
|
self.outside_effects_prob = environment.outside_effects_prob
|
||||||
self.anger_prob = settings.anger_prob
|
self.anger_prob = environment.anger_prob
|
||||||
self.joy_prob = settings.joy_prob
|
self.joy_prob = environment.joy_prob
|
||||||
self.sadness_prob = settings.sadness_prob
|
self.sadness_prob = environment.sadness_prob
|
||||||
self.disgust_prob = settings.disgust_prob
|
self.disgust_prob = environment.disgust_prob
|
||||||
self.time_awareness = []
|
self.time_awareness = []
|
||||||
for i in range(4): # In this model we have 4 sentiments
|
for i in range(4): # In this model we have 4 sentiments
|
||||||
self.time_awareness.append(0) # 0-> Anger, 1-> joy, 2->sadness, 3 -> disgust
|
self.time_awareness.append(0) # 0-> Anger, 1-> joy, 2->sadness, 3 -> disgust
|
||||||
@ -67,15 +64,15 @@ class SentimentCorrelationModel(BaseBehaviour):
|
|||||||
disgusted_neighbors_1_time_step.append(x)
|
disgusted_neighbors_1_time_step.append(x)
|
||||||
num_neighbors_disgusted = len(disgusted_neighbors_1_time_step)
|
num_neighbors_disgusted = len(disgusted_neighbors_1_time_step)
|
||||||
|
|
||||||
anger_prob= settings.anger_prob+(len(angry_neighbors_1_time_step)*settings.anger_prob)
|
anger_prob = self.anger_prob+(len(angry_neighbors_1_time_step)*self.anger_prob)
|
||||||
joy_prob= settings.joy_prob+(len(joyful_neighbors_1_time_step)*settings.joy_prob)
|
joy_prob = self.joy_prob+(len(joyful_neighbors_1_time_step)*self.joy_prob)
|
||||||
sadness_prob = settings.sadness_prob+(len(sad_neighbors_1_time_step)*settings.sadness_prob)
|
sadness_prob = self.sadness_prob+(len(sad_neighbors_1_time_step)*self.sadness_prob)
|
||||||
disgust_prob = settings.disgust_prob+(len(disgusted_neighbors_1_time_step)*settings.disgust_prob)
|
disgust_prob = self.disgust_prob+(len(disgusted_neighbors_1_time_step)*self.disgust_prob)
|
||||||
outside_effects_prob= settings.outside_effects_prob
|
outside_effects_prob = self.outside_effects_prob
|
||||||
|
|
||||||
num = random.random()
|
num = random.random()
|
||||||
|
|
||||||
if(num<outside_effects_prob):
|
if num<outside_effects_prob:
|
||||||
self.state['id'] = random.randint(1,4)
|
self.state['id'] = random.randint(1,4)
|
||||||
|
|
||||||
sentimentCorrelationNodeArray[self.id][self.env.now]=self.state['id'] # It is stored when it has been infected for the dynamic network
|
sentimentCorrelationNodeArray[self.id][self.env.now]=self.state['id'] # It is stored when it has been infected for the dynamic network
|
||||||
@ -95,13 +92,11 @@ class SentimentCorrelationModel(BaseBehaviour):
|
|||||||
self.time_awareness[self.state['id']-1] = self.env.now
|
self.time_awareness[self.state['id']-1] = self.env.now
|
||||||
elif (num<sadness_prob+anger_prob+joy_prob and num>joy_prob+anger_prob):
|
elif (num<sadness_prob+anger_prob+joy_prob and num>joy_prob+anger_prob):
|
||||||
|
|
||||||
|
|
||||||
self.state['id'] = 3
|
self.state['id'] = 3
|
||||||
sentimentCorrelationNodeArray[self.id][self.env.now]=3
|
sentimentCorrelationNodeArray[self.id][self.env.now]=3
|
||||||
self.time_awareness[self.state['id']-1] = self.env.now
|
self.time_awareness[self.state['id']-1] = self.env.now
|
||||||
elif (num<disgust_prob+sadness_prob+anger_prob+joy_prob and num>sadness_prob+anger_prob+joy_prob):
|
elif (num<disgust_prob+sadness_prob+anger_prob+joy_prob and num>sadness_prob+anger_prob+joy_prob):
|
||||||
|
|
||||||
|
|
||||||
self.state['id'] = 4
|
self.state['id'] = 4
|
||||||
sentimentCorrelationNodeArray[self.id][self.env.now]=4
|
sentimentCorrelationNodeArray[self.id][self.env.now]=4
|
||||||
self.time_awareness[self.state['id']-1] = self.env.now
|
self.time_awareness[self.state['id']-1] = self.env.now
|
||||||
|
45
settings.py
45
settings.py
@ -1,44 +1,6 @@
|
|||||||
# settings.py
|
# General configuration
|
||||||
def init():
|
|
||||||
global number_of_nodes
|
|
||||||
global max_time
|
|
||||||
global num_trials
|
|
||||||
global bite_prob
|
|
||||||
global network_type
|
|
||||||
global heal_prob
|
|
||||||
global innovation_prob
|
|
||||||
global imitation_prob
|
|
||||||
global timeout
|
|
||||||
global outside_effects_prob
|
|
||||||
global anger_prob
|
|
||||||
global joy_prob
|
|
||||||
global sadness_prob
|
|
||||||
global disgust_prob
|
|
||||||
global tweet_probability_users
|
|
||||||
global tweet_relevant_probability
|
|
||||||
global tweet_probability_about
|
|
||||||
global sentiment_about
|
|
||||||
global tweet_probability_enterprises
|
|
||||||
global enterprises
|
|
||||||
global neutral_discontent_spon_prob
|
|
||||||
global neutral_discontent_infected_prob
|
|
||||||
global neutral_content_spon_prob
|
|
||||||
global neutral_content_infected_prob
|
|
||||||
global discontent_content
|
|
||||||
global discontent_neutral
|
|
||||||
global content_discontent
|
|
||||||
global content_neutral
|
|
||||||
global variance_d_c
|
|
||||||
global variance_c_d
|
|
||||||
global standard_variance
|
|
||||||
global prob_neutral_making_denier
|
|
||||||
global prob_infect
|
|
||||||
global prob_cured_healing_infected
|
|
||||||
global prob_cured_vaccinate_neutral
|
|
||||||
global prob_vaccinated_healing_infected
|
|
||||||
global prob_vaccinated_vaccinate_neutral
|
|
||||||
global prob_generate_anti_rumor
|
|
||||||
|
|
||||||
|
# Network settings
|
||||||
network_type = 1
|
network_type = 1
|
||||||
number_of_nodes = 1000
|
number_of_nodes = 1000
|
||||||
max_time = 50
|
max_time = 50
|
||||||
@ -98,6 +60,3 @@ def init():
|
|||||||
prob_vaccinated_healing_infected = 0.035
|
prob_vaccinated_healing_infected = 0.035
|
||||||
prob_vaccinated_vaccinate_neutral = 0.035
|
prob_vaccinated_vaccinate_neutral = 0.035
|
||||||
prob_generate_anti_rumor = 0.035
|
prob_generate_anti_rumor = 0.035
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
104
settings_org.py
Normal file
104
settings_org.py
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
# settings.py
|
||||||
|
def init():
|
||||||
|
global number_of_nodes
|
||||||
|
global max_time
|
||||||
|
global num_trials
|
||||||
|
global bite_prob
|
||||||
|
global timeout
|
||||||
|
global network_type
|
||||||
|
global heal_prob
|
||||||
|
global innovation_prob
|
||||||
|
global imitation_prob
|
||||||
|
global outside_effects_prob
|
||||||
|
global anger_prob
|
||||||
|
global joy_prob
|
||||||
|
global sadness_prob
|
||||||
|
global disgust_prob
|
||||||
|
global tweet_probability_users
|
||||||
|
global tweet_relevant_probability
|
||||||
|
global tweet_probability_about
|
||||||
|
global sentiment_about
|
||||||
|
global tweet_probability_enterprises
|
||||||
|
global enterprises
|
||||||
|
global neutral_discontent_spon_prob
|
||||||
|
global neutral_discontent_infected_prob
|
||||||
|
global neutral_content_spon_prob
|
||||||
|
global neutral_content_infected_prob
|
||||||
|
global discontent_content
|
||||||
|
global discontent_neutral
|
||||||
|
global content_discontent
|
||||||
|
global content_neutral
|
||||||
|
global variance_d_c
|
||||||
|
global variance_c_d
|
||||||
|
global standard_variance
|
||||||
|
global prob_neutral_making_denier
|
||||||
|
global prob_infect
|
||||||
|
global prob_cured_healing_infected
|
||||||
|
global prob_cured_vaccinate_neutral
|
||||||
|
global prob_vaccinated_healing_infected
|
||||||
|
global prob_vaccinated_vaccinate_neutral
|
||||||
|
global prob_generate_anti_rumor
|
||||||
|
|
||||||
|
# Network settings
|
||||||
|
network_type = 1
|
||||||
|
number_of_nodes = 1000
|
||||||
|
max_time = 50
|
||||||
|
num_trials = 1
|
||||||
|
timeout = 2
|
||||||
|
|
||||||
|
# Zombie model
|
||||||
|
bite_prob = 0.01 # 0-1
|
||||||
|
heal_prob = 0.01 # 0-1
|
||||||
|
|
||||||
|
# Bass model
|
||||||
|
innovation_prob = 0.001
|
||||||
|
imitation_prob = 0.005
|
||||||
|
|
||||||
|
# Sentiment Correlation model
|
||||||
|
outside_effects_prob = 0.2
|
||||||
|
anger_prob = 0.06
|
||||||
|
joy_prob = 0.05
|
||||||
|
sadness_prob = 0.02
|
||||||
|
disgust_prob = 0.02
|
||||||
|
|
||||||
|
# Big Market model
|
||||||
|
## Names
|
||||||
|
enterprises = ["BBVA", "Santander", "Bankia"]
|
||||||
|
## Users
|
||||||
|
tweet_probability_users = 0.44
|
||||||
|
tweet_relevant_probability = 0.25
|
||||||
|
tweet_probability_about = [0.15, 0.15, 0.15]
|
||||||
|
sentiment_about = [0, 0, 0] # Default values
|
||||||
|
## Enterprises
|
||||||
|
tweet_probability_enterprises = [0.3, 0.3, 0.3]
|
||||||
|
|
||||||
|
# SISa
|
||||||
|
neutral_discontent_spon_prob = 0.04
|
||||||
|
neutral_discontent_infected_prob = 0.04
|
||||||
|
neutral_content_spon_prob = 0.18
|
||||||
|
neutral_content_infected_prob = 0.02
|
||||||
|
|
||||||
|
discontent_neutral = 0.13
|
||||||
|
discontent_content = 0.07
|
||||||
|
variance_d_c = 0.02
|
||||||
|
|
||||||
|
content_discontent = 0.009
|
||||||
|
variance_c_d = 0.003
|
||||||
|
content_neutral = 0.088
|
||||||
|
|
||||||
|
standard_variance = 0.055
|
||||||
|
|
||||||
|
# Spread Model M2 and Control Model M2
|
||||||
|
prob_neutral_making_denier = 0.035
|
||||||
|
|
||||||
|
prob_infect = 0.075
|
||||||
|
|
||||||
|
prob_cured_healing_infected = 0.035
|
||||||
|
prob_cured_vaccinate_neutral = 0.035
|
||||||
|
|
||||||
|
prob_vaccinated_healing_infected = 0.035
|
||||||
|
prob_vaccinated_vaccinate_neutral = 0.035
|
||||||
|
prob_generate_anti_rumor = 0.035
|
||||||
|
|
||||||
|
|
||||||
|
|
6
soil.py
6
soil.py
@ -8,7 +8,6 @@ import models
|
|||||||
import math
|
import math
|
||||||
import json
|
import json
|
||||||
|
|
||||||
settings.init() # Loads all the data from settings
|
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Network creation #
|
# Network creation #
|
||||||
@ -22,6 +21,7 @@ if settings.network_type == 2:
|
|||||||
G = nx.margulis_gabber_galil_graph(settings.number_of_nodes, None)
|
G = nx.margulis_gabber_galil_graph(settings.number_of_nodes, None)
|
||||||
# More types of networks can be added here
|
# More types of networks can be added here
|
||||||
|
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# Simulation #
|
# Simulation #
|
||||||
##############
|
##############
|
||||||
@ -29,12 +29,13 @@ if settings.network_type == 2:
|
|||||||
sim = NetworkSimulation(topology=G, states=init_states, agent_type=ControlModelM2,
|
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)
|
||||||
|
|
||||||
|
|
||||||
sim.run_simulation()
|
sim.run_simulation()
|
||||||
|
|
||||||
|
|
||||||
###########
|
###########
|
||||||
# Results #
|
# Results #
|
||||||
###########
|
###########
|
||||||
|
|
||||||
x_values = []
|
x_values = []
|
||||||
infected_values = []
|
infected_values = []
|
||||||
neutral_values = []
|
neutral_values = []
|
||||||
@ -86,7 +87,6 @@ plt.savefig('control_model.png')
|
|||||||
# Visualization #
|
# Visualization #
|
||||||
#################
|
#################
|
||||||
|
|
||||||
|
|
||||||
for x in range(0, settings.number_of_nodes):
|
for x in range(0, settings.number_of_nodes):
|
||||||
for attribute in models.networkStatus["agent_%s"%x]:
|
for attribute in models.networkStatus["agent_%s"%x]:
|
||||||
emotionStatusAux=[]
|
emotionStatusAux=[]
|
||||||
|
Loading…
Reference in New Issue
Block a user