Immigration-Legislation
No preview image
Model was written in NetLogo 5.3.1
•
Viewed 244 times
•
Downloaded 24 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 ] breed [immigrants immigrant] breed [citizens citizen] breed [cities city] turtles-own [ reality-community my-city ] citizens-own [ xlist initial-preference preferences ;citizens have immigration level preferences happiness ;citizens have a level of happiness alphai ;alpha level of preferred immigration alphap ;alpha level of preferred policy sum-alphas ;the sum of the alpha coefficient utility ;the utility function of all the weighted alphas ] immigrants-own [ ipreferences ;citizens have immigration level preferences ihappiness ;citizens have a level of happiness ialphai ;alpha level of preferred immigration ialphap ;alpha level of real policy isum-alphas ;the sum of the alpha coefficient iutility ;the utility function of all the weighted alphas ] cities-own [ legislation ] to setup clear-plot clear-patches clear-turtles reset-ticks set margins 2 ask patches[set pcolor grey - 2] setup-cities setup-citizens setup-immigrants ask turtles [update-reality-community ] ask cities [ set legislation random-float 1 set color scale-color violet legislation 1 0 ] output-print "new trial" output-type "citizen-community-preference " output-print citizen-community-preference output-type "citizen-policy-preference " output-print citizen-policy-preference output-type "%-immigrants " output-print %-immigrants output-print "initial legislation" ask cities [ output-show [legislation] of cities with [( who = [who] of myself) ] ] ask citizens [ set xlist (sentence reality-community reality-community) let first-mean mean xlist set xlist replace-item 0 xlist first-mean set initial-preference reality-community ] end to go if ticks mod 4 = 0 ; hold elections once every four iterations [ hold-elections ] update-utility tick ; go once per iteration output-type "ticks " output-print ticks ask cities [ output-show [legislation] of cities with [( who = [who] of myself) ] ] ask turtles [update-reality-community] ask citizens [update-preferences] if sum [happiness] of citizens / 100 >= 0.99 ; and sum [ihappiness] of immigrants / num-immigrants >= 0.99 [output-type "all happy ticks " output-print ticks output-print "distribution of citizen preferences" ask cities [ output-show sort-by < [preferences] of citizens with [ (my-city = [my-city] of myself) ] ] output-print "end" output-print " "] end to setup-cities create-cities num-cities ask cities [ ;set legislation random-float 1 set my-city self set shape "house" ] let spacing floor (world-width - 2 * margins)/(count cities) ask cities [ setxy (min-pxcor + margins + spacing * (who + 0.5))(max-pycor) ] end to setup-citizens create-citizens 100 ask citizens [ set color white set shape "person" set my-city one-of cities move-to my-city set heading 0 while [count turtles-here > 1 and ycor > min-pycor] ; has the citizens line up on top of one another [fd -1] ] ask citizens [ set alphap random-float citizen-community-preference ; sets the alpha of the weight of the city's population ideology to be a function of the slider set alphai random-float citizen-policy-preference ; sets the alpha of the weight of the city's newsletters ideology to be a function of the slider set sum-alphas alphai + alphap ; sums the alphas and normalize them to all equal 1 set alphap ( alphap / sum-alphas ) set alphai ( alphai / sum-alphas ) ] end to setup-immigrants create-immigrants (100 * %-immigrants) ask immigrants [ set color pink + 1 set shape "immigrant" set my-city one-of cities move-to my-city set heading 0 while [count turtles-here > 1 and ycor > min-pycor ] [fd -1] ] ask immigrants [ set ialphai random-float immigrants-community-preference set ialphap random-float immigrants-community-preference ; sets the alpha of the weight of the city's population ideology to be a function of the slider set isum-alphas ialphai + ialphap ; sums the alphas and normalize them to all equal 1 set ialphap ( ialphap / isum-alphas ) set ialphai ( ialphai / isum-alphas ) ] end to update-reality-community let count-immigrants count immigrants with [ (my-city = [my-city] of myself) ] let count-total ( count turtles with [ (my-city = [my-city] of myself)] ) - 1 set reality-community (count-immigrants / count-total) end to update-preferences set preferences mean xlist set xlist (sentence preferences reality-community) end to check-happiness ask citizens [ set happiness ( alphai * (1 - ( preferences - reality-community)^ 2) ) + ( alphap * (1 - ( preferences - ( [legislation] of my-city ) )^ 2) ) ;reality-policy ] ask immigrants [ set ihappiness (ialphai * (1 - (0.49 - reality-community)^ 2)) + (ialphap * (1 - ([legislation] of my-city) ^ 2 ) ) ] end to update-utility ask citizens [if happiness < 1 [set my-city one-of cities move-to my-city set heading 0 while [count turtles-here > 1 and ycor > min-pycor] [fd -1] update-reality-community check-happiness ] ] ask immigrants [if ihappiness < 1 [set my-city one-of cities move-to my-city set heading 0 while [count turtles-here > 1 and ycor > min-pycor] [fd -1] update-reality-community check-happiness ] ] end to-report check-happiness-city [local-legislation] ifelse ( preferences = local-legislation) ; 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 hold-elections ask cities [ set legislation reality-community set color scale-color violet legislation 1 0] end
There is only one version of this model, created over 6 years ago by Amanda Durso.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.