{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Rumors spreading ABS\n", "\n", "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.\n", "\n", "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).\n", "\n", "At the beginning, the model ask you to enter the parameters of the simulation:\n", "- The size of network\n", "- The length of the binary strings\n", "- The memory capacity of the spreaders\n", "- The resistance to distortions\n", "- The confidence in the most connected nodes\n", "- The number of time steps\n", "- The number of repairers inserted in the network\n", "- The time when repairers are inserted\n", "- The entering strategy" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Examples of choices of the parameters:\n", "\n", "For example, try to enter:\n", "\n", "Size=3000, Length=5, Memory_capacity=320, Resistance=3, Confidence=-3, Step=400, Repairers=300, T_entering=200, Entering_Strategy= (one of the three)\n", "\n", "or, for a more quick simulation, enter:\n", "\n", "Size=300, Length=3, Memory_capacity=32, Resistance=3, Confidence=-3, Step=300, Repairers=30, T_entering=100, Entering_Strategy= (one of the three)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%pylab inline\n", "%run go.py" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# PLOT" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Average entropy \n", "\n", "(semilogarithmic plot)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "plt.figure(figsize=(10,7))\n", "plt.xlabel('time', fontsize=18)\n", "plt.ylabel('Entropia Media', fontsize=18)\n", "plt.title(\"Averange entropy\")\n", "\n", "plt.xticks(fontsize=14)\n", "plt.yticks(fontsize=14)\n", "\n", "#plot\n", "plt.semilogx(arange(0,len(H)), H,) #label=str(Beta[i]) )\n", "plt.plot(Tstar,H[Tstar],'r*')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Evolution of the opinions concentrations" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "FalseOp=[]\n", "TrueOp=[]\n", "rum=[]\n", "for i in range(len(Rumors)):\n", " FalseOp.append(Rumors[i][0])\n", " TrueOp.append(Rumors[i][-1])\n", "plt.figure(figsize=(10,7))\n", "plt.xlabel('time', fontsize=22)\n", "plt.ylabel('D', fontsize=22)\n", "plt.title('Opinions concentrations', fontsize=22)\n", "plt.xticks(fontsize=14)\n", "plt.yticks(fontsize=14)\n", "plt.plot(range(0,len(FalseOp)),FalseOp, label='False')\n", "for i in range(len(Rumors)):\n", " rum.append(Rumors[i][1:len(Rumors)])\n", "plt.plot(range(0,len(rum)), rum)\n", "plt.plot(range(0,len(TrueOp)),TrueOp, 'r', label='True')\n", "\n", "plt.plot(Tstar,0,'g*')\n", "plt.legend(loc='best', fontsize=22)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# True opinion and false opinion concentrations" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(10,7))\n", "plt.xlabel('time', fontsize=18)\n", "plt.title('Concentrations')\n", "\n", "plt.xticks(fontsize=14)\n", "plt.yticks(fontsize=14)\n", "\n", "plt.plot(range(0,len(FalseOp)),FalseOp, label='False')\n", "plt.plot(range(0,len(TrueOp)),TrueOp, 'r', label='True')\n", "plt.legend(loc='best', fontsize=22)\n", "plt.plot(Tstar,0,'g*')\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Distribution of opinions at the end of simulation" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "plt.figure(figsize=(10,7))\n", "plt.bar(range(0,len(Rumors[-1])),Rumors[-1])\n", "plt.title(\"Distribution of the opinions\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.3" } }, "nbformat": 4, "nbformat_minor": 2 }