⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ---russianmorbidity.nlogo

📁 NETLOGO
💻 NLOGO
📖 第 1 页 / 共 2 页
字号:
; breeds [race_one race_two]globals [timeTotal_Healthy Total_Normal Total_Unhealthy Total_Kids Total_AdultsPercent_Healthy Percent_Normal Percent_Unhealthy Percent_Kids      Total_Healthy_One Total_Normal_One Total_Unhealthy_OneTotal_Healthy_Two Total_Normal_Two Total_Unhealthy_TwoTotal_Healthy_Three Total_Normal_Three Total_Unhealthy_ThreePercent_Healthy_One Percent_Normal_One Percent_Unhealthy_OnePercent_Healthy_Two Percent_Normal_Two Percent_Unhealthy_TwoPercent_Healthy_Three Percent_Normal_Three Percent_Unhealthy_Threenumberdefault ; patch color defaultyoungshade oldshademean_age mean_expected_life mean_lifespanshock_all? shock_1? shock_2? shock_3? shock_4?region_1_healthy region_1_Normal region_1_unhealthy region_1_kids region_2_healthy region_2_Normal region_2_unhealthy region_2_kids region_3_healthy region_3_Normal region_3_unhealthy region_3_kids region_4_healthy region_4_Normal region_4_unhealthy region_4_kids region_1_total region_2_total region_3_total region_4_totalmean_expected_life1 mean_expected_life2 mean_expected_life3 mean_expected_life4mean_lifespan1 mean_lifespan2 mean_lifespan3 mean_lifespan4        ]      turtles-own [ agegenerationstatusincomerandom_deathExpected_Liferegion_idExp_Utility_HealthyExp_Utility_NormalExp_Utility_Unhealthy lifestyle          ]            patches-own [hood_lifespan death_total sum_death_age border? no_data? ]to setup  ca  set-default-shape turtles "med_circle"  set number ((density / 100) * count patches)  regions  ask random-n-of (number) patches with [border? = false]    [ sprout 1 [ set status 65 set color status set age random 60 set generation 1 ] ]  ask turtles [ ifelse age < 16 [set lifestyle 0][set lifestyle 2 set status 105 set color status] region-id]  set time 0  set shock_all? false set shock_1? false set shock_2? false set shock_3? false set shock_4? false     set mean_lifespan1 0 set mean_lifespan2 0 set mean_lifespan3 0 set mean_lifespan4 0endto regionsask patches [set border? falseif N-Regions = 2 [ if pycor = 0 [set pcolor 9.9999 set border? true]]if N-Regions = 3 [ if pycor = 0 or (pycor < 1 and pxcor = 0) [set pcolor 9.9999 set border? true]]if N-Regions = 4 [if pycor = 0 or pxcor = 0 [set pcolor 9.9999 set border? true]]            ]               endto go  set time time + 1  ask turtles [without-interruption [    wander    region-id    reproduce                                    ]]  ask patches [ update-patches ]  ask turtles [without-interruption [    kids-grow-old    Healthy-grow-old    Normal-grow-old    Unhealthy-grow-old                      ]]  do-plots  stats  regional_stats  regional-mean-life  shock  if count turtles = 0    [ stop ]endto region-id  if xcor > 0 and ycor > 0 [set region_id 1]  if xcor < 0 and ycor > 0 [set region_id 2]  if xcor < 0 and ycor < 0 [set region_id 3]  if xcor > 0 and ycor < 0 [set region_id 4]                     endto kids-grow-old  if lifestyle = 0 [  set age age + 1  ;;choose - shading or no shading  ;; set color scale-color status age oldshade youngshade  set color status  ;set expected_life mean values-from neighbors with [border? = false] [hood_lifespan]  ifelse (count neighbors with [border? = false and no_data? = false] > 0)          [set expected_life mean values-from neighbors with [border? = false and no_data? = false ] [hood_lifespan]]             [set expected_life def_life_exp]  set random_death random 1000  if ( Random_Death < (10 * Probability_Death_Kid + 1) )[ set death_total death_total + 1 set sum_death_age sum_death_age + age die]  if age = 16 [      choose-lifestyle     ifelse sum values-from neighbors [count turtles-here with [lifestyle > 0]] < count neighbors with [border? = false] [go-if-empty-nearby][go-if-empty]              ]                    ]endto Healthy-grow-old if lifestyle = 1 [  set age age + 1  ;;choose - shading or no shading  ;; set color scale-color status age oldshade youngshade  set color status  set random_death random 1000  if (age < 50) and ( Random_Death < 10 * Probability_Death_Healthy )[ set death_total death_total + 1 set sum_death_age sum_death_age + age die ]  if (age > 50) and (age < 90) and ( Random_Death < (20 + 10 * Probability_Death_Healthy) )[ set death_total death_total + 1 set sum_death_age sum_death_age + age die]  if (age = 90 or age > 90)          [ set death_total death_total + 1 set sum_death_age sum_death_age + age set pcolor default die ]  set expected_life mean values-from neighbors [hood_lifespan]                           ]endto Normal-grow-old if lifestyle = 2 [  set age age + 1  ;;choose - shading or no shading  ;; set color scale-color status age oldshade youngshade  set color status  set random_death random 1000  if (age < 50) and ( Random_Death < 10 * Probability_Death_Normal )[ set death_total death_total + 1 set sum_death_age sum_death_age + age die ]  if (age > 50) and (age < 90) and ( Random_Death < (20 + 10 * Probability_Death_Normal) )[ set death_total death_total + 1 set sum_death_age sum_death_age + age die ]  if (age = 90 or age > 90)          [ set death_total death_total + 1 set sum_death_age sum_death_age + age set pcolor default die ]                      ]endto Unhealthy-grow-old  if lifestyle = 3 [  set age age + 1  ;;choose - shading or no shading  ;; set color scale-color status age oldshade youngshade  set color status  set random_death random 1000  if (age < 50) and ( Random_Death < 10 * Probability_Death_Unhealthy )[ set death_total death_total + 1 set sum_death_age sum_death_age + age die ]  if (age > 50) and (age < 90) and ( Random_Death < (20 + 10 * Probability_Death_Unhealthy) )[ set death_total death_total + 1 set sum_death_age sum_death_age + age die ]  if (age = 90 or age > 90)          [ set death_total death_total + 1 set sum_death_age sum_death_age + age set pcolor default die ]                         ]endto wanderlocals [random_movement]set random_movement random 100if random_movement < movement [  go-if-empty                              ]endto reproduce   if (age > 16 and age < 45 and random 1000 < repro_rate) [    hatch 1 [          set age 0 set generation generation + 1 set lifestyle 0 set status 65          set color status        ;; ifelse sum values-from neighbors [count turtles-here] < 8 [go-if-empty-nearby][go-if-empty]            ]                                              ]endto go-if-empty  ;; turtle procedure  locals [empty-patches target]  without-interruption    [ set empty-patches patches with [not any? turtles-here and border? = false]      if any? empty-patches        [ set target random-one-of empty-patches          set heading towards target          fd distance target ]     region-id    ]endto go-if-empty-nearby  ;; turtle procedure  locals [empty-patches target]  without-interruption    [ set empty-patches neighbors with [not any? turtles-here and border? = false]      if any? empty-patches        [ set target random-one-of empty-patches          set heading towards target          fd distance target ]     region-id    ]endto choose-lifestyle;set Exp_Utility_Healthy (((Expected_Life ) * b_healthy ) + a_healthy);set Exp_Utility_Normal (((Expected_Life ) * b_normal ) + a_normal);set Exp_Utility_Unhealthy (((Expected_Life ) * b_unhealthy ) + a_unhealthy)ifelse discounting? = false     [ set Exp_Utility_Healthy (((Expected_Life - 16) *  b_healthy) + a_healthy)      set Exp_Utility_Normal (((Expected_Life - 16) * b_normal) + a_normal)       set Exp_Utility_Unhealthy (((Expected_Life - 16) * b_unhealthy) + a_unhealthy)    ]    [ set Exp_Utility_Healthy (a_healthy + ((b_healthy * (1 - exp(- rate * (Expected_Life - 16 )))) / (exp(rate) - 1)))      set Exp_Utility_Normal (a_normal + ((b_normal * (1 - exp(- rate * (Expected_Life - 16)))) / (exp(rate) - 1)))         set Exp_Utility_Unhealthy (a_unhealthy + ((b_unhealthy * (1 - exp(- rate * (Expected_Life - 16)))) / (exp(rate) - 1)))    ]ifelse (Exp_Utility_Healthy >= Exp_Utility_Normal) and (Exp_Utility_Healthy >= Exp_Utility_Unhealthy and Healthy_Option = true)       [set lifestyle 1 set status 89]       [ ifelse (Exp_Utility_Normal >= Exp_Utility_Unhealthy ) [set lifestyle 2 set status 105][ set lifestyle 3 set status 26]]    endto update-patchesset no_data? false ifelse death_total > 0 [set hood_lifespan (sum_death_age / death_total)] [set no_data? true set hood_lifespan mean_expected_life]endto shockif timedshock1 = true and time > 39 and time < 50 [set shock_1? true]if shock_all? [ ask random-n-of shock_size turtles               [ set shock_all? false set death_total death_total + 1 set sum_death_age sum_death_age + age set pcolor default die ]  ]if shock_1? [ ifelse N-regions = 2 or N-regions = 3 [ ask random-n-of shock_size turtles with [ycor > 0]              [ set shock_1? false set death_total death_total + 1 set sum_death_age sum_death_age + age set pcolor default die ]  ]                                                   [ ask random-n-of shock_size turtles with [ycor > 0 and xcor > 0]              [ set shock_1? false set death_total death_total + 1 set sum_death_age sum_death_age + age set pcolor default die ]  ]            ]if shock_2?  [ ifelse N-regions = 2 or N-regions = 3 [ ask random-n-of shock_size turtles with [ycor < 0]              [ set shock_2? false set death_total death_total + 1 set sum_death_age sum_death_age + age set pcolor default die ]  ]                                                    [ ask random-n-of shock_size turtles with [ycor > 0 and xcor < 0]              [ set shock_2? false set death_total death_total + 1 set sum_death_age sum_death_age + age set pcolor default die ]  ]            ]if shock_3?  [ ifelse N-regions = 3 [ ask random-n-of shock_size turtles with [ycor < 0 and xcor > 0]              [ set shock_3? false set death_total death_total + 1 set sum_death_age sum_death_age + age set pcolor default die ]  ]                                   [ ask random-n-of shock_size turtles with [ycor < 0 and xcor < 0]              [ set shock_3? false set death_total death_total + 1 set sum_death_age sum_death_age + age set pcolor default die ]  ]            ]if shock_4?  [ if N-regions = 4 [ ask random-n-of shock_size turtles with [ycor < 0 and xcor > 0]              [ set shock_4? false set death_total death_total + 1 set sum_death_age sum_death_age + age set pcolor default die ]  ]            ]                                                                       endto regional_statsset region_1_kids count turtles with [lifestyle = 0 and region_id = 1] set region_1_healthy count turtles with [lifestyle = 1 and region_id = 1]set region_1_Normal count turtles with [lifestyle = 2 and region_id = 1]set region_1_unhealthy count turtles with [lifestyle = 3 and region_id = 1]set mean_expected_life1 mean values-from turtles with [region_id = 1] [expected_life]set region_2_kids count turtles with [lifestyle = 0 and region_id = 2] set region_2_healthy count turtles with [lifestyle = 1 and region_id = 2]set region_2_Normal count turtles with [lifestyle = 2 and region_id = 2]set region_2_unhealthy count turtles with [lifestyle = 3 and region_id = 2]set mean_expected_life2 mean values-from turtles with [region_id = 2] [expected_life]set region_3_kids count turtles with [lifestyle = 0 and region_id = 3] set region_3_healthy count turtles with [lifestyle = 1 and region_id = 3]set region_3_Normal count turtles with [lifestyle = 2 and region_id = 3]set region_3_unhealthy count turtles with [lifestyle = 3 and region_id = 3]set mean_expected_life3 mean values-from turtles with [region_id = 3] [expected_life]set region_4_kids count turtles with [lifestyle = 0 and region_id = 4] set region_4_healthy count turtles with [lifestyle = 1 and region_id = 4]set region_4_Normal count turtles with [lifestyle = 2 and region_id = 4]set region_4_unhealthy count turtles with [lifestyle = 3 and region_id = 4]set mean_expected_life4 mean values-from turtles with [region_id = 4] [expected_life]set region_1_total count turtles with [region_id = 1]set region_2_total count turtles with [region_id = 2]set region_3_total count turtles with [region_id = 3]set region_4_total count turtles with [region_id = 4]endto regional-mean-lifeif time > 20 [set mean_lifespan1 (sum values-from patches with [pxcor > 0 and pycor > 0] [sum_death_age] / sum values-from patches with [pxcor > 0 and pycor > 0] [death_total])set mean_lifespan2 (sum values-from patches with [pxcor < 0 and pycor > 0] [sum_death_age] / sum values-from patches with [pxcor < 0 and pycor > 0] [death_total])set mean_lifespan3 (sum values-from patches with [pxcor < 0 and pycor < 0] [sum_death_age] / sum values-from patches with [pxcor < 0 and pycor < 0] [death_total])set mean_lifespan4 (sum values-from patches with [pxcor > 0 and pycor < 0] [sum_death_age] / sum values-from patches with [pxcor > 0 and pycor < 0] [death_total])]endto statsifelse time > 2 [set mean_age mean values-from turtles [age]set mean_expected_life mean values-from turtles [expected_life]            ] [set mean_expected_life def_life_exp]if time > 20 [set mean_lifespan (sum values-from patches [sum_death_age] / sum values-from patches [death_total])]              set Total_Healthy count turtles with [lifestyle = 1]set Total_Normal count turtles with [lifestyle = 2]set Total_Unhealthy count turtles with [lifestyle = 3]set Total_Kids count turtles with [lifestyle = 0]set Total_Adults count turtles with [lifestyle > 0]             set percent_kids (Total_Kids / count turtles) set percent_healthy (Total_healthy / Total_Adults)set percent_normal (Total_normal / Total_Adults) set percent_unhealthy (Total_unhealthy / Total_Adults)             endto do-plots   set-current-plot "Mean Lifespan and Expected Lifespan"      set-current-plot-pen "Mean Lifespan"      plot mean_lifespan      set-current-plot-pen "Expected Lifespan"      plot mean_expected_life  set-current-plot "Unhealthy"      set-current-plot-pen "Unhealthy 1"      plot region_1_unhealthy       set-current-plot-pen "Unhealthy 2"      plot region_2_unhealthy      set-current-plot-pen "Unhealthy 3"      plot region_3_unhealthy       set-current-plot-pen "Unhealthy 4"      plot region_4_unhealthy         end@#$#@#$#@GRAPHICS-WINDOW26110702472202010.51221200000CC-WINDOW5720887815Command CenterBUTTON8109343SetupsetupNIL1TOBSERVERTNILMONITOR981118260total populationcount turtles31BUTTON7449377Go/PausegoT1TOBSERVERNILNILSLIDER704227877260Probability_Death_HealthyProbability_Death_Healthy0251.00.11NILSLIDER780150113densitydensity01007011NILMONITOR1851124260NIL

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -