Voting with Feet - A.JD
Model was written in NetLogo 5.3.1
•
Viewed 311 times
•
Downloaded 21 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
globals [ margins ; spacing from the two edges of the screen ] ;; three breeds of agents: 1) citizens, 2) cities, and 3) newsletters breed [citizens citizen] breed [cities city] breed [newsletters newsletter] citizens-own [ preference ; citizens have ideological preferences happiness ; citizens have a level of happiness money ; citizens have financial resources alphac ; the alpha coefficient associated with the weight of the city's ideology alphap ; the alpha coefficient associated with the weight of the city population's ideology alphan ; the alpha coefficient associated with the weight of the city newsletter's ideology sum-alphas ; the sum of the alpha coefficient utility ; the utility function of all the weighted alphas my-newsletter ; the newsletter of each town the citizen is living in my-city ; the city of each city ] cities-own [ ideology ; the ideology of the city ] newsletters-own [ bias ; the ideological slant of the city's newsletter placement ] to setup clear-plot clear-patches clear-turtles ; clears the world reset-ticks ; resets the number of iterations set margins 2 ; sets the margins around the screen to be two patches setup-cities ; creates the cities and their characteristics setup-citizens ; creates the citizens and their characteristics setup-newsletters ; creates the newsletters and their characteristics ask citizens [update-happiness] end to go ;ask citizens [ update-happiness] ; sets up the initial happiness levels if ticks mod 4 = 0 ; hold elections once every four iterations [ hold-elections ] if ticks mod newsletter-lag = 0 [change-newsletters] ; change the newsletter bias if ticks mod pop-lag = 0 [ ask citizens [ update-happiness check-happiness] ] tick ; go once per iteration if sum [happiness] of citizens / num-citizens >= 0.99 [output-print ticks stop] end to setup-cities create-cities num-cities ; create the same number of cities as on the slider ask cities [ ifelse random 2 = 1 ; city has random starting policies [set ideology red] ; set random 50% of cities to be conservative (red) [set ideology blue] ; set the rest of the cities to be liberal (blue) set color ideology ; sets the color to be the same as ideology set shape "house" ; sets the shape of the cities as a house ] let spacing floor ( world-width - 2 * margins ) / ( count cities ) ; spacing of cities ask cities [ setxy (min-pxcor + margins + spacing * (who + .5) ) (pycor - 10) ] end to setup-citizens create-citizens num-citizens ; creates the same number of citizens as on the slider ask citizens [ ; randomly creates liberal or conservative citizens set as their preference ifelse random 2 = 1 [set preference red set money random 100] ; give citizens a random amount of resources to be money to move [set preference blue set money random 100] set color preference ; sets the color to be the same as the preference set shape "person" ; sets the shape as a person set my-city one-of cities move-to my-city set heading 0 while [count turtles-here > 1 and ycor < max-pycor] ; has the citizens line up on top of one another [fd 1] ;updates-alphas set alphac random-float city-ideology ; sets the alpha for the weight of the city's ideology to be a function of the slider set alphap random-float population-ideology ; sets the alpha of the weight of the city's population ideology to be a function of the slider set alphan random-float newsletter-slant ; sets the alpha of the weight of the city's newsletters ideology to be a function of the slider set sum-alphas alphac + alphap + alphan ; sums the alphas and normalize them to all equal 1 set alphac ( alphac / sum-alphas ) set alphap ( alphap / sum-alphas ) set alphan ( alphan / sum-alphas ) ] end to setup-newsletters create-newsletters num-cities ; create the same number of newsletters as the number of cities ask newsletters [ ifelse random 2 = 1 ; randomly creates liberal or conservative newsletters set as their bias, colored accordingly [set bias red] [set bias blue] set placement random num-cities set color bias set shape "book" ; sets the shape as a book move-to one-of cities with [not any? other newsletters-here] ; moves to under one of the location as one of the city ] ask newsletters [ set heading 0 fd -1 ] ask citizens [ set my-newsletter one-of newsletters with [ xcor = [xcor] of myself] ] end to update-happiness let count-similar count citizens with [ (my-city = [my-city] of myself) and (color = [color] of myself) ] let count-total count citizens with [ my-city = [my-city] of myself ] set happiness (check-happiness-city ( [ideology] of my-city ) * alphac) + ( check-happiness-newsletter ( [bias] of my-newsletter) * alphan) + ( (count-similar / count-total) * alphap) end to check-happiness ask citizens [if happiness < desire-to-move and money > money-to-move [ set my-city one-of cities move-to my-city set heading 0 while [count turtles-here > 1 and ycor < max-pycor] ; has the citizens line up on top of one another [fd 1] set my-newsletter one-of newsletters with [ xcor = [xcor] of myself] update-happiness ] ] end to-report check-happiness-city [local-ideology] ifelse ( preference = local-ideology) ; if the preference of the citizen is the same as the city ideology, report a 1, if not 0 [report 1] [report 0] end to-report check-happiness-newsletter [local-bias] ifelse ( preference = local-bias ) ; if the preference of the citizen is the same as the newsletter ideology, report a 1, if not 0 [report 1] [report 0 ] end to hold-elections ask cities [ let city-id who ; number by which citizens identify the city let voters citizens with [ my-city = city-id ] ; voters are citizens living in the city hold-democratic-referenda (voters) ; the city uses a democratic referenda set color ideology ] end to hold-democratic-referenda [voters] ; changes the cities' ideology based on direct referenda let reds count voters with [preference = red] ; if more people vote red, the city will turn red ifelse ( reds > (count voters) / 2 ) [set ideology red ] ; if more people voted blue, the city will turn blue [ifelse (reds < (count voters) / 2 ) [set ideology blue ] [ifelse ( (random 2) = 1 ) ; if tied, flip coin [set ideology red] [set ideology blue] ] ] end to change-newsletters ask newsletters [ let newsletter-id who ; number by which citizens identify the newsletter let journalists citizens with [ my-newsletter = newsletter-id ] ; journalists are citizens living near the newsletter change-newsletter-bias (journalists) ; the journalists change the bias of the newsletter set color bias ] end to change-newsletter-bias [journalists] ; changes the newsletter bias based on the citizen's ideology let reds count journalists with [preference = red] ; if more people are red, the newsletter will be red ifelse reds > count journalists / 2 [set bias red ] [ifelse reds < count journalists / 2 ; if more people vote blue, the newsletter will be blue [set bias blue ] [ifelse random 2 = 1 ; if tied, flips coin [set bias red] [set bias blue] ] ] end
There is only one version of this model, created about 8 years ago by Amanda Durso.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Voting with Feet - A.JD.png | preview | Preview for 'Voting with Feet - A.JD' | about 8 years ago, by Amanda Durso | Download |
This model does not have any ancestors.
This model does not have any descendants.