macro-neighbours-micro

No preview image

This model is seeking new collaborators — would you please help?

1 collaborator

Default-person Shipra Ghosh Ray (Author)

Tags

neighbors 

Tagged by Shipra Ghosh Ray almost 9 years ago

politics 

Tagged by Shipra Ghosh Ray almost 9 years ago

voter 

Tagged by Shipra Ghosh Ray almost 9 years ago

voting 

Tagged by Shipra Ghosh Ray almost 9 years ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 5.3.1 • Viewed 1009 times • Downloaded 49 times • Run 0 times
Download the 'macro-neighbours-micro' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


MODEL SCOPE

(The model explores voting dynamics in a neighbourhood in a spatial context.Consider a game which has the following rules: 1. Consider a neighbourhood of people.Each resident has one neighbour at most. This means that there can exist some cases where an agent may have no neighbour. 2. Two residents of the neighbourhood are running for neighbourhood elections. They both have extreme and opposite views. One has been coded as red-influential and the other as blue-influential. The choice of colours is indicative of their difference in viewpoints. 3. The people of the neighbourhood, coded as persons are required to align with these two neighbours or they may remain non-aligned. The number of these persons may be chosen as per the num-persons slider with minimum of 1 person and a maximum of 100 persons. This means that at any given point the time, the number of persons in the world will be num-persons + 2 (1 red-influential and 1 blue-influential). 4. The persons initially begin by sporting the colour, beige, which indicates their neutrality or non-alignment. As time ticks by, the agents change their colour to red or blue or remain beige. Whether or not a neighbour aligns or stays non-aligned depends on whether they have a neighbour and on the distance between them and the red and blue influential agents. 5. Whether or not a person has a neighbour is determined by the links. It is necessary for a person to have a neighbour in order for it to align. This is because it is an assumption of the game that only persons who are linked to other persons or red and blue-influential are allowed to vote. 6. Once the alignment has taken place, it is checked whether red-influential and blue-influential still retain their influence in the neighbourhood or whether they are themselves influenced by opposite viewpoints to change breed and colour to that of the opposite contestant. After this, the persons align themselves again and the above steps are repeated. In case bredds and colours do not change, the persons simply re-align themselves if necessary. )

AGENT SELECTION

(The agents have been classified into the following breeds: • The red agent that contests has been classified as red-influential and there is one of these. • The blue agent that contests has been classified as blue-influential and there is one of these. • The non-contesting persons in the neighbourhood have been classified as persons and their number can be selected using the slider by the user. Their number can range between 1 and 100. )

AGENT PROPERTIES

(The properties of the agents are as elucidated below: • red-influential: Red-influential has a red-influence of 5, which is a global property i.e. applicable to all agents in the world. Its default shape has been set to that of a “flag” and its default colour is red.

• blue-influential:Blue-influential has a blue-influence of 5, which is a global property i.e. applicable to all agents in the world. Its default shape has been set to that of a “flag” and its default colour is blue.

• persons: These agents have been positioned randomly according to the spring layout which can be observed from the code. Their default colour is beige (35 + 3 on the color swatch). Their shape has been set to “persons” and their size is 1. Each person begins by having a red-reward of 0 and a blue-reward of 0, which increases or decreases according to time depending on the following cases: If the person is linked: If the distance between the person and the red-influential is less than or equal to 5, then, red-reward decreases by 0.1. If the distance between the person and the red-influential is greater than 5 and less than or equal to 10, then, red-reward increases by 0.1. If the distance between the person and the red-influential is greater than 10 then, red-reward remains as is if the distance between the person and the blue-influential is less than or equal to 5, then, blue-reward decreases by 0.1 If the distance between the person and the blue-influential is greater than 5 and less than or equal to 10, then, blue-reward increases by 0.1 If the distance between the person and the blue-influential is greater than 10 then, blue-reward remains 0 If the distance between the person and the red-influential and the distance between the person and the blue-influential is equal, then, red-reward = blue-reward

Each person also has a red-factor and blue-factor unique to themselves. The red-factors and blue-factors are calculated as follows:

red-factor = red-influence + red-reward blue-factor = blue-influence + blue-reward

For each person, if red-factor > blue-factor, then, it aligns with red-influential and its colour changes to red. Otherwise, it aligns with blue-influential and its colour turns blue. In case, red-factor = blue-factor, then, the persons stay non-aligned and their colour remains beige.

)

