This model simulate the spreading of different types of opinions in a scale-free network. The opinions are represented by binary strings and they are spread by agents called spreaders. The spreaders have a memory of capacity M, where they store the opinions that they receive. Moreover, the spreaders can also distort an opinion before to pass it.
This model can be used also to evaluate the effect of the entrance of some "incorruptible" agents (repairers). It is possible to evaluate three different strategies to enter them: random (the repairers are inserted randomly in the network), preferential attachment by degree (repairers are inserted in the most connected nodes) and preferential attachment by betweenness (repairers are inserted in the nodes wit highest betweenness centrality).
At the beginning, the model ask you to enter the parameters of the simulation:
For example, try to enter:
Size=3000, Length=5, Memory_capacity=320, Resistance=3, Confidence=-3, Step=400, Repairers=300, T_entering=200, Entering_Strategy= (one of the three)
or, for a more quick simulation, enter:
Size=300, Length=3, Memory_capacity=32, Resistance=3, Confidence=-3, Step=300, Repairers=30, T_entering=100, Entering_Strategy= (one of the three)
%pylab inline
%run go.py
(semilogarithmic plot)
plt.figure(figsize=(10,7))
plt.xlabel('time', fontsize=18)
plt.ylabel('Entropia Media', fontsize=18)
plt.title("Averange entropy")
plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
#plot
plt.semilogx(arange(0,len(H)), H,) #label=str(Beta[i]) )
plt.plot(Tstar,H[Tstar],'r*')
FalseOp=[]
TrueOp=[]
rum=[]
for i in range(len(Rumors)):
FalseOp.append(Rumors[i][0])
TrueOp.append(Rumors[i][-1])
plt.figure(figsize=(10,7))
plt.xlabel('time', fontsize=22)
plt.ylabel('D', fontsize=22)
plt.title('Opinions concentrations', fontsize=22)
plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
plt.plot(range(0,len(FalseOp)),FalseOp, label='False')
for i in range(len(Rumors)):
rum.append(Rumors[i][1:len(Rumors)])
plt.plot(range(0,len(rum)), rum)
plt.plot(range(0,len(TrueOp)),TrueOp, 'r', label='True')
plt.plot(Tstar,0,'g*')
plt.legend(loc='best', fontsize=22)
plt.figure(figsize=(10,7))
plt.xlabel('time', fontsize=18)
plt.title('Concentrations')
plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
plt.plot(range(0,len(FalseOp)),FalseOp, label='False')
plt.plot(range(0,len(TrueOp)),TrueOp, 'r', label='True')
plt.legend(loc='best', fontsize=22)
plt.plot(Tstar,0,'g*')
plt.figure(figsize=(10,7))
plt.bar(range(0,len(Rumors[-1])),Rumors[-1])
plt.title("Distribution of the opinions")