forked from niloofar-jebelli/UrbanDynamics
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Land_Market_6_1.nlogo
1821 lines (1656 loc) · 62.2 KB
/
Land_Market_6_1.nlogo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
extensions [array table gis csv]
globals
[
;reporters
mean-white-saving ;average developer saving
mean-yellow-saving ;average developer saving
mean-orange-saving ;average developer saving
mean-violet-saving ;average developer saving
mean-gray-saving ;average developer saving
mean-professional-saving ;average professionals saving
mean-nonprofessional-saving ;average non-professionals saving
mean-professional-housing ;average professionals housing
mean-nonprofessional-housing ;average non-professionals housing
innercity-professional ;number of inner-city professionals
innercity-nonprofessional ;number of inner-city non-professionals
suburbia-professional ;number of suburbia professionals
suburbia-nonprofessional ;number of suburbia non-professionals
white-noi ;developer NOI
yellow-noi ;developer NOI
orange-noi ;developer NOI
violet-noi ;developer NOI
gray-noi ;developer NOI
; gentrified_population ;number of agents that have been gentrified
sprawl_population ;number of agents that have been sprawled
emigration_population ;number of agents that have been removed signifiying out-migration
urban_growth_population ;number of agents that have been added to the model
; ESRI related variables
themap
neighborhoods-dataset
zones-dataset ;ESRI
studyarea-dataset
]
turtles-own ;using Jackson's gentrification model
[
;developer ;if true the agent is either yellow, violet, white, orange and gray
;professional ;if true the person is green, red or blue (economic class)
;non-professional ;if true the person is green, red or blue (economic class)
tID ; agent turtle ID
budget ;69% of annual income is annual budget, using Devisch agent decision-making
ttype ; dev;pro;nonpro
income ;average annual of 75628
housing ;28% of budget is housing (based on a 14868 annual housing cost)
saving ;every agent's income-budget
lowerbound ;mean - std of income distribution
upperbound ;mean + std of income distribution
;A-age ;random between 0 and 85
happy? ;happy if neighboring same color and class agents >= 10%
pID ;it is the patch ID that this turtle resides
similar-color ;neighbors with similar colors
similar-income ;neighbors with similar incomes
NOI ;Net Operating Income of a project (NOI = Value * Cap Rate)
near-CBD ;preference to be near CBD
low-rent ;preference to pay lower rent
]
patches-own[
ID ;each patches ID related to a neighborhood, patch ID is identical with polygon ID_ID, using Yang Zhou's Segregation model
properties
occupied? ;if it is occupied by a turtle
density ;number of agents in one area
zID ;each patches ID related to a zone
nID ;neighborhood ID
p-age ;property age up to 100 years old (using 0.04 lambda for property decay)
psize ;property size as square footage
ptype ;property type (C.condo/coop, S.detached/attached single family houses)
price ;overall value of the property for selling and buying
PR ;potential rent that arrived from the price factor using 32.03 price-to-rent ratio for DC
CR ;capitalized rent
;NR ;neighborhood rent
Rent-gap ;RG based on Neil Smith's CR and PR
;vacancy-rate ;vacant properties divided by total properties
]
to setup
clear-all
random-seed 47820 ;random seed to make the experiments consistent when testing different parameters
; set gentrified_population 0 ;initialize reporters
set sprawl_population 0 ;initialize reporters
set emigration_population 0 ;initialize reporters
load_data ;load map information and patch data
setup-properties ;initialize properties of each patch (house)
setup-patches ;initialize properties of each patch (house)
setup-developer ;initialize developers properties
setup-professional 1.0 ;add (1.0 * initial_population) number of professional agents
setup-nonprofessional 1.0 ;add (1.0 * initial_population) number of non-professional agents
update-turtles ;update agent properties
reset-ticks
end
to go
if all? turtles [ happy? ] [ stop ] ;if all agents are happy, stop the program. Schelling's segregation model by Uri Wilensky
emigration ; run emigration model in each iteration
;;; <<<calculate the density of each patch>>> ;;;
let max_nID (max [nID] of patches with [zID > 30]) + 1
let density_list array:from-list n-values max_nID [0]
foreach n-values max_nID [ ?1 -> ?1 ] [ ?1 ->
let number_of_turtles count turtles-on patches with [nID = ?1]
let dens (number_of_turtles / (count patches with [nID = ?1]))
array:set density_list ?1 dens
]
;;; <<<calculate the density of each patch>>> ;;;
sprawl density_list ;pass density of each patch to see if we need sprawl
move-turtles ;move agents based on their preferences
developer-buy ;developers buy vacant places based on their saving
update-turtles ;update turtles properties
;;; <<< update the housing price based on density and CR >>> ;;;
ask patches with [zID > 30][
set density array:item density_list nID
set p-age p-age + 1
set CR (PR * exp (-0.04 * min (list 100 p-age)))
set Rent-gap ((PR - CR) / PR)
set price (price-change-by-density density) * (CR * 12 * 32.02) ; more dense area have higher prices
]
;;; <<< update the housing price based on density and CR >>> ;;;
get-info
;;; <<< urban growth every 15 years >>> ;;;
;if ticks != 0 and (remainder ticks 15) = 0
;changed to one year rate
setup-professional ug_rate / 15
setup-nonprofessional ug_rate / 15
;;; <<< gentrification by demand every 15 years >>> ;;;
; if ticks != 0 and (remainder ticks 15) = 0 [
; gen_demand
; ]
export-patches-vals
export-turtles-vals
tick
end
;;; load the map from shape file
to load_data
set neighborhoods-dataset gis:load-dataset "data/Neighborhoods.shp"
set zones-dataset gis:load-dataset "data/Zones.shp"
set studyarea-dataset gis:load-dataset "data/StudyArea.shp"
gis:set-world-envelope gis:envelope-of studyarea-dataset
gis:set-drawing-color white
gis:draw neighborhoods-dataset 1
gis:draw zones-dataset 1
gis:apply-coverage zones-dataset "BUFF_DIST" zID
gis:apply-coverage neighborhoods-dataset "INPUT_FID" nID
;print gis:property-names zones-dataset
end
;;; for each patch (house), set a specific size, price, and PR
to setup-properties ;using Smith's rent gap theory (capitalized & potential rent and decay factor)
ask patches with [zID = 60] [set ptype "C" ;inner-city condo/coop
set psize random-normal 926.96 31.26
set price random-normal 492867 14715.43
set PR (1.0 * price / (12 * 32.02))] ; bid rent theory (1.0)
ask patches with [zID = 90] [set ptype "S" ;suburban dettached/attached single family house
set psize random-normal 1650.40 504.14
set price random-normal 769387 201379.80
set PR (0.95 * price / (12 * 32.02))] ; bid rent theory (0.95)
ask patches with [zID > 30] [set p-age random 100
set CR (PR * exp (-0.04 * p-age)) ;decline of CR through time. (Diappi and Bolchi model)
set Rent-gap ((PR - CR) / PR)
]
end
;;; for each patch (house), set their color to defaul and make the vacant
to setup-patches
(foreach (sort patches) (n-values count patches [ ?1 -> ?1 ]) [ [?1 ?2] ->
ask ?1 [ set id ?2 ]
])
ask patches with [ ptype = "C" or ptype = "S"] [set pcolor 3]
ask patches with [ zID = 30] [set pcolor black]
ask patches with [ID >= 0] [set occupied? false]
end
;;; setup properties of each developer
to setup-developer
crt 1 [set color yellow set ttype "dev" set ID who]
crt 1 [set color violet set ttype "dev" set ID who]
crt 1 [set color white set ttype "dev" set ID who]
crt 1 [set color orange set ttype "dev" set ID who]
crt 1 [set color gray set ttype "dev" set ID who]
ask turtles with [ttype = "dev"] [
set tID who
set shape "person"
set size 5
set happy? true
set income random-normal 5000000 4000000 ;assuming developers have an initial income between 1 million and 10 million
while [income < 0] [set income random-normal 5000000 4000000]
set saving income
set budget (income * 0.69)
set NOI 0
]
ask turtles with [ttype = "dev"] [move-to one-of patches with [zID = 30]]
end
;;; add and setup properties of professionals
to setup-professional [rate]
; for each color (red, green, blue), we create initial_population/2 agents for professionals
crt round (rate * initial_population / 2) [ ; half the initial_population is professional and half of them are non-professional
set tID who
set ttype "pro"
set color green
set happy? false
set lowerbound 117086
set upperbound 158542
set income random-normal 137814 20728
set budget (income * 0.69)
set housing (budget * 0.28)
set saving (income - budget)
set shape "person"
set size 5
let CBD-interest random 100 ;setting the near-CBD preference
ifelse CBD-interest > 30 ;if number is more than 30% then the agent has a preference to be near CBD, if less than 30%, the agent doesn't prefer that
[set near-CBD 1]
[set near-CBD 0]
let low-rent-perc random 100 ;setting the near-CBD preference
ifelse low-rent-perc < 30 ;if number is more than 30% then the agent has a preference to pay low rent, if less than 30%, the agent doesn't prefer that
[set low-rent 1]
[set low-rent 0]
let target one-of patches with [zID > 30 and occupied? = false]
let moved-price [price] of target
move-to target
;if this patch is already developed by a developer, add the price to its saving
ask patch-here[
set occupied? true
if pcolor != 3 [ask turtles with [color = pcolor] [set saving (saving + moved-price)]]
]
set housing (housing - moved-price)
set pID [ID] of patch-here
]
crt round (rate * initial_population / 2) [
set tID who
set color red
set ttype "pro"
set happy? false
set lowerbound 117086
set upperbound 158542
set income random-normal 137814 20728
set budget (income * 0.69)
set housing (budget * 0.28)
set saving (income - budget)
set shape "person"
set size 5
let CBD-interest random 100 ;setting the near-CBD preference
ifelse CBD-interest > 30 ;if number is more than 30% then the agent has a preference to be near CBD, if less than 30%, the agent doesn't prefer that
[set near-CBD 1]
[set near-CBD 0]
let low-rent-perc random 100 ;setting the near-CBD preference
ifelse low-rent-perc < 30 ;if number is more than 30% then the agent has a preference to pay low rent, if less than 30%, the agent doesn't prefer that
[set low-rent 1]
[set low-rent 0]
let target one-of patches with [zID > 30 and occupied? = false]
let moved-price [price] of target
move-to target
;if this patch is already developed by a developer, add the price to its saving
ask patch-here[
set occupied? true
if pcolor != 3 [ask turtles with [color = pcolor] [set saving (saving + moved-price)]]
]
set housing (housing - moved-price)
set pID [ID] of patch-here
]
crt round (rate * initial_population / 2) [
set tID who
set color blue
set ttype "pro"
set happy? false
set lowerbound 117086
set upperbound 158542
set income random-normal 137814 20728
set budget (income * 0.69)
set housing (budget * 0.28)
set saving (income - budget)
set shape "person"
set size 5
let CBD-interest random 100 ;setting the near-CBD preference
ifelse CBD-interest > 30 ;if number is more than 30% then the agent has a preference to be near CBD, if less than 30%, the agent doesn't prefer that
[set near-CBD 1]
[set near-CBD 0]
let low-rent-perc random 100 ;setting the near-CBD preference
ifelse low-rent-perc < 30 ;if number is more than 30% then the agent has a preference to pay low rent, if less than 30%, the agent doesn't prefer that
[set low-rent 1]
[set low-rent 0]
let target one-of patches with [zID > 30 and occupied? = false]
let moved-price [price] of target
move-to target
;if this patch is already developed by a developer, add the price to its saving
ask patch-here[
set occupied? true
if pcolor != 3 [ask turtles with [color = pcolor] [set saving (saving + moved-price)]]
]
set housing (housing - moved-price)
set pID [ID] of patch-here
]
end
;;; add and setup properties of professionals
to setup-nonprofessional [rate]
; for each color (red, green, blue), we create initial_population/2 agents for non-professionals
crt round (rate * initial_population / 2) [
set tID who
set color red
set ttype "nonpro"
set lowerbound 31876
set upperbound 53752
set income random-normal 42814 10938
set budget (income * 0.69)
set housing (budget * 0.28)
set saving (income - budget)
set shape "person"
set size 5
let CBD-interest random 100 ;setting the near-CBD preference
ifelse CBD-interest > 30 ;if number is more than 30% then the agent has a preference to be near CBD, if less than 30%, the agent doesn't prefer that
[set near-CBD 1]
[set near-CBD 0]
let low-rent-perc random 100 ;setting the near-CBD preference
ifelse low-rent-perc < 30 ;if number is more than 30% then the agent has a preference to pay low rent, if less than 30%, the agent doesn't prefer that
[set low-rent 1]
[set low-rent 0]
let target one-of patches with [zID > 30 and occupied? = false]
let moved-price [price] of target
move-to target
;if this patch is already developed by a developer, add the price to its saving
ask patch-here[
set occupied? true
if pcolor != 3 [ask turtles with [color = pcolor] [set saving (saving + moved-price)]]
]
set housing (housing - moved-price)
set pID [ID] of patch-here
]
crt round (rate * initial_population / 2) [
set tID who
set color green
set ttype "nonpro"
set lowerbound 31876
set upperbound 53752
set income random-normal 42814 10938
set budget (income * 0.69)
set housing (budget * 0.28)
set saving (income - budget)
set shape "person"
set size 5
let CBD-interest random 100 ;setting the near-CBD preference
ifelse CBD-interest > 30 ;if number is more than 30% then the agent has a preference to be near CBD, if less than 30%, the agent doesn't prefer that
[set near-CBD 1]
[set near-CBD 0]
let low-rent-perc random 100 ;setting the near-CBD preference
ifelse low-rent-perc < 30 ;if number is more than 30% then the agent has a preference to pay low rent, if less than 30%, the agent doesn't prefer that
[set low-rent 1]
[set low-rent 0]
let target one-of patches with [zID > 30 and occupied? = false]
let moved-price [price] of target
move-to target
;if this patch is already developed by a developer, add the price to its saving
ask patch-here[
set occupied? true
if pcolor != 3 [ask turtles with [color = pcolor] [set saving (saving + moved-price)]]
]
set housing (housing - moved-price)
set pID [ID] of patch-here
]
crt round (rate * initial_population / 2) [
set tID who
set color blue
set ttype "nonpro"
set lowerbound 31876
set upperbound 53752
set income random-normal 42814 10938
set budget (income * 0.69)
set housing (budget * 0.28)
set saving (income - budget)
set shape "person"
set size 5
let CBD-interest random 100 ;setting the near-CBD preference
ifelse CBD-interest > 30 ;if number is more than 30% then the agent has a preference to be near CBD, if less than 30%, the agent doesn't prefer that
[set near-CBD 1]
[set near-CBD 0]
let low-rent-perc random 100 ;setting the near-CBD preference
ifelse low-rent-perc < 30 ;if number is more than 30% then the agent has a preference to pay low rent, if less than 30%, the agent doesn't prefer that
[set low-rent 1]
[set low-rent 0]
let target one-of patches with [zID > 30 and occupied? = false]
let moved-price [price] of target
move-to target
;if this patch is already developed by a developer, add the price to its saving
ask patch-here[
set occupied? true
if pcolor != 3 [ask turtles with [color = pcolor] [set saving (saving + moved-price)]]
]
set housing (housing - moved-price)
set pID [ID] of patch-here
]
end
;to gen_demand
; let sorted_turtles sort-on [income] turtles with [zID = 90] ;sort the agents in suburbia based on their income
;let sublist_sorted_turtles sublist sorted_turtles 0 round (gen_rate * count turtles with [zID = 90]) ;select the lowest income agent based on gen_rate
;set gentrified_population gentrified_population + (round (gen_rate * count turtles with [zID = 90])) ;update the reporter for the number of gentrified agents
;;; <<< start moving low income agents to inner-city >>> ;;;
;foreach sublist_sorted_turtles[
; ask ?1 [
; let turtle-saving housing
; let target one-of patches with [zID = 60 and occupied? = false and price < turtle-saving]
;if target != nobody [
; ask patch-here[set occupied? false]
;move-to target
;let moved-price [price] of target
;if this patch is already developed by a developer, add the price to its saving
;ask patch-here [
; set occupied? true
;if pcolor != 3 [ask turtles with [color = pcolor] [set saving (saving + moved-price)]]
;]
;set pID [ID] of patch-here
;set housing (housing - moved-price) ;developer sell
;]
;]
;]
;end
to sprawl [density_list]
foreach n-values (array:length density_list) [ ?1 -> ?1 ][ ?1 ->
let patch_density array:item density_list ?1
if patch_density > sprawl_density_threshold[ ;if density of a specific patch is greater than the threshold, we have to move them
let turtles_in_patch turtles-on patches with [nID = ?1]
let number_turtles_in_patch count turtles_in_patch
let sprawl_count round (sprawl_moving_rate * number_turtles_in_patch) ; update the number of sprawled agents
set sprawl_population sprawl_population + sprawl_count
;;; <<< start moving turtles >>> ;;;
ask n-of sprawl_count turtles_in_patch[
let turtle-saving housing
let turtle-size [psize] of patch-here
; agents should move to a place that is vacant, its price is lower than their saving, it's less crowded, and the property size is greater than their current place
let current-CR ([PR] of patch-here * exp (-0.04 * min (list 100 [p-age] of patch-here))) ; capping the age of a building to 100
let current-price (price-change-by-density [density] of patch-here) * (current-CR * 12 * 32.02) ; more dense area have higher prices
let current-nID [nID] of patch-here
let target one-of patches with [occupied? = false and zID > 30 and price < (turtle-saving + current-price) and density < patch_density and psize > turtle-size]
if target != nobody [
ask patch-here [set occupied? false]
move-to target
let moved-price [price] of target
;if this patch is already developed by a developer, add the price to its saving
ask patch-here [
set occupied? true
if pcolor != 3 [ask turtles with [color = pcolor] [set saving (saving + moved-price)]]
]
set pID [ID] of patch-here
; selling price + agent's saving
set housing (current-price + housing - moved-price) ;developer sell
; we need to set the pcolor of this house to 3 showing that an agent lives in this house and is not controlled by developers anymore
set pcolor 3
]
]
]
]
end
to emigration
let dying_count round (emigration_rate * count turtles with [zID > 30]) ;randomly remove agents from the model based on emigration-rate
set emigration_population emigration_population + dying_count
ask n-of dying_count turtles with [zID > 30] [
ask patch-here [set occupied? false]
die ;RIP
]
end
to-report price-change-by-density [dens] ;implement the "f(d) = 1+d" function
report exp(1 + dens) ; exponential growth for the price according to density
end
; find the developer that is most frequent in a specific nID
to-report max-developer [current-nID]
let dev-colors array:from-list (list yellow white violet gray orange)
let yellow-patches count patches with [nID = current-nID and pcolor = yellow]
let white-patches count patches with [nID = current-nID and pcolor = white]
let violet-patches count patches with [nID = current-nID and pcolor = violet]
let gray-patches count patches with [nID = current-nID and pcolor = gray]
let orange-patches count patches with [nID = current-nID and pcolor = orange]
let max-dev max (list yellow-patches white-patches violet-patches gray-patches orange-patches)
let max-item-index position max-dev (list yellow-patches white-patches violet-patches gray-patches orange-patches)
report array:item dev-colors max-item-index
end
to move-turtles ;using Yang Zhou's segregation model
ask turtles with [color = green or color = red or color = blue] [
if happy? = false [
let turtle-saving housing
; getting current price of the house based on property age (p-age), PR, CR
let current-CR ([PR] of patch-here * exp (-0.04 * min (list 100 [p-age] of patch-here))) ; capping the age of a building to 100
let current-price (price-change-by-density [density] of patch-here) * (current-CR * 12 * 32.02) ; more dense area have higher prices
let current-nID [nID] of patch-here
if near-CBD = 1 [
ifelse low-rent = 1 [
let target item 0 sort-on [price] patches with [occupied? = false and zID = 60]
; selling the property managed by current-price of the house added to the saving of the agent
if target != nobody and [price] of target < (turtle-saving + current-price) [
; start buying
ask patch-here [set occupied? false]
move-to target
let moved-price [price] of target
;if this patch is already developed by a developer, add the price to its saving
ask patch-here [
set occupied? true
; if the patch that agent is moving has already been developed, add the price to the saving of the developer
; else add the price of the house to the most frequent developer in this nID
if pcolor != 3 [ask turtles with [color = pcolor] [set saving (saving + moved-price)]]
;[ask turtles with [color = (max-developer current-nID)] [set saving (saving + moved-price)]]
]
set pID [ID] of patch-here
; selling price + agent's saving
set housing (current-price + housing - moved-price) ;developer sell
; we need to set the pcolor of this house to 3 showing that an agent lives in this house and is not controlled by developers anymore
set pcolor 3
]
]
[
let target one-of patches with [occupied? = false and zID = 60 and price < turtle-saving + current-price ]
if target != nobody [
ask patch-here [set occupied? false]
move-to target
let moved-price [price] of target
;if this patch is already developed by a developer, add the price to its saving
ask patch-here [
set occupied? true
if pcolor != 3 [ask turtles with [color = pcolor] [set saving (saving + moved-price)]]
;[ask turtles with [color = (max-developer current-nID)] [set saving (saving + moved-price)]]
]
set pID [ID] of patch-here
; selling price + agent's saving
set housing (current-price + housing - moved-price) ;developer sell
set pcolor 3
]
]
]
if near-CBD = 0 [
ifelse low-rent = 1 [
let target item 0 sort-on [price] patches with [occupied? = false and zID > 30]
if target != nobody and [price] of target < turtle-saving + current-price [
; start buying
ask patch-here [set occupied? false]
move-to target
let moved-price [price] of target
;if this patch is already developed by a developer, add the price to its saving
ask patch-here [
set occupied? true
if pcolor != 3 [ask turtles with [color = pcolor] [set saving (saving + moved-price)]]
;[ask turtles with [color = (max-developer current-nID)] [set saving (saving + moved-price)]]
]
set pID [ID] of patch-here
; selling price + agent's saving
set housing (current-price + housing - moved-price) ;developer sell
set pcolor 3
]
]
[
let target one-of patches with [occupied? = false and zID > 30 and price < turtle-saving + current-price ]
if target != nobody [
ask patch-here [set occupied? false]
move-to target
let moved-price [price] of target
;if this patch is already developed by a developer, add the price to its saving
ask patch-here [
set occupied? true
if pcolor != 3 [ask turtles with [color = pcolor] [set saving (saving + moved-price)]]
;[ask turtles with [color = (max-developer current-nID)] [set saving (saving + moved-price)]]
]
set pID [ID] of patch-here
; selling price + agent's saving
set housing (current-price + housing - moved-price) ;developer sell
set pcolor 3
]
]
]
]
]
end
;;; update properties of each agent after one run
to update-turtles ;using Benenson's CA model, deciding based on economic status
ask turtles [
set saving (income - budget + saving)
set housing (housing + budget * 0.28)
] ;increasing the saving and housing every year
ask turtles with [color = green or color = red or color = blue]
[
let current-pID pID
let current-patch-nID [nID] of patch-here
;let num-neighbors count patches with [nID = current-patch-nID]
let neighbors-in-nID patches with [nID = current-patch-nID]
let num-neighbors count turtles-on neighbors-in-nID
set similar-color count (turtles-on neighbors-in-nID) with [ color = [ color ] of myself ]
;set similar-income count (turtles-on neighbors-in-nID) with [ income <= [lowerbound] of myself and income >= [upperbound] of myself and housing > 0]
set similar-income count (turtles-on neighbors-in-nID) with [ ttype = [ttype] of myself and housing > 0]
;show (word "patch ID: " current-pID " patch nID: " current-patch-nID " num neighbors: " num-neighbors " similar-color: " similar-color " similar-income: " similar-income)
set happy? (housing > 0) and (similar-color / num-neighbors > 0.5 or similar-income / num-neighbors > 0.5) ; happy if housing is greater than 0, meaning the agent is not under debt
]
end
;;; developers buy vacant places randomly based on their current saving
to developer-buy
let vacant patches with [occupied? = false and zID > 30 and zID <= 90 and pcolor = 3 and p-age > 60]
let sorted-vacant sort-on [(- Rent-gap)] vacant
let developers turtles with [ttype = "dev"]
foreach sorted-vacant[ ?1 ->
let vacant-price [price] of ?1
let vacant-id [ID] of ?1
let vacant-age [p-age] of ?1
let vacant-PR [PR] of ?1
let target one-of developers with [saving > vacant-price]
if target != nobody[
ask target[
set saving saving - vacant-price
let dv-color color
ask one-of patches with [ID = vacant-id] [set pcolor dv-color
set p-age 0
]
set NOI NOI + ((vacant-PR * 12 * 32.02) * Cap-Rate / 100) ; 32.02 is the price-to-rent ratio
]
]
]
end
;;;; <<< REPORTERS SECTION >>> ;;;;
to-report developer-reporter-white
let list-white-saving []
ask turtles with [color = white][set list-white-saving lput saving list-white-saving]
set mean-white-saving mean list-white-saving
report mean-white-saving
end
to-report developer-reporter-yellow
let list-yellow-saving []
ask turtles with [color = yellow][set list-yellow-saving lput saving list-yellow-saving]
set mean-yellow-saving mean list-yellow-saving
report mean-yellow-saving
end
to-report developer-reporter-orange
let list-orange-saving []
ask turtles with [color = orange][set list-orange-saving lput saving list-orange-saving]
set mean-orange-saving mean list-orange-saving
report mean-orange-saving
end
to-report developer-reporter-violet
let list-violet-saving []
ask turtles with [color = violet][set list-violet-saving lput saving list-violet-saving]
set mean-violet-saving mean list-violet-saving
report mean-violet-saving
end
to-report developer-reporter-gray
let list-gray-saving []
ask turtles with [color = gray][set list-gray-saving lput saving list-gray-saving]
set mean-gray-saving mean list-gray-saving
report mean-gray-saving
end
to-report nonprofessional-housing-reporter
;nonprofessional
let list-nonprofessional-housing []
ask turtles with [lowerbound = 31876 and upperbound = 53752][set list-nonprofessional-housing lput housing list-nonprofessional-housing]
set mean-nonprofessional-housing mean list-nonprofessional-housing
report mean-nonprofessional-housing
end
to-report professional-housing-reporter
;professional
let list-professional-housing []
ask turtles with [lowerbound = 117086 and upperbound = 158542][set list-professional-housing lput housing list-professional-housing]
set mean-professional-housing mean list-professional-housing
report mean-professional-housing
end
to-report professional-saving-reporter
;professional
let list-professional-saving []
ask turtles with [lowerbound = 117086 and upperbound = 158542][set list-professional-saving lput saving list-professional-saving]
set mean-professional-saving mean list-professional-saving
report mean-professional-saving
end
to-report nonprofessional-saving-reporter
;nonprofessional
let list-nonprofessional-saving []
ask turtles with [lowerbound = 31876 and upperbound = 53752][set list-nonprofessional-saving lput saving list-nonprofessional-saving]
set mean-nonprofessional-saving mean list-nonprofessional-saving
report mean-nonprofessional-saving
end
to-report innercity-professional-reporter
set innercity-professional count turtles with [lowerbound = 117086 and upperbound = 158542 and zID = 60]
report innercity-professional
end
to-report innercity-nonprofessional-reporter
set innercity-nonprofessional count turtles with [lowerbound = 31876 and upperbound = 53752 and zID = 60]
report innercity-nonprofessional
end
to-report suburbia-professional-reporter
set suburbia-professional count turtles with [lowerbound = 117086 and upperbound = 158542 and zID = 90]
report suburbia-professional
end
to-report suburbia-nonprofessional-reporter
set suburbia-nonprofessional count turtles with [lowerbound = 31876 and upperbound = 53752 and zID = 90]
report suburbia-nonprofessional
end
to-report white-developer-noi-reporter
set white-noi sum [NOI] of turtles with [color = white]
report white-noi
end
to-report yellow-developer-noi-reporter
set yellow-noi sum [NOI] of turtles with [color = yellow]
report yellow-noi
end
to-report orange-developer-noi-reporter
set orange-noi sum [NOI] of turtles with [color = orange]
report orange-noi
end
to-report violet-developer-noi-reporter
set violet-noi sum [NOI] of turtles with [color = violet]
report violet-noi
end
to-report gray-developer-noi-reporter
set gray-noi sum [NOI] of turtles with [color = gray]
report gray-noi
end
to-report ug-population-reporter
set urban_growth_population 3 * count turtles with [color = green]
report urban_growth_population
end
;to-report gentrified-population-reporter
; report gentrified_population
;end
to-report sprawl-population-reporter
report sprawl_population
end
to-report emigration-population-reporter
report emigration_population
end
to get-info
;developer saving
let list-white-saving []
let list-yellow-saving []
let list-orange-saving []
let list-violet-saving []
let list-gray-saving []
ask turtles with [color = white][set list-white-saving lput log saving 10 list-white-saving]
ask turtles with [color = yellow][set list-yellow-saving lput log saving 10 list-yellow-saving]
ask turtles with [color = orange][set list-orange-saving lput log saving 10 list-orange-saving]
ask turtles with [color = violet][set list-violet-saving lput log saving 10 list-violet-saving]
ask turtles with [color = gray][set list-gray-saving lput log saving 10 list-gray-saving]
;set mean-white-saving mean list-white-saving
;set mean-yellow-saving mean list-yellow-saving
;set mean-orange-saving mean list-orange-saving
;set mean-violet-saving mean list-violet-saving
;set mean-gray-saving mean list-gray-saving
set mean-white-saving 0
set mean-yellow-saving 0
set mean-orange-saving 0
set mean-violet-saving 0
set mean-gray-saving 0
;professional
let list-professional-saving []
ask turtles with [lowerbound = 117086 and upperbound = 158542][set list-professional-saving lput saving list-professional-saving]
set mean-professional-saving mean list-professional-saving
;nonprofessional
let list-nonprofessional-saving []
ask turtles with [lowerbound = 31876 and upperbound = 53752][set list-nonprofessional-saving lput saving list-nonprofessional-saving]
set mean-nonprofessional-saving mean list-nonprofessional-saving
;number of professionals and nonprofessionals in inner city
set innercity-professional count turtles with [lowerbound = 117086 and upperbound = 158542 and zID = 60]
set innercity-nonprofessional count turtles with [lowerbound = 31876 and upperbound = 53752 and zID = 60]
;number of professionals and nonprofessionals in suburbia
set suburbia-professional count turtles with [lowerbound = 117086 and upperbound = 158542 and zID = 90]
set suburbia-nonprofessional count turtles with [lowerbound = 31876 and upperbound = 53752 and zID = 90]
;developer NOIs
set white-noi sum [NOI] of turtles with [color = white]
set yellow-noi sum [NOI] of turtles with [color = yellow]
set orange-noi sum [NOI] of turtles with [color = orange]
set violet-noi sum [NOI] of turtles with [color = violet]
set gray-noi sum [NOI] of turtles with [color = gray]
set urban_growth_population 3 * count turtles with [color = green]
end
to-report get-turtle-attributes ;turtle proc
report (list ticks tID budget ttype income housing saving lowerbound upperbound happy? pID similar-color similar-income NOI near-CBD low-rent)
end
to-report get-patches-attributes ;turtle proc
report (list ticks ID properties occupied? density zID nID p-age psize ptype price PR CR Rent-gap pcolor)
end
to export-turtles-vals ;turtle proc
ask turtles [
file-open "turtles.csv"
file-print csv:to-row get-turtle-attributes
file-close
]
end
to export-patches-vals ;turtle proc
;ask patches with [occupied? = true]
ask patches [
file-open "patches.csv"
file-print csv:to-row get-patches-attributes
file-close
]
end
to output [basepath]
let interface-filename (word basepath "interface_ip-" initial_population "_ug-" ug_rate "_cr-" Cap-Rate "_gr-" gen_rate "_sdt-" sprawl_density_threshold "_smr-" sprawl_moving_rate "_sr-" emigration_rate "_" date-and-time ".png")
let world-filename (word basepath "world_ip-" initial_population "_ug-" ug_rate "_cr-" Cap-Rate "_gr-" gen_rate "_sdt-" sprawl_density_threshold "_smr-" sprawl_moving_rate "_sr-" emigration_rate "_" date-and-time ".png")
export-interface interface-filename
export-view world-filename
end
to output-time [basepath tick-time]
let interface-filename (word basepath "time_" tick-time "_interface_ip-" initial_population "_ug-" ug_rate "_cr-" Cap-Rate "_gr-" gen_rate "_sdt-" sprawl_density_threshold "_smr-" sprawl_moving_rate "_sr-" emigration_rate "_" date-and-time ".png")
let world-filename (word basepath "time_" tick-time "_world_ip-" initial_population "_ug-" ug_rate "_cr-" Cap-Rate "_gr-" gen_rate "_sdt-" sprawl_density_threshold "_smr-" sprawl_moving_rate "_sr-" emigration_rate "_" date-and-time ".png")
export-interface interface-filename
export-view world-filename
end
@#$#@#$#@
GRAPHICS-WINDOW
279
13
689
424
-1
-1
2.0
1
10
1
1
1
0
1
1
1
-100
100
-100
100
0
0
1
ticks
30.0
BUTTON
14
30
78
63
Setup
setup
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
100
32
163
65
Go
go
T
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
170
34
245
67
go once
go
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
SLIDER
22
143
194
176
Cap-Rate
Cap-Rate
4.75
7.75
7.5
0.25
1
NIL
HORIZONTAL
MONITOR
23
82
155
127
Developed Properties
count patches with [pcolor = yellow or pcolor = orange or pcolor = violet or pcolor = gray or pcolor = white]
17
1
11
PLOT
730
13
990
147
Developer Av. Saving
Years
Saving
0.0
30.0
0.0
10.0
true
true
"" ""
PENS
"White" 1.0 0 -16777216 true "" "plot mean-white-saving"
"Yellow" 1.0 0 -1184463 true "" "plot mean-yellow-saving"
"Orange" 1.0 0 -955883 true "" "plot mean-orange-saving"