AGENT ACTIONS

(The agents can perform the following actions: red-influential - Can change colour and breed to that of blue-influential if the red-flux is below the threshold of 0.25, cannot move about in space blue-influential - Can change colour and breed to that of red-influential if the blue-flux is below the threshold of 0.25, cannot move about in space persons - can align or non-align and after the first stage of alignment can re-align and can move forward10 and right 90 degrees during re-alignment)

ENVIRONMENT

(The environment is a spatial environment with a linked layout adhering to the spring layout. The details of the layout of the links can be observed from the code.)

ORDER OF EVENTS

(After “go” is hit, in the first time step, all persons perform the “align” action, i.e. they either change colour to red or blue or they retain their original colour. Then, the persons perform “flux-act”. It is calculated whether the red-influential and blue-influential have fluxes less than 25% of original flux and if so, their breed and colour is changed to the opposite colour and breed. Finally, all persons “re-align” i.e. the persons that have already been aligned, change to the opposite colour. In the next tick, all of the above actions are repeated. And so on so forth…)

INPUTS AND OUTPUT

(The inputs are Number of persons. Outputs are the dynamics observed in the world and the monitors displaying the percentage of people and their adherence. )

MODEL EXECUTION

(Select the number of persons using the “num-persons” slider and hit the setup button to set up the environment and click on the “go” button for the model to be executed.)

USER INTERFACE

(The User Interface is very brief and is as described below. • There is a “num-persons” slider which lets the user select the number of persons in the neighbourhood and it can vary between 1 and 100 with an increment of 1. • There is a “setup” button, which sets up the model. • There is a “go” button, which executes the model. • There is of course, the world in which the agents interact and in which wrapping has been turned off. • There are five output monitors. They display the percentage of persons aligned with blue, red and beige and also blue-flux and red-flux. )

THINGS TO NOTICE

(Whether the red and blue-influential agents change colour and if so, when do they do it.)

THINGS TO TRY

(Right click on any of the persons and inspect them and observe the change in properties like red-reward etc when the model is being executed. In the observer command section, type show red-count, show blue-count, show red-flux, show blue-flux, etc when the model is being executed. )

RELATED MODELS

(Segregation Model)

CREDITS AND REFERENCES

( Wilensky, U. (1997). NetLogo Segregation model. http://ccl.northwestern.edu/netlogo/models/Segregation. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. )

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; PLEASE USE THE SPEED SLIDER TO MAKE     ;;;
;;; THE SPEED REALLY SLOW IN ORDER TO       ;;;
;;; VIEW IN DETAIL. THANKS. LOOK FORWARD TO ;;;
;;; CONSTRUCTIVE COMMENTS :)                ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



breed[red-influentials red-influential]   ;; classifies the red agent contesting as a separate breed
breed[blue-influentials blue-influential] ;; classifies the blue agent contesting as a separate breed
breed[persons person]                     ;; classifies the non-contesting agents as a different breed

persons-own [red-factor  ;; each person has a red-factor associated with it
             blue-factor ;; each person has a blue factor associated with it
             red-reward  ;; each person gets a reward in terms of its spatial
                         ;; relationship with red-influential
             blue-reward ;; each person gets a reward in terms of its spatial
                         ;; relationship with blue-influential

             ]
globals[red-influence  ;; the red-influential has an influence that spreads across all agents
        blue-influence ;; the blue-influential has an influence that spreads across all agents
        red-flux       ;; this deterines the changing prominence of the red-influential in the world
        blue-flux      ;; this determines the changing prominence of the blue-influential in the world
        red-count      ;; counts the number of persons with the colour red in the world after alignment
                       ;; has taken place
        blue-count     ;; counts the number of persons with the colour blue in the world after alignment
                       ;; has taken place
        neutral-count  ;; gives the number of beige persons in the world before and after alignment
        alignment      ;; gives the number of non-beige persons after alignment has taken place (sum of
                       ;; red and blue persons)
        ]

