-
Notifications
You must be signed in to change notification settings - Fork 2
/
TUNAMI-EVAC1.nlogo
1674 lines (1509 loc) · 42.3 KB
/
TUNAMI-EVAC1.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 [gis pathdir vid]
__includes [ "Rayleigh2011.nls" "Astar2011.nls"]
;;***********************************************************************************************
;; DECLARING VARIABLES
;;***********************************************************************************************
;; GLOBAL VARIABLES
;; September 2012
;; This is an example of the model TUNAMI-EVAC1 developed by Erick Mas on Sep. 2012.
;; This model was developed on a NetLogo version 4.x, it may not run on newer versions
;; Contact the author for the latest update version: [email protected]
;;
;; July 2020
;; Updated to work in NetLogo 6.1.1
;;
;; April 2022
;; Verified working in NetLogo 6.2.2
globals [ land-patches
urban-patches
sea-patches
street-patches
exit-patches
teb-patches
teb-capacity
exit-capacity
scale
tsu-counter
tsunami-file-name
Cmax-ped
Cmax-car
decided-kids
decided-teens
decided-adults
decided-elders
decided-cars
safe-kids
safe-teens
safe-adults
safe-elders
safe-cars
casualty-kids
casualty-teens
casualty-adults
casualty-elders
casualty-cars
pop-kids
pop-teens
pop-adults
pop-elders
pop-cars
]
breed [ kids kid ]
breed [ teens teen ]
breed [ adults adult ]
breed [ elders elder ]
breed [ cars car]
kids-own [ dim speed handicap stage path ini goal L heuri td ]
teens-own [ dim speed handicap stage path ini goal L heuri td ]
adults-own [ dim speed handicap stage path ini goal L heuri td ]
elders-own [ dim speed handicap stage path ini goal L heuri td ]
cars-own [ dim speed handicap stage path ini goal L heuri td ]
patches-own [ zt ]
;;************************************************************************************************
;; INITIAL CONDITIONS
;;************************************************************************************************ SETUP
to setup
;; (for this model to work with NetLogo's new plotting features,
;; __clear-all-and-reset-ticks should be replaced with clear-all at
;; the beginning of your setup procedure and reset-ticks at the end
;; of the procedure.)
__clear-all-and-reset-ticks
set-initial-values
load-spatial
load-population
display
end
;;************************************************************************************************ SETUP 2
to reload
reset-timer
clear-turtles
clear-output
reset-ticks
set-initial-values
load-population
end
;;************************************************************************************************ INITIAL VALUES
to set-initial-values
random-seed 100
set-default-shape turtles "dot"
set decided-kids 0
set decided-teens 0
set decided-adults 0
set decided-elders 0
set decided-cars 0
set safe-kids 0
set safe-teens 0
set safe-adults 0
set safe-elders 0
set safe-cars 0
set casualty-kids 0
set casualty-teens 0
set casualty-adults 0
set casualty-elders 0
set casualty-cars 0
set pop-kids 0
set pop-teens 0
set pop-adults 0
set pop-elders 0
set pop-cars 0
set teb-capacity [ ]
set exit-capacity [ ]
set scale 5 ;--> very important parameter!
set Cmax-ped ceiling (0.7 * scale ^ 2)
set Cmax-car ceiling (0.07 * scale ^ 2)
if tsunami? [set tsu-counter 53900] ;<------------------------------------------------------------------------------------------CHANGE!!!
if movie? [ vid:reset-recorder vid:start-recorder];v.4.1 -> movie-set-frame-rate movie-frame-rate] let name (word movie-name ETA ".mp4") vid:movie-open name
ask patches [set plabel "" set plabel-color black set zt -99]
let dir-temp (word pathdir:get-model-path "//Output")
set-current-directory dir-temp
file-close-all
file-open (word "Evacuation-Record" run-number ".txt")
file-print "id,x-ini,y-ini,x-goal,y-goal,x-end,y-end,L0-path,L1-path,td,tsh,zt,C"
file-close
set-current-directory pathdir:get-model-path
end
;;************************************************************************************************ LOAD SPATIAL
to load-spatial
;resizing the world
let x (1320 / scale) - 1
let y (-1) * ((1150 / scale) - 1)
resize-world 0 x y 0 ;Original 1320x1150
if scale = 5
[ set-patch-size 3 ]
if scale = 2
[ set-patch-size 1 ] ;this is the scale 2mx2m grid
;loading GIS data
let dir-temp word pathdir:get-model-path "//SpatialDB"
set-current-directory dir-temp
gis:load-coordinate-system "Projection.prj"
let Land gis:load-dataset "Land.shp"
let Urban gis:load-dataset "Urban.shp"
let Streets gis:load-dataset "Streets.shp"
let Sea gis:load-dataset "Sea.shp"
let Exit-dataset gis:load-dataset "Exits.shp"
let TEB-dataset gis:load-dataset "TEB.shp"
gis:set-world-envelope gis:envelope-of Land
set land-patches patches gis:intersecting land
set urban-patches patches gis:intersecting urban
gis:set-drawing-color gray
gis:fill urban 0.1
gis:set-drawing-color blue
gis:fill sea 0.1
set street-patches patches gis:intersecting streets
set exit-patches patches gis:intersecting exit-dataset
set teb-patches patches gis:intersecting teb-dataset
ask land-patches [ set pcolor white ]
ask street-patches [ set pcolor green ]
ask exit-patches [ sprout 1 [set color violet set size 4 set shape "circle" stamp die]
set exit-capacity lput (list self 0) exit-capacity ]
foreach gis:feature-list-of teb-dataset
[ feat -> ask patches gis:intersecting feat [ sprout 1 [set color violet set size 4 set shape "circle" stamp die]
set teb-capacity lput (list self 0) teb-capacity ;gis:property-value ? "capacity") teb-capacity
]
]
print teb-capacity
print exit-capacity
set-current-directory pathdir:get-model-path
output-print (word "Spatial data: " timer " sec.")
reset-timer
end
;;************************************************************************************************ LOAD POPULATION
to load-population
create-kids #-of-kids [ set dim 0.6 set speed 0.8 * 1.33 / scale]
create-teens #-of-teens [ set dim 1.0 set speed 1.0 * 1.33 / scale]
create-adults #-of-adults [ set dim 1.0 set speed 1.0 * 1.33 / scale]
create-elders #-of-elders [ set dim 0.8 set speed 0.7 * 1.33 / scale]
create-cars #-of-cars [ set dim 1.2 set speed 1.0 * 1.68 / scale] ;same speed but 5 times running
let pedestrians (turtle-set kids teens adults elders)
ask pedestrians [ move-to one-of urban-patches
set color black
set size ( 1 / scale * dim ) * scale * 5
let s-shapes [ ]
let str 0
let nd 0
ifelse u < ETA
[ set str u set nd ETA]
[ set str ETA set nd u]
while [ str <= nd]
[ set s-shapes lput str s-shapes
set str str + 1 ]
set td floor ( random-td-rayleigh random-float 1 one-of s-shapes )
set heuri random 5
set ini patch-here
set goal patch-here
]
ask cars [ move-to one-of street-patches
set color magenta
set size ( 1 / scale * dim ) * scale * 5
let s-shapes [ ]
let str 0
let nd 0
ifelse u < ETA
[ set str u set nd ETA]
[ set str ETA set nd u]
while [ str <= nd]
[ set s-shapes lput str s-shapes
set str str + 1 ]
set td floor (random-td-rayleigh random-float 1 one-of s-shapes)
;if td < 5 [ set td random one-of s-shapes ]
set heuri random 5
set ini patch-here
set goal patch-here
;set shape "car"
]
let p round ( %-of-handicap * count pedestrians / 100 )
ask n-of p pedestrians [ set handicap true set speed speed * 0.5 ]
set pop-kids count kids
set pop-teens count teens
set pop-adults count adults
set pop-elders count elders
set pop-cars count cars
update-text
if movie? [vid:record-view];[movie-grab-interface];
output-print (word "Population data: " timer " sec.")
set-current-plot "Preparation time"
histogram [td] of turtles
end
;;************************************************************************************************
;; MAIN PROGRAM
;;************************************************************************************************ MAIN PROG. (GO)
to go
if ticks = 0 [reset-timer no-display]
ask turtles
[ t.decide-to-start
t.decide-shelter
t.search-road
ifelse breed != cars
[ t.follow-path ]
[ repeat 5 [ t.follow-path] ]
t.search-shelter-route
]
if tsunami? [if ticks >= (65 * 60) [tsunami-run] ]
outputs
update-text
if ticks mod movie-interval = 0 and movie? [vid:record-view];[movie-grab-interface];
if ticks mod (10 * 60) = 0 and snapshots? [do-snapshots]
if ticks mod (5 * 60) = 0 and snapshots? [ display export-interface (word "Model_" run-number "_K" ticks ".png") no-display ]
tick
do-plots
if ticks = (TS * 60)
[ output-print (word "Total time:" timer " sec.")
if output-files?
[ let dir-temp (word pathdir:get-model-path "//Output")
set-current-directory dir-temp
let name (word "Safe_" run-number ".csv")
export-plot "Safe" name
set name (word "Casualty_" run-number ".csv")
export-plot "Casualty" name
;set name "Monitor.csv"
;export-output name
set name (word "TEBs_" run-number ".csv")
export-plot "TEBs" name
set-current-directory pathdir:get-model-path
]
if movie? [vid:record-view let name (word movie-name ETA ".mp4") vid:save-recording name];[movie-grab-interface movie-close];
display
export-interface (word "Model_" run-number "_K" ticks ".png")
do-snapshots
no-display
stop
]
end
;;************************************************************************************************ START DECISION
to t.decide-to-start
if stage = 0 and ( ticks = ( td * 60 ) ); or ticks = (62 * 60) )
[ set stage 1
if breed = kids [ set decided-kids decided-kids + 1]
if breed = teens [ set decided-teens decided-teens + 1]
if breed = adults [ set decided-adults decided-adults + 1]
if breed = elders [ set decided-elders decided-elders + 1]
if breed = cars [ set decided-cars decided-cars + 1 ]
]
end
;;************************************************************************************************ SHELTER DECISION
to t.decide-shelter
if stage = 1 [ ifelse random-shelter?
[ set goal one-of teb-patches ]
[ set goal one-of teb-patches with-min [distance myself] ]
ifelse breed != cars
[ set stage 2 ]
[ if random-float 1 < 0.68 ;this means 68% probability of true
[ ifelse random-shelter?
[ set goal one-of exit-patches ]
[ set goal one-of exit-patches with-min [distance myself] ]
set stage 4
]
]
]
end
;;************************************************************************************************ ROAD SEARCH
to t.search-road
if stage = 2 [ let road-1 distance min-one-of patches with [pcolor = green] [distance myself]
let road-2 distance min-one-of exit-patches [distance myself]
let road nobody
ifelse road-1 < road-2
[ set road min-one-of patches with [pcolor = green] [distance myself] set stage 3]
[ set road min-one-of exit-patches [distance myself]
set goal road
set stage 5 ]
set path Astar patch-here road white 4
]
end
;;************************************************************************************************ MOVE
to t.follow-path
if stage = 3 [ ifelse not empty? path
[ let next first path
face next
if r.topology?-to-street next
[ fd adjust-speed ]
if patch-here = next
[ set path but-first path ]
]
[ set stage 4 ]
]
if stage = 5 [ ifelse not empty? path
[ let next first path
face next
if r.topology?-on-street next
[ fd adjust-speed ]
if patch-here = next
[ set path but-first path ]
]
[ if patch-here = goal [ if breed = kids [set safe-kids safe-kids + 1]
if breed = teens [set safe-teens safe-teens + 1]
if breed = adults [set safe-adults safe-adults + 1]
if breed = elders [set safe-elders safe-elders + 1]
if breed = cars [ set safe-cars safe-cars + 1 ]
adjust-teb-capacity
export-record
die ]
]
]
end
;;************************************************************************************************ SHELTER SEARCH
to t.search-shelter-route
if stage = 4 [ set path [ ]
if breed = cars ; --> correcting a pedestrian bridge, this should be corrected with a street shape for car and street shape for pedestrians
[ ask patch 164 -132 [ set pcolor white]
ask patch 165 -131 [ set pcolor white]
ask patch 165 -132 [ set pcolor white]
ask patch 166 -131 [ set pcolor white]
ask patch 166 -132 [ set pcolor white]
]
set path Astar patch-here goal green 4
set L length path
set stage 5
if breed = cars
[ ask patch 164 -132 [ set pcolor green]
ask patch 165 -131 [ set pcolor green]
ask patch 165 -132 [ set pcolor green]
ask patch 166 -131 [ set pcolor green]
ask patch 166 -132 [ set pcolor green]
]
]
end
;;************************************************************************************************
;;************************************************************************************************ REPORTERS
to-report adjust-speed
let s 0
ifelse breed != cars
[ let pedestrians (turtle-set other kids in-cone ( 5 / scale) 60 other teens in-cone ( 5 / scale) 60 other adults in-cone ( 5 / scale) 60 other elders in-cone ( 5 / scale) 60)
let p count pedestrians with [td > [td] of self]
let a (((pi / 3) * 5 ^ 2) / 2)
let d p / a
set s precision ((1 / SQRT(2 * PI * 0.3 ^ 2 )) * EXP(-((d - 0) ^ 2) / (2 * 0.3 ^ 2))) 2
if breed = kids [ set s 0.8 * s ]
if breed = elders [ set s 0.7 * s ]
if handicap = true [ set s s * 0.5 ]
]
[ let ahead-cars (turtle-set other cars in-cone ( 10 / scale) 60 )
let p count ahead-cars with [td <= [td] of self ]
let a (((pi / 3) * 10 ^ 2) / 2)
let d p / a
set s precision ((1 / SQRT(2 * PI * 0.047 ^ 2 )) * EXP(-((d - 0) ^ 2) / (2 * 0.047 ^ 2)) / 5.0 ) 2 ;/5.0 because is repeated 5 times every second of computation
]
set s s / scale
report s
end
to-report r.topology?-on-street [next]
ifelse ( breed != cars )
[ ;let pedestrians (turtle-set other kids-on next other teens-on next other adults-on next other elders-on next) ;not include cars pedestrians in sidewalk
let pedestrians (turtle-set other kids in-cone ( 5 / scale) 60 other teens in-cone ( 5 / scale) 60 other adults in-cone ( 5 / scale) 60 other elders in-cone ( 5 / scale) 60)
ifelse next != nobody and count pedestrians with [td <= [td] of self and next != patch-here] < Cmax-ped
[ set color black report true ]
[ ;output-print (word self " blocked at " patch-here)
set color white stamp
report false ]
]
[ let ahead-cars (turtle-set other cars in-cone (10 / scale) 60)
ifelse next != nobody and count ahead-cars with [td <= [td] of self and next != patch-here] < Cmax-car ;not include pedestrians cars in road
[ set color magenta report true ]
[ ;output-print (word self " blocked at " patch-here)
set color white stamp
report false ]
]
end
;;************************************************************************************************
to-report r.topology?-to-street [next]
let pedestrians (turtle-set other kids in-cone ( 5 / scale) 60 other teens in-cone ( 5 / scale) 60 other adults in-cone ( 5 / scale) 60 other elders in-cone ( 5 / scale) 60)
ifelse next != nobody and count pedestrians with [td <= [td] of self and next != patch-here] < Cmax-ped
[ set color black report true ]
[ ;output-print (word self " blocked at " patch-here)
set color white stamp
report false ]
end
;;************************************************************************************************
to do-snapshots
let dir-temp (word pathdir:get-model-path "//Output")
set-current-directory dir-temp
let name (word run-number "K_" ticks ".png")
export-view name
set-current-directory pathdir:get-model-path
end
;;************************************************************************************************
to adjust-teb-capacity
ifelse not member? patch-here exit-patches
[ let new-teb [ ]
let pos 0
foreach teb-capacity
[ t -> if goal = item 0 t
[ let cap item 1 t
ifelse breed = cars
[ set cap cap + 4 ]
[ set cap cap + 1 ]
set new-teb replace-item 1 t cap
set pos position t teb-capacity
]
]
set teb-capacity replace-item pos teb-capacity new-teb
]
[ let new-exit [ ]
let pos 0
foreach exit-capacity
[ x -> if goal = item 0 x
[ let cap item 1 x
ifelse breed = cars
[ set cap cap + 4 ]
[ set cap cap + 1 ]
set new-exit replace-item 1 x cap
set pos position x exit-capacity
]
]
set exit-capacity replace-item pos exit-capacity new-exit
]
end
;;************************************************************************************************
to update-text
if scale = 5
[ ask patch 185 -210 [set plabel title]
ask patch 185 -220 [set plabel (word "TIME: " round (ticks / 60) " min." )]
]
if scale = 2
[ ask patch 645 -515 [set plabel title]
ask patch 645 -535 [set plabel (word "TIME: " round (ticks / 60) " min." )]
]
end
;;************************************************************************************************
to-report clock
let minutes floor (ticks / (60 ))
let seconds floor (((ticks / (60 )) - (floor (ticks / (60 )))) * (60))
report (word minutes " min. " seconds " secs.")
end
;;************************************************************************************************
to do-plots
set-current-plot "Decision"
if pop-kids > 0
[ set-current-plot-pen "kids"
plot (decided-kids / pop-kids) * 100
]
if pop-teens > 0
[ set-current-plot-pen "teens"
plot (decided-teens / pop-teens) * 100
]
if pop-adults > 0
[ set-current-plot-pen "adults"
plot (decided-adults / pop-adults) * 100
]
if pop-elders > 0
[ set-current-plot-pen "elders"
plot (decided-elders / pop-elders) * 100
]
if pop-cars > 0
[ set-current-plot-pen "cars"
plot (decided-cars / pop-cars) * 100
]
set-current-plot "Safe"
if pop-kids > 0
[ set-current-plot-pen "kids"
plot (safe-kids / pop-kids) * 100
]
if pop-teens > 0
[ set-current-plot-pen "teens"
plot (safe-teens / pop-teens) * 100
]
if pop-adults > 0
[ set-current-plot-pen "adults"
plot (safe-adults / pop-adults) * 100
]
if pop-elders > 0
[ set-current-plot-pen "elders"
plot (safe-elders / pop-elders) * 100
]
if pop-cars > 0
[ set-current-plot-pen "cars"
plot (safe-cars / pop-cars) * 100
]
set-current-plot "Casualty"
if pop-kids > 0
[ set-current-plot-pen "kids"
plot (casualty-kids / pop-kids) * 100
]
if pop-teens > 0
[ set-current-plot-pen "teens"
plot (casualty-teens / pop-teens) * 100
]
if pop-adults > 0
[ set-current-plot-pen "adults"
plot (casualty-adults / pop-adults) * 100
]
if pop-elders > 0
[ set-current-plot-pen "elders"
plot (casualty-elders / pop-elders) * 100
]
if pop-cars > 0
[ set-current-plot-pen "cars"
plot (casualty-cars / pop-cars) * 100
]
set-current-plot "TEBs"
set-current-plot-pen "TEB#1_1"
plot (item 1 item 0 teb-capacity)
set-current-plot-pen "TEB#1_2"
plot (item 1 item 1 teb-capacity)
;set-current-plot-pen "TEB#2"
;plot (item 1 item 2 teb-capacity)
set-current-plot-pen "Exit#1"
plot (item 1 item 0 exit-capacity)
set-current-plot-pen "Exit#2"
plot (item 1 item 1 exit-capacity)
end
;;************************************************************************************************
to outputs
ask cars [ if [zt] of patch-here > 0.50 [ set casualty-cars casualty-cars + 1 ;(Suga, 1995 in Yasuda, 2004)
set color red
stamp
export-record
die ] ]
let pedestrians (turtle-set kids teens adults elders)
ask pedestrians [ let HZ [zt] of patch-here
if HZ >= 0
[ ifelse HZ <= 0.85
[ let z -12.37 + 22.036 * [zt] of patch-here + 11.517 * 2.0 ;average velocity 1.80m/s from TUNAMI
let fz 1 / ( 1 + exp (15.48 - z) )
if fz > 0.50
[ if breed = kids [ set casualty-kids casualty-kids + 1 ]
if breed = teens [set casualty-teens casualty-teens + 1]
if breed = adults [set casualty-adults casualty-adults + 1]
if breed = elders [set casualty-elders casualty-elders + 1]
set color red
stamp
export-record
die
]
]
[ if breed = kids [ set casualty-kids casualty-kids + 1 ]
if breed = teens [set casualty-teens casualty-teens + 1]
if breed = adults [set casualty-adults casualty-adults + 1]
if breed = elders [set casualty-elders casualty-elders + 1]
set color red
stamp
export-record
die
]
]
]
end
;;************************************************************************************************
;to output-shelters ;turtle procedure
; file-close-all
; let dir-temp word pathdir:get-model "//Output"
; set-current-directory dir-temp
; file-open "Shelter-Report01.txt" ;(word "Exit-Report" run-number ".txt")
; file-print (word who " " e.shelter-pref)
; file-close
; set-current-directory pathdir:get-model
;end
to export-record ;turtle procedure
let dir-temp (word pathdir:get-model-path "//Output")
set-current-directory dir-temp
file-close-all
file-open (word "Evacuation-Record" run-number ".txt")
ifelse [color] of self = red
[ set stage 1 ]
[ set stage 0 ]
if path = 0
[set path [ ]]
file-print (word self "," [pxcor] of ini "," [pycor] of ini "," [pxcor] of goal "," [pycor] of goal "," [pxcor] of patch-here "," [pycor] of patch-here "," L "," (L - length path) "," td ","
precision (ticks / 60) 1 "," [zt] of patch-here "," stage ) ;stage=0 safe stage=1 casualty
file-close
set-current-directory pathdir:get-model-path
end
;;************************************************************************************************
to tsunami-run
let dir-temp word pathdir:get-model-path "//TsunamiDB"
set-current-directory dir-temp
set tsunami-file-name (word "out" tsu-counter ".asc")
; ifelse tsu-counter < 10
; [ set tsunami-file-name (word "out4000" tsu-counter ".asc") ]
; [ ifelse tsu-counter >= 10 and tsu-counter < 100
; [ set tsunami-file-name (word "out400" tsu-counter ".asc")]
; [ set tsunami-file-name (word "out40" tsu-counter ".asc") ]
; ]
let inundation gis:load-dataset tsunami-file-name
gis:set-world-envelope-ds (gis:envelope-of inundation)
gis:apply-raster inundation zt
ask patches with [zt > 0] [ set pcolor scale-color blue zt 20 -20 ]
display
no-display
set tsu-counter tsu-counter + 1 ;because data is at 0.5s output
set-current-directory pathdir:get-model-path
end
@#$#@#$#@
GRAPHICS-WINDOW
297
10
1097
709
-1
-1
3.0
1
10
1
1
1
0
0
0
1
0
263
-229
0
1
1
1
ticks
30.0
BUTTON
228
46
291
79
NIL
go
T
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
INPUTBOX
8
169
77
229
#-of-adults
2723.0
1
0
Number
INPUTBOX
8
107
77
167
#-of-kids
0.0
1
0
Number
INPUTBOX
80
107
156
167
#-of-teens
0.0
1
0
Number
INPUTBOX
82
169
156
229
#-of-elders
0.0
1
0
Number
INPUTBOX
157
106
242
166
%-of-handicap
0.0
1
0
Number
BUTTON
217
10
291
43
NIL
reload
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
151
10
214
43
NIL
setup
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
TEXTBOX
9
13
159
41
press SETUP only when open first time, then use RELOAD
11
0.0
1
SWITCH
10
325
157
358
movie?
movie?
0
1
-1000
INPUTBOX
8
45
225
105
title
\"Arahama Model\"
1
0
String
INPUTBOX
10
360
80
420
movie-name
Model
1
0
String
SWITCH
163
230
295
263
random-shelter?
random-shelter?
1
1
-1000
INPUTBOX
159
167
218
229
#-of-cars
50.0
1
0
Number
SWITCH
163
265
295
298
tsunami?
tsunami?
0
1
-1000
SWITCH
10
291
159
324
output-files?
output-files?
0
1
-1000
PLOT
1108
287
1429
514
Safe
time (s)
%safe
0.0
1800.0
0.0
100.0
true
true
"" ""
PENS
"kids" 1.0 0 -955883 true "" ""
"teens" 1.0 0 -6459832 true "" ""
"adults" 1.0 0 -10899396 true "" ""
"elders" 1.0 0 -13345367 true "" ""
"cars" 1.0 0 -5825686 true "" ""
PLOT
1109
516
1429
731
Casualty
time (s)
%casualty
0.0
1800.0
0.0
100.0
true
true
"" ""
PENS
"kids" 1.0 0 -955883 true "" ""
"teens" 1.0 0 -6459832 true "" ""
"adults" 1.0 0 -10899396 true "" ""
"elders" 1.0 0 -13345367 true "" ""
"cars" 1.0 0 -5825686 true "" ""
SWITCH
162
299
296
332
snapshots?
snapshots?
0
1
-1000
INPUTBOX
10
421
107
481
movie-frame-rate
10.0
1
0
Number
INPUTBOX
81
359
160
419
movie-interval
5.0
1
0
Number
TEXTBOX