consensus
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
A model of consensus network to agree in a the value of one variable
HOW IT WORKS
Each agent exchanges its value with its direct neighbor and updates it towards the average value of all the received values
HOW TO USE IT
Configure the model using:
NUM-AGENTS determines the size of the network DEGREE is the exact degree of each node ITER is the number of iterations that will be executed
Then GENERATE NEWORK creates a random network with the defined parameters and inits the value of each agents uniformly in [0,1]
Click on STEP to exchange values among the agents step by step. Click on GO to execute the number of iterations specified in ITER. RESET will generate a new set of initial values over the same network structure.
CHANGE-COLOR allows to keep the agent color to check its evolution on the graph CONSENSUS PROCESS or allows the color to change towards the consensus value.
THINGS TO NOTICE
The size of the network barely affects to the convergece speed. The convnergece is more sensitive to the degree of the network and its topology.
THINGS TO TRY
Check what happens if the network has more that one component.
EXTENDING THE MODEL
To include additional network models
To include weights in the edges so an weighted average is calculated
To allow the agents dynamically enter or leave the system
CREDITS AND REFERENCES
2012 Miguel Rebollo (@mrebollo).
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Comments and Questions
globals [ initial-average current-average cummulated-difference maximum-degree ;;; code to isolate view from code (View-controller Model) number-of-agents initial-degree iterations ] turtles-own [ x ;; current agent value newx ;;next iteration value eps ;; epsilon value: step to approach to the mean value ] to setup configure-model create-network reset end to configure-model set number-of-agents num-agents set initial-degree degree set iterations iter end to create-network ca set-default-shape turtles "circle" create-turtles num-agents ;;create a random network ask turtles [create-links-with n-of degree other turtles] set maximum-degree max [count my-links] of turtles end to reset clear-all-plots reset-ticks set current-average 0 set cummulated-difference 0 ;; reset agents ask turtles [reset-agent] set initial-average mean [x] of turtles ;; Layout turtles: layout-circle (sort turtles) max-pxcor - 2 display end to reset-agent ;; inits agent value at random set x random-float 1 set eps 1 / (maximum-degree + 1) set-current-plot "Consensus process" create-temporary-plot-pen (word who) set-turtle-color end to set-turtle-color ifelse (change-color?) [set color scale-color blue x 0 1] [ifelse ( num-agents < 15 ) [set color one-of base-colors] [set color random 140] ] end to reach-consensus ;; stops when the number of iteratios is reached if (ticks = iter) [stop] ;; updates the values ask turtles [ set newx x - eps * (x * (count my-links) - sum [x] of link-neighbors) ] ask turtles [ set x newx if (change-color?) [set color scale-color blue x 0 1] ] ;; calculates the current average (just to check sum/aerage conservation set current-average mean [x] of turtles ;; calulates the cummulative difference with the average value set cummulated-difference sum [(x - current-average) ^ 2] of turtles / 2 tick end
There is only one version of this model, created almost 8 years ago by Miguel Rebollo.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
consensus.png | preview | Preview for 'consensus' | almost 8 years ago, by Miguel Rebollo | Download |
This model does not have any ancestors.
This model does not have any descendants.