to setup
  clear-all

  create-red-influentials 1                  ;; there is only 1 agent contesting from the red side
  ask red-influentials [set color red       ;; set colour of red-influential to red
                        set size 1.5        ;; set size of red-influential to 1.5
                        setxy -2.344534561015166 5.675315858632209 ;; set aapproximate coordinates
                        fd 5]               ;; move forward 5
  set-default-shape red-influentials "flag" ;; the observer should see the red-influential appear
                                            ;; as a flag

  create-blue-influentials 1                ;; there is only 1 agent contesting from the blue side
  ask blue-influentials [set color blue     ;; set colour of blue-influential to blue
                         set size 1.5       ;; set size of blue-influential to 1.5
                         setxy 2.344534561015166 -5.675315858632209 ;; set approximate coordinates
                         fd 5]              ;; move forward 5
  set-default-shape blue-influentials "flag";; the observer should see the blue-influential appear
                                            ;; as a flag

  create-persons num-persons [              ;;creates non-contesting persons in the neighbourhood
                                            ;; their number can be determined from the num-persons
                                            ;; slider by the user
    set shape "person"                      ;; persons agents should appear in the persons shape
    set color 35 + 3                        ;; the color of these agents should be beige
    setxy random-xcor random-ycor           ;; they can be located anywhere at random in the world
    set red-reward 0                        ;; the initial red-reward at setup should be 0
    set blue-reward 0                       ;; the initial blue-reward at setup should be zero
    set red-influence 5                     ;; since red-influence is a global variable, it has to
                                            ;; be defined at setup and its value is chosen to be 5
    set blue-influence 5                    ;; since blue-influence is a global variable, it has to
                                            ;; be defined at setup and its value is chosen to be 5
                                            ;; since the views of red-influential and blue-influential
                                            ;; are both extreme and opposite, therefore it has been
                                            ;; assumed that they exert equal and opposite influence
                                            ;; in society their colours indicate the opposite viewpoints
                                            ;; but their influence has equal weight

     ]



  ask turtles [ create-links-with n-of 1 other turtles ] ;; in order to indicate that a neighbourhood exists,s,
                                                         ;; the turtles have been linked
                                                         ;; only turtles with links can align
                                                         ;; each turtle has only one neighbour at most

  repeat num-persons [layout-spring turtles links 0.2 5 1] ;; the spring layout has been chosen according to
                                                           ;; model documentation and its repetition number
                                                           ;; is dependent on the number of persons selected by
                                                           ;; the user

  reset-ticks
end 

to go

ask persons[align]                                          ;; persons are required to align

tick

ask turtles[flux-act]                                       ;; the turtles and not persons only are required to
                                                            ;; change alignment depending on changes in fluxes of red and blue

tick

ask persons [re-align]                                      ;; persons then perform the re-alignment procedure

tick
end 

to align


  ask persons [check-distance                               ;; persons perform the check-distance procedure which determines
                                                            ;; values of red-reward and blue-reward
               color-self                                   ;; persons color themselves and align according to changes to
                                                            ;; red-factor and blue-factor
  ]
end 

to check-distance                                            ;; this procedure calculate values of red-reward, blue-reward,
                                                             ;; red-factor and blue-factor

  ask persons [ if any? my-links [                           ;; this determines whether the persons are linked .
                                                             ;; i.e have neighbours


                  if (distancexy -2.344534561015166 5.675315858632209) > 10 [set red-reward 0 ]
                  ;; if the distance of person from specified coordinates is greater than 10, then,
                  ;; they are really not interested in aligning or non-aligning with red-influential
                  if (distancexy -2.344534561015166 5.675315858632209) <= 5 [set red-reward red-reward - 0.01]
                  ;; if the distance between person and specified coordinates is less than or equal to 5, then'
                  ;; they are interested in incrementally not aligning with red
                  if (distancexy -2.344534561015166 5.675315858632209) > 5 [set red-reward red-reward + 0.01]
                  ;; if the distance between person andspecified coordinates is greater than 5 and less than 10, then,
                  ;; they are interested in incrementally aligning with red
                  if (distancexy 2.344534561015166 -5.675315858632209) > 10 [set blue-reward 0]
                  ;; if the distance of person from specified coordinates is greater than 10, then,
                  ;; they are really not interested in aligning or non-aligning with blue-influential
                  if (distancexy 2.344534561015166 -5.675315858632209) <= 5 [set blue-reward blue-reward - 0.01]
                  ;; if the distance between person and specified coordinates is less than or equal to 5, then,
                  ;; they are interested in incrementally not aligning with blue
                  if (distancexy 2.344534561015166 -5.675315858632209) > 5 [set blue-reward blue-reward + 0.01]
                  ;; if the distance of person from specified coordinates is greater than 5, then,
                  ;; they are  interested in incrementally aligning with blue-influential
                  if (distancexy -2.344534561015166 5.675315858632209) = (distancexy 2.344534561015166 -5.675315858632209) [set red-reward red-reward = blue-reward]
                  ;; if the distance between the person and red-influential and person and blue-influential
                  ;; is equal, then, they are not interested in aligning with either candidate,
                  ;; even incrementally


                  set red-factor red-influence + red-reward
                  ;;  red-factor is unique to every person and is the sum of the global red-influence
                  ;;  and unique red-reward
                  set blue-factor blue-influence + blue-reward
                  ;;  blue-factor is unique to every person and is the sum of the global blue-influence
                  ;;  and unique blue-reward

                      ]

                                ]
