You take your health with you
Model was written in NetLogo 6.4.0
•
Viewed 28 times
•
Downloaded 0 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
breed [people person] breed [services service] services-own [ visits ; Tracks the number of people visiting the service ] people-own [ income ; Random for simplicity health ; Held constant home-patch ; Stores the patch that is the person's home last-relocation-tick ; Tracks the last tick on which the person relocated their home ] patches-own [ housing-cost ; Varies and may increase when services are nearby ] to setup clear-all setup-people setup-services setup-housing-costs setup-zones reset-ticks end to setup-people create-people num-people [ setxy random-xcor random-ycor set home-patch patch-here ; Sets the current patch as the person's home set income random-normal 1 0.5 ; Use a normal distribution for more variability ; Directly tie health to income ; This example assumes health should be in the range 0 to 1 and is linearly related to income set health min list 1 (max list 0 (income / 2)) set shape "person" set color scale-color grey health 0 1 ; Visualize health levels through color intensity set last-relocation-tick 0 ; Initialize to 0 indicating they haven't relocated yet ] ; Calculate median income after all people are created let median-income median [income] of people end to setup-services create-services num-services [ setxy random-xcor random-ycor set shape "house" set color red ] end ; Define two zones to setup-zones ask patches [ ifelse pxcor < 0 [ set pcolor blue ; Zone 1 ] [ set pcolor black ; Zone 2 ] ] end to setup-housing-costs ask patches [ set housing-cost 0.5 ; Initial housing cost, for simplicity ] end to go ask people [ try-move-home-closer ] relocate-services ; Check and potentially relocate services based on demand update-housing-costs ; Adjust housing costs based on defined criteria update_my_plots update-health-inequality-plot update-service-count-plots tick end ; Relocate services based on some criteria, e.g., demand and competition to relocate-services ask services [ ; Calculate the average income for each zone let avg-income-zone1 mean [income] of people with [pxcor < 0] let avg-income-zone2 mean [income] of people with [pxcor >= 0] ; Count the number of services in each zone let services-count-zone1 count services with [pxcor < 0] let services-count-zone2 count services with [pxcor >= 0] ; Determine the desirability of each zone based on income and competition ; This example uses a simple metric: average income minus a penalty for the number of services let desirability-zone1 (avg-income-zone1 - 0.1 * services-count-zone1) let desirability-zone2 (avg-income-zone2 - 0.1 * services-count-zone2) ; Choose the zone with higher desirability let target-zone ifelse-value (desirability-zone1 > desirability-zone2) [one-of patches with [pxcor < 0]] [one-of patches with [pxcor >= 0]] ; Move to the selected zone and reset visits move-to target-zone set visits 0 ] end ; People try to move closer to the service and consider affordability to try-move-home-closer ask people [ ; Check if it's time to try moving (e.g., every 10 ticks) if ticks mod 10 = 0 [ let my-income income let nearest-service min-one-of services [distance myself] let potential-new-homes patches in-radius 10 with [housing-cost < my-income and not any? people-here] let new-home min-one-of potential-new-homes [distance nearest-service] ; Move if a new home is found and it's closer to the nearest service if new-home != nobody and [distance new-home] of nearest-service < [distance myself] of nearest-service [ move-to new-home set home-patch new-home set last-relocation-tick ticks ] ] ] end to update-housing-costs ask patches [ ; Gather incomes of people within a certain radius let incomes [income] of turtles in-radius 10 with [breed = people] ; Calculate the mean income if there are any people within the radius if not empty? incomes [ let local-avg-income mean incomes ; Calculate service proximity for each patch, e.g., average distance to nearest service let nearest-service min-one-of services [distance myself] let service-proximity ifelse-value (nearest-service != nobody) [distance nearest-service] [max-pxcor + max-pycor] ; Fallback to a large distance if no service is found ; Adjust housing cost based on local average income and service proximity set housing-cost 0.5 + (0.05 * local-avg-income) - (0.01 * service-proximity) ; Ensure housing cost stays within bounds set housing-cost max list 0.1 (min list housing-cost 3.0) ] ] end to update_my_plots ; Update the Health Over Time plot set-current-plot "Population health over time" plot mean [health] of people end to update-service-count-plots ; Calculate the total number of services in each of the two zones let services-zone1 count services with [pxcor < 0] let services-zone2 count services with [pxcor >= 0] ; Ensure the correct plot is selected for updating set-current-plot "Services in each Zone" ; Update the plot for services in each zone set-current-plot-pen "Zone1" plot services-zone1 set-current-plot-pen "Zone2" plot services-zone2 end to update-health-inequality-plot ; Calculate average health for each zone let avg-health-zone1 mean [health] of people with [pxcor < 0] let avg-health-zone2 mean [health] of people with [pxcor >= 0] ; Update the plot set-current-plot "Health Inequality" set-current-plot-pen "Zone1" plot avg-health-zone1 set-current-plot-pen "Zone2" plot avg-health-zone2 end
There is only one version of this model, created about 1 month ago by Jonathan Stokes.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
You take your health with you.png | preview | Preview for 'You take your health with you' | about 1 month ago, by Jonathan Stokes | Download |
This model does not have any ancestors.
This model does not have any descendants.