-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreative_City_Final.nlogo
4819 lines (4561 loc) · 168 KB
/
Creative_City_Final.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
;; *************************************************** MODEL OF CREATIVE CLASS IN CITY ***********************************************************
globals [
mean-pop-count
high-dense-level
n-number
percent-educated ;; % of pop with college education; this value used for plot, calculated in brain-drain procedure
percent-educated-cr ;; % of creative with college education; value used for plot, calculated in brain-drain procedure
indexofgini
percent-poor
percent-middle
percent-rich
cr-space%
mean-rent-all
mean-income-all
median-income-all
mean-income-cr
]
turtles-own [
new ;; allows for turtles created as result of pop-growth rate to get attributes
hood-start ;; list of neighborhoods turtle belongs to based on turtle creation
afford-rent ;; can turtle afford rent as percentage of income yes (1) or no (0)
satisfied? ;; satisifed when they are not looking to move, can afford rent, and have similar neighbors of same color
content-w-neighbor;; content with similar ratio of neighbors desired yes (1) or no (0)
tol-var ;; tolerance range of variance, higher tolerance, more range, lower tolerance less range (tolerance / 2)
tolerance ;; percent of similar neighbors desired
sim-ratio ;; percent of similar neighbors nearby
similar-nearby ;; number of turtles with similar tolerance on neighboring patches (similar tolerance is +/- 5 points)
similar-here ;; number of turtles on same patch with similar tolerance
similar ;; total number of similar tolerance turtles here and on neibhors
other-nearby ;; number of turtles outside tolerance range on neighbor patches
other-here ;; number of turtles outside of tolerance range here
other-count ;; total number of turtles here and on neighbors outside tolerance range
total-nearby ;; total number of turtles here and on neighbors
creative ;; yes/no+
creative-h ;; highly creative yes/no
creative-m ;; medium creative yes/no
creative-l ;; low creative yes/no
celebrity-status ;; makes the most partnerships
income ;; gamma or bimodal distribution
income-start ;; income assigned at model start - can be used to see how much money made
current-rent ;; rent turtles pays at current tick
rent-% ;; calculation of rent from patch / income (percent of income that goes to rent)
rent-yr ;; calculation of rent per year
p-savings ;; placeholder - yes/no to invest to move or start business
educated ;; university degree yes/no
;; employment-status ;;student, employed, notworking
;; entrepreneurial ;;yes/no desire to start own business, tried to get funding, training
HighCreative? ;; If true, the person is considered to be high-creative
partnered? ;; If true, the person is paired with an investment or creative inspiration partner.
partner-timeshare ;; How long the person prefers to partner with investor/creative inspiration.
partner ;; The person paired up with for business venture or creative inspiration.
]
patches-own [
neighborhood ;; neighborhood region displayed
outside ;; not assigned a neighborhood
hood-list ;; list of neighborhoods overlapping
landuse ;; landuse value assigned ranges from 0-7
amenities ;; placeholder
pop-count ;; count of turtles on patch - used to classify patches as high-density residential
pop-dens ;; placeholder if wanted to specify density
occupancy-start ;; how many turtles were here at start
%full ;; % full based on pop-count compared to occupancy-start
rent-base ;; rent as assigned at model setup
rent-current ;; rent price for this patch at current time tick
creative-space ;; true/false
creative-value ;; sum of value adde by turtles with creativity visiting patch
creative-dens-p ;; the start-pop of creative people per patch
num-satisfied-cr ;; number of satisfied creative here
pop-count-cr ;; creative population counts use to assign creative value and creative space
pop-count-crt
pop-count-cr-h
pop-count-cr-m
pop-count-cr-ht
pop-count-cr-mt
pop-count-cr-n ;; new pop count used to decline in number of creatives visit
pop-count-cr-diff;; diff of count of creative pop to current count of creative pop if negative then gained value, otherwise decrease
pop-count-cr-minus;; factor to subtract for loss of creative value
]
;; ***** TO SET UP ************************************
to setup ;; Procedures that run when setup button is pressed
clear-all
setup-landuse
setup-rent
reset-ticks
create-people
setup-people
create-neighborhoods
setup-creative-space
check-affordability
setup-high-dense
check-similar-tolerance
update-variables
end
;; ***** DEFINE PATCH LANDUSE VALUES ************************************
;; average landuse for select city .....
to setup-landuse
ask patches [set landuse 0];; 0 undeveloped white 24%
ask n-of (1681 * 0.60) patches [set landuse 1] ;; 1 is residential light orange 31% ** this is where turtles can live
ask n-of (1681 * 0.1) patches [set landuse 2] ;; 2 is commercial yellow 6%
ask n-of (1681 * 0.1) patches [set landuse 3] ;; 3 is can't develop eg. airport etc gray 6%
;; landuse 4 place holder for high dense which is set up after creating initial people
ask n-of (1681 * 0.1) patches [set landuse 5] ;; 5 is water light blue 19%
ask n-of (1681 * 0.1) patches [set landuse 6] ;; 6 green areas 9%
end
;; ***** SETUP INITIAL RENTS ****************************
;; rents assigned to patches as a monthly rent (e.g. rent per time tick)
to setup-rent ;; rent is average monthly rent in units
ask patches
[set rent-base int random-normal avg-rent 10000 ;; assigns initial rent as normal distrubution around user specifed avg rent with variance of 10000 (Std Dev)
set rent-current rent-base]
end
;; ********CREATE INITIAL PEOPLE *******************************************************************
to create-people ;;used at set up only
create-turtles start-pop [set creative-l 1 set size 1 set new 1] ;; creates user-specified start-pop of turtles low creative
end
;; ******** ASSIGN ATTRIBUTES TO PEOPLE AND NEW POP GROWTH ********************
to setup-people
;; population growth rate
if ticks >= 1 [if pop-growth-rate < 0 [ask n-of ((count turtles * (abs pop-growth-rate / 100)) / 12) turtles [die]]] ;; population decline
if ticks >= 1 [create-turtles ((count turtles * (pop-growth-rate / 100)) / 12) [set creative 0 set creative-l 1 set size 1 set new 1] ] ;; create new turtles
;; assign attributes to new turtles
;; assign education
ask n-of (count turtles with [new = 1 ] * (%educated / 100)) turtles with [new = 1] [set educated 1]
;; move turtles to residential patch and assign neighborhood
ask turtles with [new = 1]
[move-to one-of patches with [landuse = 1 or landuse = 4]
set hood-start [neighborhood] of patch-here]
if ticks >= 1 [if allow-development = false
[ask turtles with [new = 1 and hood-start = 0]
[move-to one-of patches with [(landuse = 1 or landuse = 4) and outside = 0]
set hood-start [neighborhood] of patch-here]]]
;; assign income as gamma curve
if income-dist = "gamma"
[let income-diff (top10% - percapita)
let income-avg ((top10% + 9 * percapita) / 10) ;;weighted average
let income-variance ((income-diff * income-diff) / 2)
let alpha ((percapita * percapita) / income-variance)
let lambda (1 / (income-variance / income-avg))
ask turtles with [new = 1] [ set income-start int random-gamma (alpha * 2.5) (lambda * 2) set income income-start]
ask turtles with [income-start < 1] [set income-start 1 set income income-start]]
;; assign income as bimodal curve
if income-dist = "bi-modal"
[ask turtles with [new = 1] [set income-start int random-normal percapita 20000 set income income-start]
ask n-of (count turtles with [new = 1] * .1) turtles with [new = 1] [set income-start int random-normal top10% 20000 set income income-start]
ask turtles with [income-start <= 1] [set income-start 1 set income income-start]]
ask turtles with [educated = 1] [set income income * 1.0083] ;; turtles with education earn 1% more income each year
set percent-poor (count turtles with [income <= (median-income-all * .75)] / (count turtles) * 100)
set percent-middle (count turtles with [income > (median-income-all * .75) and income <= (median-income-all * 4)] / (count turtles) * 100)
set percent-rich (count turtles with [income > (median-income-all * 4)] / (count turtles) * 100)
;; assign rents to turtles
ask turtles with [new = 1]
[set current-rent [rent-current] of patch-here
set rent-yr ([rent-current] of patch-here)
set rent-% (rent-yr / income) * 100 ;; percentange of income that goes to rent
ifelse rent-% >= rent%-of-income [set afford-rent 0] [set afford-rent 1] ] ;; if rent/yr for this patch less than income, poverty threshold then afford
;; assign creativity (assume creatives have a little more income, but high creatives have much more)
ask n-of (count turtles with [new = 1] / 10) turtles with [new = 1] ;; 10% of pop is medium creative people
[set creative 1 set creative-m 1 set creative-h 0 set creative-l 0 set income (income * 1.02)]
ask n-of (count turtles with [new = 1] * (%PopHighCreative / 100)) turtles with [new = 1];; user specifies percent high creative - % of high creative assigned below
[set creative 1 set creative-h 1 set creative-l 0 set creative-m 0 set income (income * 1.03)]
;; assign attributes that affect behavior
ask turtles with [new = 1]
[set partnered? false
set partner nobody ]
;; assign tolerance
ask turtles with [new = 1] ;; assigns initial tolerance to new turtles as normal dist around mean
[set tolerance int random-normal tolerance-for-others 10]
;; adds noise to model, ask 10% to be random tolerance
ask n-of (count turtles with [new = 1] * .1) turtles with [new = 1] [set tolerance random 100]
ask turtles with [new = 1]
[set tol-var (tolerance * .25) ] ;; set similar range as weights tolerance by taking variance and multiplying by use specified tolerance
;; makes the turtles not new anymore
ask turtles [set new 0]
;; used for monitor plots on interface
set mean-income-all (mean [income] of turtles)
set median-income-all (median [income] of turtles)
set mean-income-cr (mean [income] of turtles with [creative = 1])
end
;; ***** CREATE NEIGHBORHOODS *******************
to create-neighborhoods ;; create neighborhoods as 7 random circles
ask patches [set hood-list list (50) (50)] ;;created list with 50 as 2 last items in list
repeat 7
[set n-number n-number + 1 ;; iteration so can add name to neighborhood and add name
ask n-of 1 patches
[let p self
let a max list 7 round (random-normal 7 (1 * 7))
ask patches with [distance p <= a]
[set neighborhood n-number
set hood-list fput neighborhood hood-list ;; a patch can be part of overlapping neighborhoods
ask turtles-here with [hood-start = 0] [set hood-start n-number set color (orange + hood-start)] ] ;;for some strange reason removing the set color from here ruins the display
]]
ask patches with [neighborhood = 0] [set outside 1 set hood-list fput neighborhood hood-list]
ask turtles with [hood-start = 0]
[move-to one-of patches with [(landuse = 1 or landuse = 4) and neighborhood != 0]
set hood-start [neighborhood] of patch-here]
end
;; ***** SET UP CREATIVE SPACE *******************
to setup-creative-space ;; create creative space to start based on density of creatives present, assigns creative value, bumps up rent on creative-space
ask patches [
set pop-count count turtles-here
set pop-count-cr-h count turtles-here with [creative-h = 1] ;; count high creative on patch
set pop-count-cr-m count turtles-here with [creative-m = 1] ;; count medium creative
set pop-count-cr count turtles-here with [creative = 1] ;; count of creative people same as (pop-count-cr-h + pop-count-cr-m)
set creative-dens-p creative-dens ;; user defines start-pop of creatives per patch used to define creative space (default is 3)
;;creates initial creative spaces when enough creative tutrles and not in an outside area (e.g. not in a neighbhorhood)
;;assigns rent as double cost and assigns creative value of 10 for high creative, and 5 for medium creative
if pop-count-cr >= creative-dens-p
[if allow-development = true [set creative-space 1 set rent-base (rent-base * 2) set creative-value ((pop-count-cr-h * 10) + (pop-count-cr-m * 5))]
if allow-development = false and outside = 0 [set creative-space 1 set rent-base (rent-base * 2) set creative-value ((pop-count-cr-h * 10) + (pop-count-cr-m * 5))] ]
]
end
;; ***** SET UP HIGH DENSE RESIDENTIAL LANDUSE = 4 *******************
to setup-high-dense
;; assign occupancy value
ask patches [set occupancy-start pop-count]
set mean-pop-count (mean [pop-count] of patches with [outside = 0]) ;;set mean as pop-density of city
set high-dense-level int (mean-pop-count * 4)
ask patches with [pop-count > 4] [set landuse 4] ;; set landuse as high dense residential (landuse = 4) density is 5x of average
end
;; *******GO PROCEDURES *******************************************************************
to go ;; Procedures that run when go button is pressed
setup-people ;;to create new people from pop-growth rate
brain-drain ;; educated leave
update-cr-land-value
check-partner ;; CONTROLS TURTLE INTERACTION AND SPREADS CREATIVITY - high creative turtles get larger after inspring others, comment out to check just schelling segregation rules
check-affordability
check-similar-tolerance
move-unsatisfied
update-variables
tick
end
;; ********* BRAIN-DRAIN **************
to brain-drain ;; some educated or creative turtles disappear or appear based on user-specified percent
;; if losing smart people
if ticks > 1 [
if %brain-drain > 0 ;; convert smart or creative people to low creative and uneducated
[ask n-of (count turtles with [educated = 1 or creative = 1] * (%brain-drain / 100) / 12) turtles with [educated = 1 or creative = 1]
[set educated 0 set creative 0 set creative-h 0 set creative-m 0 set creative-l 1 set income income-start] ] ;; brain-drain expressed as changing turtle from educated or creative to non-educated or non-creative
;; if gaining smart people
if %brain-drain < 0;; when no pop growth, but neg brain-drain converts existing population to creative based on percent of existing educated
[if (count turtles with [educated = 1] * ((abs %brain-drain / 100) / 12) > count turtles with [educated = 0])
[ask n-of (count turtles with [educated = 1] * ((abs %brain-drain / 100) / 12)) turtles with [educated = 0]
[set educated 1 set new 1 set income (income * 1.5) ;;increases income
if creative = 1
[ask n-of (count turtles with [new = 1] / 20) turtles with [new = 1] [set creative-m 1 set creative 1 set new 0];; ask 10% of new brainy people to be medium creative
ask n-of (count turtles with [new = 1] * ((count turtles with [creative-h = 1] / count turtles) / 100)) turtles with [new = 1]
[set creative-h 1 set creative 1 set new 0] ;;creates new high creatives based on current % of high creatives
]
set new 0 ]
]
]
]
set percent-educated count turtles with [educated = 1] / (count turtles) * 100 ;; used for plots
set percent-educated-cr count turtles with [educated = 1 and creative = 1] / (count turtles) * 100 ;; used for plots
end
;; ************ SEGREGATION / TOLERANCE OF OTHER (BY COLOR OF TURTLE DISPLAYED) ***************
to check-similar-tolerance ;;checks color of neighbors and then tolerance for similiarity
ask turtles
[
set similar-nearby count (turtles-on neighbors ) with [(tolerance >= ([tolerance] of myself) - tol-var ) or (tolerance < ([tolerance] of myself) + tol-var ) ] ;; set similar nearby when other turtles are within -/+ 5 points of your own tolerance
set similar-here count (turtles-on patch-here ) with [(tolerance >= ([tolerance] of myself) - tol-var ) or (tolerance < ([tolerance] of myself) + tol-var ) ] ;; set similar nearby when other turtles are within -/+ 5 points of your own tolerance
set similar (similar-nearby + similar-here)
set other-nearby count (turtles-on neighbors) with [(tolerance < ([tolerance] of myself) - tol-var ) or (tolerance > ([tolerance] of myself) + tol-var ) ]
set other-here count (turtles-on patch-here ) with [(tolerance < ([tolerance] of myself) - tol-var ) or (tolerance > ([tolerance] of myself) + tol-var ) ] ;; set similar nearby when other turtles are within -/+ 5 points of your own tolerance
set other-count (other-nearby + other-here)
set total-nearby (similar + other-count)
if total-nearby <= 0 [set total-nearby 1]
set sim-ratio ((similar / total-nearby) * 100)
]
;; turtle is content when the ratio of turtles on its patch and neighbor patches of similar tolerance range matches or is better than its threshold for tolerance
;; note: turtles will stop moving when they can afford rent (and if segregation is on then they also must be content with their neighbors)
ask turtles ;; if the similar neighbors ratio is at min range of your tolerance level as range based on diff from turtle tol and user-specifed-avg (allows ability to make pop more/less tol at each tick)
[ifelse (sim-ratio <= (tolerance * ((100 + tolerance-for-others) / 100))) ;; minimum threshold to be content
[set content-w-neighbor 1 ] [set content-w-neighbor 0]
]
end
;; ********* STOP WHEN SATISFIED TURTLES AND TO TELL UNSATISFIED TURTLES TO MOVE *************
to move-unsatisfied ;; turtles move randomly around landscape trying to find a place to be satisfied
;; note: turtles will stop moving when they can afford rent (and if segregation is on then -- they also must be content with their neighbors)
if segregation = true ;; turtle is satisfied when can afford rent and it's content with neighbors or has high tolerance
[ask turtles with [(afford-rent = 1 and content-w-neighbor = 1)]
[set satisfied? 1]]
if segregation = false
[ask turtles with [afford-rent = 1] ;;if can afford rent and satisifed, stop
[set satisfied? 1]]
ask turtles with [afford-rent = 0] ;; if you can't afford rent you are not satisfied
[set satisfied? 0]
ask turtles with [satisfied? != 1] [move] ;; if you are not satisfied, then move
end
to move
if restrict-movement-to-neighborhood = true ;;if restrict movement is on, move to patch within neighborhood.
[rt random-float 360 ;;turn right
ifelse member? hood-start hood-list ;; check to see if neighborhood of turtle is in patch list of neighborhoods that overlap that patch
[fd random-float 1] ;; move forward if patch is in neighbhorhood list
;;move to nearest patch in neighborhood if current patch is not part of the original neighborhood list
[let numb hood-start move-to min-one-of patches with [member? numb hood-list] [distance myself]]]
if restrict-movement-to-neighborhood = false
[rt random-float 360 fd random-float 1 ] ;;if no restriction is on, keep moving
end
;;ASSIGN creative VALUE FOR HIGH CREATIVE AREAS******************
;; ********** Turtle Interaction with patches *****************
;; add value - if a high-creative turtle lands on high creative patch it add value of 10 to patch, medium turtles add 5
;; change color - if creative value is 50 it changes to darker color, when creative-value >= 100 then color is black
;; spread creative patches - when a patch has creative value 100 or more, its neighbor4 patches change to landuse=7 and magenta
;; however won't change landuse and color of those that are landuse canton, transit, water
to update-cr-land-value
ask patches
[set pop-count (count turtles-here) ;; update pop density each time for all patches
set pop-count-cr (count turtles-here with [creative = 1]) ;; count creative turtles on patch
if pop-count-cr >= creative-dens and allow-development = false and outside = 1 [set creative-space 1]
;; if # of creative turtles matches threshold, make it a creative space
set num-satisfied-cr count turtles-here with [creative = 1 and satisfied? = 1] ;; count satisfied creative turtles
set pop-count-cr-m count turtles-here with [creative-m = 1] ;; count creative turtles of medium on this patch at this time
set pop-count-cr-h count turtles-here with [creative-h = 1] ;; count creative turtles of medium on this patch at this time
;; counter to subtract value for every 5 ticks no creative visit
if pop-count-cr = 0 [set pop-count-cr-diff pop-count-cr-diff + 1] ;; if no creative turtles visit, add one to counter called diff
if ticks > 1 and pop-count-cr-diff > 3 [set pop-count-cr-minus (pop-count-cr-minus + 1) set pop-count-cr-diff 0] ;;after 3 mos. no creative visit, add to minus counter, reset diff to zero
if creative-space = 1 ;; for creative patches calculate value
[
set pop-count-cr-ht (pop-count-cr-ht + (count turtles-here with [creative-h = 1])) ;; count tally of high creative visits over time
set pop-count-cr-mt (pop-count-cr-mt + (count turtles-here with [creative-m = 1])) ;; count tally of medium creative visits over time
set pop-count-crt (pop-count-cr-mt + pop-count-cr-ht)
] ;; count total creative turtles visits over time
;; need to work on this section
ifelse num-satisfied-cr = pop-count-cr [set creative-value creative-value] ;; calculate creative value: each high creative 10, medium 5; subtract the count for minus
[set creative-value ((pop-count-cr-ht * 10) + (pop-count-cr-mt * 5) - (pop-count-cr-minus * 100))]
set creative-value (creative-value * (pop-count-cr / creative-dens))
if creative-value <= 1 [set creative-space 0 set creative-value 0]
if creative-value > 1 and creative-value < 50 [set creative-space 1]
if creative-value >= 50 and creative-value < 100 [set rent-current (rent-base * 1.05)]
if creative-value >= 100 [set rent-current (rent-base * 1.1)]
if creative-value >= 300 [set rent-current (rent-base * 1.5)]
if creative-value >= 500
[set creative-value 500 set rent-current (rent-base * 2)
ask neighbors [ifelse allow-development = true
[if (creative-space != 1) [set creative-space 1]]
[ if (creative-space != 1 and outside != 1 and landuse != 4 and landuse != 5 and landuse != 3) [set creative-space 1 ]]] ;;change neighbors4 to creative space.
]
set cr-space% (count patches with [creative-space > 0] / 1681) * 100
]
end
;; ******** INTERACTION BETWEEN TURTLES **********
;; PEOPLE INSPIRE AND INVEST IN OTHERS
to check-partner ;; all turtles can partner if not partnered, look to couple, inspire, and uncouple
ask turtles
[if not partnered? and (random-float 10.0 < 2) [find-partner]
inspire
uncouple]
end
;; probability of if two red meet in a creative patch they are most likely to create something
;; if red and blue interact probabliity is lower
;; if green and red match (if green is high risk taking (and high inome and ....) then maybe coud be come blue
to find-partner ;; and to change and sprout
let potential-partner one-of (turtles-at -1 0) with [not partnered?] ;; ask turtles at or near space if partnered then checks parameters for partnering
if potential-partner != nobody
;; if turtle is creative-h 1 and
[ if random-float 10.0 < 2 ;;[intro-extro-tend] of potential-partner ;; consider removing???????? based on percentages ....to allow partner/change etc
[ set partner potential-partner
set partnered? true
ask partner [ set partnered? true ]
ask partner [ set partner myself ]
move-to patch-here ;; move to center of patch
move-to patch-here ;; partner moves to center of patch
]
]
end
;;
to inspire ;; to raise creativiy level of individuals
if creative-h = 1 and partnered? ;;if 2 high creatives meet in area of creative-space they increase income
[if [creative-h] of partner = 1 and [creative-value] of patch-here >= 500 [set income (income * 1.05) set celebrity-status (celebrity-status + 1)] ;; those that partner a lot become "celebrity"
if celebrity-status > 2 [set size 2] ];;those that are partnering most get bigger for visual
if creative-m = 1 and partnered? ;; if medium creative partners with high creative, on area of amenities then it becomes a high creative and gains a little income
[if [creative-m] of partner = 1 and [creative-value] of patch-here >= 500 [set creative 1 set creative-h 1 set creative-m 0 set income (income * 1.02)]]
if creative-m = 1 and partnered? ;; if medium creative partners with high creative, on area of amenities then it becomes a high creative and gains a little income
[if [creative-h] of partner = 1 and [creative-value] of patch-here >= 300 [set creative 1 set creative-h 1 set creative-m 0 set income (income * 1.02)]]
if creative-l = 1 and partnered? ;; if low creative partners with high creative, on area of amenities then it gets bigger
[if [creative-m] of partner = 1 and [creative-value] of patch-here > 100 [set creative 1 set creative-m 1 set creative-l 0 set income (income * 1.02)]]
if creative-l = 1 and partnered? ;; if low creative partners with high creative, on area of amenities then it gets bigger
[if [creative-h] of partner = 1 and [creative-space] of patch-here = 1 [set creative 1 set creative-m 1 set creative-l 0 set income (income * 1.02)]]
end
;; placeholder probability of starting business
to start-business
end
to uncouple ;; turtle procedure
if partnered?
[ set partnered? false
ask partner [ set partner-timeshare 0 ]
ask partner [ set partner nobody ]
ask partner [ set partnered? false ]
set partner nobody ]
end
;; *********** CHECK affordability and occupancy and update rent *************
to check-affordability
;;rent increases 1% each year note that currently only turtles with education gain 1% income each year, turtles that partner also gain income
ask patches [
if ticks >= 1 [set rent-current (rent-current * 1.0083) set rent-base (rent-base * 1.0083)]
]
ask turtles
[if [landuse] of patch-here = 1
[if allow-development = false
[if [outside] of patch-here = 1 [set afford-rent 0]]]
if allow-development = true
[set current-rent [rent-current] of patch-here
set rent-yr ([rent-current] of patch-here * 1)
ifelse rent-yr > income [set rent-% 100] [set rent-% (rent-yr / income) * 100]
ifelse rent-% > 40 [set afford-rent 0] [set afford-rent 1]
] ;; if rent/yr for this patch less than income, poverty threshold then afford
]
ask turtles with [creative = 1] ;; creatives don't have the same poverty threshold to account for their preference to be there (e.g. willing to pay a little higher)
[if [creative-space] of patch-here = 1
[if (([rent-current] of patch-here * 1) < income) [set afford-rent 1]
]
]
end
;; *********** UPDATE VARIABLES *************
to update-variables
check-display
plot-histograms
end
to check-display
;; to update-Display and turtles colors
ask patches
[if _Display = "none" [set pcolor gray + 3]
if _Display = "Landuse"
[if landuse = 0 [set pcolor white] ;; undeveloped
if landuse = 1 [set pcolor orange + 4] ;; residential
if landuse = 2 [set pcolor yellow + 3] ;; commercial
if landuse = 3 [set pcolor gray + 2] ;; off-limits
if landuse = 4 [set pcolor orange + 2] ;; high dense residential
if landuse = 5 [set pcolor 109] ;; water
if landuse = 6 [set pcolor green + 3] ];; green space
if _Display = "Neighborhoods"
[set pcolor neighborhood + 1.5
if neighborhood = 0 [set pcolor white]] ;; gray scale
if _Display = "Rents"
[ set mean-rent-all (mean [rent-current] of patches)
if rent-current <= (mean-rent-all * .9) [set pcolor 75 + 4] ;; below average rent
if rent-current >= (mean-rent-all * .9) [set pcolor 75 + 2] ;; average rent
if rent-current >= (mean-rent-all * 1.5) [set pcolor 75 - 2] ] ;; really above avg and highest rent
if _Display = "creative potential"
[ if creative-space = 0 [set pcolor gray + 3]
if creative-space = 1 [set pcolor 129]]
]
;; show creative spaces
if show-creative-space = true
[ask patches
[ if creative-value > 0 and creative-value < 50 [set pcolor 126] ;; set creative-space 1] ;;color patch based on value
if creative-value >= 50 and creative-value < 100 [set pcolor 125] ;; set rent (rent * 1.05)] ;; pink = pos
if creative-value >= 100 [set pcolor 124]
if creative-value >= 300 [set pcolor 123]
if creative-value >= 500 [set pcolor 121]
]]
;; to update turtles color
ask turtles
[ ifelse _Turtle_color = "hide" [set hidden? true] [set hidden? false]
if _Turtle_color = "black" [set color black]
if _Turtle_color = "by Neighborhood" [set color (orange + hood-start - 1)]
if _Turtle_color = "afford rent" [ifelse afford-rent = 1 [set color red] [set color black]]
if _Turtle_color = "Creative"
[if creative-h = 1 [set color magenta]
if creative-m = 1 [set color magenta + 2]
if creative-l = 1 [set color green - 2]]
if _Turtle_color = "Income"
[if income < (percapita * .9) [set color black + 2]
if income >= (percapita * .9) and income <= (percapita * 1.1) [set color blue]
if income > (percapita * 1.1) and (income <= 75000) [set color blue]
if income > 75000 and income < (top10% * .8) [set color red]
if income >= (top10% * .8) and income < (top10% * 1.2) [set color red]
if income >= (top10% * 1.2) [set color red]]
if _Turtle_color = "Tolerance" ;; for trying to see whether the new tolerance thing works
[if tolerance >= (tolerance-for-others + (tolerance-for-others * .25)) [set color blue] ;; more tolerant
if tolerance <= (tolerance-for-others + (tolerance-for-others * .25)) [set color green] ;; average tolerance
if tolerance <= (tolerance-for-others - (tolerance-for-others * .25)) [set color red] ] ;; low tolerance
if _Turtle_color = "Content" ;; for trying to see whether the new tolerance thing works
[ ifelse content-w-neighbor = 1 [set color green - 2] [set color red + 2]]
]
end
to plot-histograms
set-current-plot "Lorenz Curve"
clear-plot
set-current-plot-pen "Equal" ;; draw a straight line from lower left to upper right
plot 0
plot 100
set-current-plot-pen "Lorenz"
set-plot-pen-interval 100 / count turtles
plot 0
let SortedWealths sort [Income] of turtles
let TotalWealth sum SortedWealths
let WealthSumSoFar 0
let GiniIndex 0
let GiniIndexReserve 0
repeat count turtles [
set WealthSumSoFar (WealthSumSoFar + item GiniIndex SortedWealths)
plot (WealthSumSoFar / TotalWealth) * 100
set GiniIndex (GiniIndex + 1)
set GiniIndexReserve GiniIndexReserve + (GiniIndex / count turtles) - (WealthSumSoFar / TotalWealth)]
;; plot GiniIndex
;; set-current-plot "Gini Index"
set IndexOfGini ((GiniIndexReserve / count turtles) / 0.5)
;; plot (GiniIndexReserve / count turtles) / 0.5
set-current-plot "Income Distribution"
set-current-plot-pen "Income-dist"
if income-dist = "gamma" [set-histogram-num-bars 500]
if income-dist = "bi-modal" [set-histogram-num-bars 100]
histogram [income] of turtles
set-current-plot-pen "Income-cr"
if income-dist = "gamma" [set-histogram-num-bars 500]
if income-dist = "bi-modal" [set-histogram-num-bars 100]
histogram [income] of turtles with [creative = 1]
set-current-plot "Rent Distribution"
set-current-plot-pen "Creative"
set-histogram-num-bars 100
histogram [rent-current] of patches with [creative-space = 1]
set-current-plot-pen "Overall"
set-histogram-num-bars 1000
histogram [rent-base] of patches
set-current-plot "tol-var"
set-current-plot-pen "tol-var"
set-histogram-num-bars 100
histogram [tol-var] of turtles
set-current-plot "Tolerance"
set-current-plot-pen "tolerance-for-others"
set-histogram-num-bars 100
histogram [tolerance] of turtles
set-current-plot "nearby"
set-current-plot-pen "sim-nearby"
set-histogram-num-bars 100
histogram [sim-ratio] of turtles
end
; Copyright 1997 Uri Wilensky.
; See Info tab for full copyright and license.
@#$#@#$#@
GRAPHICS-WINDOW
246
12
683
470
20
20
10.415
1
10
1
1
1
0
0
0
1
-20
20
-20
20
1
1
1
months
20.0
SLIDER
4
45
242
78
start-pop
start-pop
1200
6000
1780
10
1
NIL
HORIZONTAL
SLIDER
3
350
241
383
tolerance-for-others
tolerance-for-others
0
100
49
1
1
%
HORIZONTAL
BUTTON
4
10
84
43
setup
setup
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
85
10
165
43
go
go
T
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
SLIDER
4
80
242
113
%PopHighCreative
%PopHighCreative
0
50
15
1
1
NIL
HORIZONTAL
MONITOR
893
486
969
531
% Unsatisfied
count turtles with ([satisfied? = 0]) / (count turtles) * 100
2
1
11
MONITOR
687
13
789
58
Gross City Income
sum [income] of turtles
0
1
11
SLIDER
4
114
242
147
Creative-dens
Creative-dens
1
10
3
1
1
NIL
HORIZONTAL
PLOT
688
59
890
179
Income Distribution
Income
No.
0.0
1000000.0
0.0
10.0
true
false
"" ""
PENS
"Income-dist" 1.0 1 -16777216 true "" ""
"income-cr" 1.0 1 -5825686 true "" ""
SWITCH
3
315
241
348
segregation
segregation
1
1
-1000
SLIDER
1
502
241
535
avg-rent
avg-rent
6000
350000
6000
1000
1
annual
HORIZONTAL
MONITOR
1291
386
1387
431
% Similar Nearby
sum [similar-nearby] of turtles / sum [total-nearby] of turtles * 100
2
1
11
MONITOR
789
13
862
58
Per Capita
mean [income] of turtles
0
1
11
MONITOR
864
13
950
58
Median Income
median [income] of turtles
0
1
11
TEXTBOX
4
384
181
409
Annual Income (Rs.)
12
0.0
1
SLIDER
1
434
115
467
top10%
top10%
100000
900000
254000
1000
1
NIL
HORIZONTAL
SLIDER
1
399
115
432
percapita
percapita
0
350000
42000
1000
1
NIL
HORIZONTAL
SLIDER
3
268
242
301
%brain-drain
%brain-drain
-10
30
0
.5
1
%yr
HORIZONTAL
SLIDER
4
182
242
215
pop-growth-rate
pop-growth-rate
-10
10
0
.1
1
%yr
HORIZONTAL
MONITOR
952
13
1018
58
Population
count turtles
0
1
11
SLIDER
3
233
242
266
%educated
%educated
0
100
50
1
1
college
HORIZONTAL
PLOT
689
425
891
545
Brain Drain
Time
%
0.0
10.0
0.0
1.0
true
true
"" ""
PENS
"Educated" 1.0 0 -12895429 true "" "plot percent-educated"
"Educ-Cr" 1.0 0 -5825686 true "" "plot percent-educated-cr"
MONITOR
893
438
963
483
% Educated