end 

to color-self                                            ;; this procedure carries the visual nature of
                                                         ;; the alignment process

  ifelse red-factor > blue-factor                        ;; for every person, when red-factor is greater
                         [set color red]                 ;; than blue-factor, their colour changes to red
                         [set color blue]                ;; and if otherwise, their colour changes to blue;
                                                         ;; if both the factors are equal, then, their colour
  if red-factor = blue-factor [set color 35 + 3]         ;; remains beige
end 

to flux-act                                              ;; this procedure re-aligns the red and blue-influentials
                                                         ;; themselves

  set red-count count persons with [color = red]         ;; counts persons with colour red after alignment
  set blue-count count persons with [color = blue]       ;; counts persons with colour blue after alignment
  set neutral-count count persons with [color = 35 + 3]  ;; counts persons with colour beige after alignment

  set alignment count persons with [color = red] + count persons with [color = blue] ;; counts sum of persons
                                                                                     ;; with colour red or blue


  if blue-count + neutral-count = 0 [stop
                                     print "stopped as cannot divide by zero"
                                     ];; stops running the model as it is
  if red-count + neutral-count = 0 [stop
                                    print "stopped as cannot divide by zero"
                                    ] ;; impossible to divide by zero





  set red-flux red-count / (blue-count + neutral-count)  ;; calculates the force from the other colours
                                                         ;; on red-influential once alignment has taken place
  set blue-flux blue-count / (red-count + neutral-count) ;; calculates the force from the other colours
                                                         ;; on blue-influential once alignment has taken place



  if (red-flux) < 0.25 [ ask red-influentials [set breed blue-influentials ;; sets threshold for red-flux below which
                                                                           ;; its breed changes to blue-influential
                                               set color blue              ;; and colour changes to blue

                                               ]

                         ]
  if (blue-flux) < 0.25 [ask blue-influentials [set breed red-influentials ;; sets threshold for blue-flux below which
                                                                           ;; its breed changes to red-influential
                                                set color red              ;; and colour changes to red
                                                ]

                         ]
end 

to re-align                                            ;; the persons re-align if any change in alignment
                                                       ;; of influentials has taken place

  ifelse blue-factor > red-factor                      ;; for every person, when red-factor is greater
                         [set color red                ;; than blue-factor, their colour changes to red
                          fd 10 rt 90]                 ;; and if otherwise, their colour changes to blue;
                         [set color blue               ;; if both the factors are equal, then, their colour
                          fd 10 rt 90]                 ;; remains beige. When re-alignment takes place, the
                                                       ;; turtles move forward 10 and turn right by 90 degrees.
  if red-factor = blue-factor [set color 35 + 3]       ;; no movement for non-aligned turtles

  set red-count count persons with [color = red]         ;; counts persons with colour red after re-alignment
  set blue-count count persons with [color = blue]       ;; counts persons with colour blue after re-alignment
  set neutral-count count persons with [color = 35 + 3]  ;; counts persons with colour beige after re-alignment
end 

There is only one version of this model, created almost 9 years ago by Shipra Ghosh Ray.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.