Commit ce363a46 authored by Amit Goldenberg's avatar Amit Goldenberg

This is a version that includes the modifies reductions as well as an ability to graph the results

parent 3f8f2569
#testdd
import random
import numpy as np
from scipy.stats import truncnorm
......@@ -13,7 +12,7 @@ class ColEmo(NetworkAgent):
self.preference = np.random.normal(0,self.globalSharedParameters['preference']) #this is the defree of preference (regulation) each participants has.
self.gamma = self.globalSharedParameters['gamma'] # the decay term.
#fixed variables (for now)
self.event = 0.9 #self.globalSharedParameters['event'] # rate of experience
self.event = 0.5 #self.globalSharedParameters['event'] # rate of experience - low numbers mean
self.bump = 2#globalSharedParameters['bump']
self.noise = 0.02 # noise term
self.conform = truncnorm.rvs(0.2,0.6) # this is the degree of conformity each participant has.
......@@ -31,9 +30,11 @@ class ColEmo(NetworkAgent):
influence = influence
else:
influence = 0
# I made this cose for situations in which influence is = 0 (when there are no people that express their emotions)
#print "influence %s" %influence
emotion = (self.state*self.gamma) - influence + self.preference # the individual emotion
# this part forms the emotional bump that a participant recieves using the experience ratio.
self.event = self.event*0.95
if self.flip() == "bump": # if the flip condition fit the bump - than we need to bump.
self.state = emotion + self.bump # can be changed
elif self.flip() == "no_bump":
......@@ -72,4 +73,4 @@ class ColEmo(NetworkAgent):
def flip(self):
return "no_bump" if random.random() < self.event else "bump"
return "no_bump" if random.random() > self.event else "bump"
......@@ -17,7 +17,7 @@ from ComplexNetworkSim import NetworkSimulation, utils, PlotCreator
"""network"""
nodes = 40 # the amount of nodes for the graph. which is also the amount of particiaptns
nodes = 10 # the amount of nodes for the graph. which is also the amount of particiaptns
#typologt
......@@ -31,7 +31,7 @@ nx.draw_networkx(G) # draw the network
""" parameter combination """
#event_set = [0.1,0,2] # the rate of emotion eliciting events (the change that an agent will experience)
preference_set = [0.01,0.2,0.5]
preference_set = [0.01,0.2, 0.5]
gamma_set = [0.95]
#bump_set = [2]
......@@ -46,8 +46,8 @@ TRIALS = 1 # how many repititions is the system doing
mean_total = []#pd.DataFrame(range(MAX_SIMULATION_TIME))
sim_name = 'wide'
states = [ np.random.normal(5,1) for n in G.nodes()] # initiation state of all agenges
states[0] = np.random.normal(5,1) # infecting partcipiant 0
states = [ np.random.normal(2,1) for n in G.nodes()] # initiation state of all agenges
states[0] = np.random.normal(2,1) # infecting partcipiant 0
states[0] = sorted([1, states[0], 8])[1] # define an upper limit.
def main(): # we are defining a function that activates the sumulation.
......@@ -134,7 +134,7 @@ def main(): # we are defining a function that activates the sumulation.
"""
# run main
if __name__ == '__main__':
if __name__ == '__main__':
main()
""" in this part I print mean total which is the list of all the means"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment