KIN_PROPINQUITY_RESIDENTIAL_MOBILITY_AND_ETHNIC SEGREGATION

No preview image

1 collaborator

Default-person Eduardo Tapia (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.2.2 • Viewed 103 times • Downloaded 3 times • Run 0 times
Download the 'KIN_PROPINQUITY_RESIDENTIAL_MOBILITY_AND_ETHNIC SEGREGATION' modelDownload this modelEmbed this model

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

;;Paper: “KIN PROPINQUITY, RESIDENTIAL MOBILITY, AND ETHNIC SEGREGATION”.
;; Jarvis, B., Chihaya Da Silva, G., & Tapia, E. (2022).
;; The ABM is based on Schelling´s model of segregation (1971,1969).

extensions [ rnd ]

globals [
  prop_neighborhood
  euclidean_distance
  index_of_dissimilarity
]

turtles-own [
  similar-nearby  ;; in-group turtles at my NBH (Moore neighborhood)
  total-nearby    ;; turtles at my NBH
  proportion_similar ;; similar-nearby / total-nearby
  kin ;; unique ID number to identify agents' kin
  total_utility_current_NBH ;; b1 (ethnic_share) + b3 (kin-distance to NBH)
  mover ;; if the household has been selected to move, mover = 1.
]

patches-own [
  NBH_id

]
breed [slots slot]  ;; slot = empty dwelling
breed [households household]

;############################ S E T U P #####################################

to setup
  ca
  resize-world 0 world_size 0 world_size
  set-patch-size patch_size ; 7 o 36
  let number_of_patches precision ((count patches * Perc_Agents ) / 100 ) 0
  ask n-of number_of_patches patches [ sprout-households 1 ]
  ;; majority (green agents)
  ask households [ set color green set shape "square"]
  ;; minority (red agents)
  ask n-of (( number_of_patches * %_minority_group_RED ) / 100 ) households [ set color red set shape "square"]
  ;; kin
  kinship
  ask patches with [ not any? turtles-here ] [ sprout-slots 1 [ set color black ]]

  current-NBH-utility
  selecting-movers
  create_NBH
  calculate_index

  reset-ticks
end 

to create_NBH

    let temp (world_size + 1) /   NBHsize_mXm
    let pool n-values temp [ i -> i ]
  foreach pool [
    x -> ask patches with [pycor >= (x * NBHsize_mXm) and pycor < (x * NBHsize_mXm) + NBHsize_mXm] [
set NBH_id int(pxcor / NBHsize_mXm) + ((x * ( (world_size + 1) /   NBHsize_mXm) ) + 1)
]
]
end 

to kinship
  let NumRed count turtles with [ color = red ]
  let NumGreen count turtles with [ color = green ]
  let NumgroupsRed floor ( NumRed / Kin_size )
  let NumgroupsGreen floor ( NumGreen / Kin_size )
  let greenlist n-values NumgroupsGreen [i -> i + 1]
  let redlist n-values NumgroupsRed [i -> i + (NumgroupsGreen + 1)]
  foreach greenlist [i -> ask n-of Kin_size households with [color = green and kin = 0] [ set kin i ]  ]
  foreach redlist   [i -> ask n-of Kin_size households with [color = red   and kin = 0] [ set kin i ]  ]
  ;; dropping unmatched agents
  ask turtles with [ kin = 0 ] [ die ]
end 

to current-NBH-utility

 ask households
  [
  ;; household color?
  let mycolor [color] of self

  ;; Calculating utility current NBH
  ;----------------------------------
  ;; (A) Ethnic Share utility
  set similar-nearby count (households-on neighbors) with [color = mycolor]
  set total-nearby count (households-on neighbors)
  ifelse (total-nearby > 0) [ set proportion_similar similar-nearby / total-nearby ] [set proportion_similar 0] ;; or 1?
  let utility_share_own_NBH ( proportion_similar * beta_ethnic )
  ;; (B) Kin-distance utility
  let yo [who] of self
  let mykin [kin] of self
  let mykins [who] of other households with [kin = mykin]
  let tempo2 []  ;; to save kin distances
  foreach mykins
  [
    i -> let x i
    let distance_to_temp euclidean_distancia x yo
    set tempo2 lput distance_to_temp tempo2
  ]

  let averg_kin_distance mean tempo2
  ;; normalizing kin distance
  let averg_kin_distance_NORM   averg_kin_distance / (world_size / 2)
  let utility_kin_distance_own_NBH ( averg_kin_distance_NORM * beta_kin )
  ;; household utility
  set total_utility_current_NBH utility_share_own_NBH + utility_kin_distance_own_NBH

  ]
end 

to selecting-movers
  let num_movers precision (( %_movers * count households ) / 100 ) 0
  ask min-n-of num_movers households [total_utility_current_NBH] [ set mover 1 ]
end 

to initialize
  ifelse (burning = "A")
  [
  ifelse (ticks < 150)
  [
    set beta_ethnic 1
    set beta_kin -1
  ]
  [
    set beta_ethnic beta_ethnic2
    set beta_kin beta_kin2
  ]
  ]
  [
  ifelse (ticks < 150)
  [
    set beta_ethnic 0
    set beta_kin -1
  ]
  [
    set beta_ethnic beta_ethnic2
    set beta_kin beta_kin2
  ]
  ]
end 

;#############################################################################



;############################  G O  #####################################

to go
  if (ticks = 300) [stop]
  initialize
  move-households
  resetting-mover-list
  current-NBH-utility
  selecting-movers
  calculate_index
 tick
end 

;#########################################################################

to move-households
  ifelse (All_move? = "yes")
  [
   ask households with [ mover = 1 ]
  [
    evalute_select_and_movingin_neighborhoods
  ]
  ]
  [
   ask one-of households with [ mover = 1 ]
  [
    evalute_select_and_movingin_neighborhoods
  ]
  ]
end 

to resetting-mover-list
  ask households [ set mover 0 ]
end 

to evalute_select_and_movingin_neighborhoods

  ;; creating a raw list of NBHS
  let candidates [who] of slots
  let mycolor [color] of self
  ;; calculating distance to each of NBHs candidates
  let my [who] of self

  ;; calculating b1 = ethnic share
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  let ethnic_share map [i -> prop_same_group i mycolor] candidates

  ;; calculating b2 = distance
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  let distance_to_slots2 map [i -> euclidean_distancia my i] candidates
  let distance_to_slots_normalized map [i -> normalize2 i ] distance_to_slots2

  ;; calculating b3 = kin distance
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  let mykin [kin] of self
  let mykins [who] of other households with [kin = mykin]
  let tempo2 []
  let temp3 n-values (length candidates) [i -> 0]

  foreach mykins
  [
    i -> let x i
    let pos position x mykins
    let distance_to_temp map [r -> euclidean_distancia x r] candidates
    set tempo2 temp3
    set temp3 []
    (foreach distance_to_temp tempo2 [ [a b] -> let suma (a + b) set temp3 lput suma temp3 ])
   ]

  let averg_kin_distance map [i -> i / (Kin_size - 1)] temp3
  let averg_kin_distance_normalized map [i -> normalize2 i ] averg_kin_distance

  ;; calculating utility
  ;;;;;;;;;;;;;;;;;;;;;;;
  let utility_share map [i -> i * beta_ethnic] ethnic_share
  ;; household distance
  let utility_distance map [i -> i * beta_distance] distance_to_slots_normalized
  ;; kin-distance
  let utility_kin_distance map [i -> i * beta_kin] averg_kin_distance_normalized
  let added_utility2 []
  (foreach utility_share utility_distance utility_kin_distance [ [a b c] -> let suma (a + b + c) set added_utility2 lput suma added_utility2 ])
  ;; Exp utility
  let added_utility map [i -> exp i ] added_utility2
  ;; Calculating probabilities
  let tot_utility sum added_utility
  let NBH_probabilities map [i -> i / tot_utility] added_utility
  ;; Joining final utilities and NBHs' ids
  let final_pool (map list candidates NBH_probabilities)

  ;; selecting and moving
  ;;;;;;;;;;;;;;;;;;;;;;;
  let origin_place patch-here
  let decision select_and_move my final_pool origin_place
end 


;; F U N C T I O N S
;;;;;;;;;;;;;;;;;;;;

to-report select_and_move [a b c]
 ask turtle a [
  if ( (length b) > 0 )
    [
    let chosen_NBH first rnd:weighted-one-of-list b [ [p] -> last p ]
    move-to slot chosen_NBH
    ask slot chosen_NBH [
      move-to c ]

  ]
  ]
  report []
end 

to-report prop_same_group [a mycolor]
   ask turtle a [
    let similar_nearby count (households-on neighbors) with [color = mycolor]
    let total_nearby count (households-on neighbors)
    ifelse (total_nearby > 0)    [set prop_neighborhood   (similar_nearby / total_nearby)] [ set prop_neighborhood 0]

    ]
  report prop_neighborhood
end 

to-report euclidean_distancia [my neighborhood]
   ask turtle my [
    set euclidean_distance distance turtle neighborhood
    ]
  report euclidean_distance
end 

to-report normalize2 [ current_distance ]
  let b precision ( current_distance / ( world_size / 2 )) 4
  report b
end 

to calculate_index
  let num_NBHs ((world_size + 1) / NBHsize_mXm) ^ 2
  let neig n-values num_NBHs [ ?1 -> ?1  + 1]
  let segre_by_n map [ ?1 -> abs (((count (households-on patches with [NBH_id = ?1]) with [ color = red ]) / (count households with [ color = red]) ) - ((count (households-on patches with [NBH_id = ?1]) with [ color = green ]) / (count households with [ color = green]) )) ] neig
  set index_of_dissimilarity sum segre_by_n / 2
end 

There is only one version of this model, created about 2 years ago by Eduardo Tapia.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.