Service access model - 1

Service access model - 1 preview image

1 collaborator

Default-person Rohan Fisher (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.2.1 • Viewed 292 times • Downloaded 15 times • Run 0 times
Download the 'Service access model - 1' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Info tab cannot be displayed because of an encoding error

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

extensions [palette gis]
globals [a1 b1 c1 scan minldm ldm1 ldm2 ldm3 ldm4 ldm5 ldm6 ldm7 ldm8 ldm9  ldm10 ldm11 ldm12 ldm13 d0 x y covergis  a b c d f mx  target-data  iteration time scan-time time-to-go]
patches-own [  dist cost  costs is-land-patch  costgis cover saved-target fin-dist]
breed [bar bars]
breed [road1 roads1]
breed [road2 roads2]
breed [road3 roads3]
breed [dest dests]
breed [scanner scanners]

to set-up
   clear-all
   set-gis
   set c min-pxcor + 2 set d min-pycor + 2 set a max-pxcor - 2 set b max-pycor - 2
   set a1 0.9866   set b1 1.4141   set c1 2.2062
   ask patch c b [sprout-scanner 1 [set color yellow set size 8 set heading 180]]
   set scan 1
   set iteration 0
   reset-ticks
end 

to go
    if ticks = 0  [reset-timer]
    if use-gis and ticks < 2 [set-cost]
    if  scan = 5 [chkend]
    ask turtles with [color = yellow] [fd 1 chk-scan]
    if not any? scanner [  ask patches [set fin-dist dist ]  set-zcolor ask patches with [dist = 999999] [set dist -1] set-pcolor if use-gis [set-zcolor] stop ]
    if scan = 1 [ask turtles [foward-scan]]
    if scan = 2 [ask turtles [back-scan]]
    if scan = 3 [ask turtles [top-scan]]
    if scan = 4 [ask turtles [bot-scan]]
    if scan >= 2 [set time-to-go (scan-time - timer)]
    tick
end 

to set-gis
      ask patches [set cost 5 set dist 999999]
      if center-target [ask patches [if (pxcor = 0 and pycor = 0) [set dist 0]  ]]
      ask patches with [dist = 999999] [set pcolor blue]
;;load landcover layer
      set covergis gis:load-dataset "data/landcover.asc"
      if use-gis [gis:apply-raster covergis cover       make-rivers set-cost]
      gis:set-world-envelope      (gis:envelope-of covergis)
      ask patches [  ifelse (cost <= 0) or (cost >= 0)  [ set is-land-patch 1 ] [ set cost 60 ]  ]   ; NaN fix
;;import shape file for destination points
      if use-shp [ set target-data gis:load-dataset "data/ponec.shp" foreach gis:feature-list-of target-data
        [gis:set-drawing-color white    gis:fill ? 2.0 ask patches gis:intersecting target-data [set dist 0 ] ]]
;;display shaded landcover image
      if use-gis [import-pcolors-rgb "data/LandCover_png.png" ask patches with [dist = 0] [sprout-dest 1 [set shape "cylinder" set size 10 set color white]]]
end 


;; set default cost value for each patch based on land cover type,  ie the amount of time it takes to cross a patch in seconds;;;;;;;;;;;;;

to set-cost
  ask patches with [cover = 1] [set cost 180]
  ask patches with [cover = 2] [set cost 90]
  ask patches with [cover = 3] [set cost 60]
  ask patches with [cover = 4] [set cost 240]
  ask patches with [cover = 101] [set cost 90]
  ask patches with [cover = 102] [set cost 90]
  ask patches with [cover = 103] [set cost 90]
  ask patches with [cover = 104] [set cost 90]
  ask patches with [cover = 105] [set cost 99999]
  ask patches with [cover = 201] [set cost 3]
  ask patches with [cover = 202] [set cost 7]
  ask patches with [cover = 203] [set cost 18]
;; set cost value with optionalsettings
  if (walking = "Assisted") [ask patches [if cover < 5 [set cost cost * 2]]]
   if (walking = "Stretcher") [ask patches [if cover < 5 [set cost cost * 5]]]
  if (time-of-day = "Night") [ask patches [set cost cost * 1.2]]
  if (weather = "Rainy") [ask patches [if cover = 104 or cover = 103 [set cost 99999]] ask patches [set cost cost * 1.1]]
   if (weather = "Flooding") [ask patches [if cover = 104 or cover = 103 or cover = 102 or cover = 101 [set cost 99999]] ask patches [set cost cost * 1.3]]
  if use-road-speeds [ask patches [
    if (cover = 201) [set cost (180 / Pimary-Road)]
    if (cover = 202) [set cost (180 / Secondary-Road)]
    if (cover = 203) [set cost (180 / Local-Road)]]]
end 

;;;;;;;;;;;;;;;;;;; Chamfer scans ;;;;;;;;;;;;;;;;;;;

to foward-scan
   set d0 ([dist] of  patch-here)
   set LDM1 (C1 * cost + ([dist] of patch-at -1 2))
   set LDM2 (C1 * cost + ([dist] of patch-at -2 1))
   set LDM3 (C1 * cost + ([dist] of patch-at -2 -1))
   set LDM4 (C1 * cost + ([dist] of patch-at -1 -2))
   set LDM5 (B1 * cost + ([dist] of patch-at -1 1))
   set LDM6 (B1 * cost + ([dist] of patch-at -1 -1))
   set LDM7 (A1 * cost + ([dist] of patch-at -1 0))
   set LDM8 (A1 * cost + ([dist] of patch-at 0 -1))
   set LDM9 (0 + ([dist] of patch-at 0 0))
 set minldm min (list ldm1 ldm2 ldm3 ldm4 ldm5 ldm6  ldm7  ldm8 ldm9)
 set dist min (list d0 minldm )
end 

to back-scan
   set d0 ([dist] of  patch-here)
   set LDM1 (C1 * cost + ([dist] of patch-at 1 -2))
   set LDM2 (C1 * cost + ([dist] of patch-at 2 -1))
   set LDM3 (C1 * cost + ([dist] of patch-at 2 1))
   set LDM4 (C1 * cost + ([dist] of patch-at 1 2))
   set LDM5 (B1 * cost + ([dist] of patch-at 1 -1))
   set LDM6 (B1 * cost + ([dist] of patch-at 1 1))
   set LDM7 (A1 * cost + ([dist] of patch-at 1 0))
   set LDM8 (A1 * cost + ([dist] of patch-at 0 1))
   set LDM9 (0 + ([dist] of patch-at 0 0))
  set minldm min (list ldm1 ldm2 ldm3 ldm4 ldm5 ldm6  ldm7  ldm8 ldm9)
  set dist min (list d0 minldm)
end 

to top-scan
   set d0 ([dist] of  patch-here)
   set LDM1 (C1 * cost + ([dist] of patch-at -1 2))
   set LDM2 (C1 * cost + ([dist] of patch-at -2 1))
   set LDM3 (C1 * cost + ([dist] of patch-at 2 1))
   set LDM4 (C1 * cost + ([dist] of patch-at 1 2))
   set LDM5 (B1 * cost + ([dist] of patch-at -1 1))
   set LDM6 (B1 * cost + ([dist] of patch-at 1 1))
   set LDM7 (A1 * cost + ([dist] of patch-at -1 0))
   set LDM8 (A1 * cost + ([dist] of patch-at 0 1))
   set LDM9 (0 + ([dist] of patch-at 0 0))
 set minldm min (list ldm1 ldm2 ldm3 ldm4 ldm5 ldm6  ldm7  ldm8 ldm9)
 set dist min (list d0 minldm )
end 

to bot-scan
   set d0 ([dist] of  patch-here)
   set LDM1 (C1 * cost + ([dist] of patch-at -1 -2))
   set LDM2 (C1 * cost + ([dist] of patch-at -2 -1))
   set LDM3 (C1 * cost + ([dist] of patch-at 2 -1))
   set LDM4 (C1 * cost + ([dist] of patch-at 1 -2))
   set LDM5 (B1 * cost + ([dist] of patch-at 1 -1))
   set LDM6 (B1 * cost + ([dist] of patch-at -1 -1))
   set LDM7 (A1 * cost + ([dist] of patch-at 1 0))
   set LDM8 (A1 * cost + ([dist] of patch-at 0 -1))
   set LDM9 (0 + ([dist] of patch-at 0 0))
 set minldm min (list ldm1 ldm2 ldm3 ldm4 ldm5 ldm6  ldm7  ldm8 ldm9)
 set dist min (list d0 minldm)
end 

;; change scan direction

to chk-scan
 if ycor = d and scan = 1 [set f (f + 1) setxy (c + f) b  ]
  if xcor = a and scan = 1 [set f 0 setxy a d set heading 0 set scan 2 set scan-time (timer * 4) ]
   if ycor = b and scan = 2 [set f (f + 1) setxy (a - f) d  ]
    if xcor = c and scan = 2 [set f 0 setxy c b set heading 90 set scan 3 set scan-time (timer * 2)]
     if xcor = a and scan = 3 [set f (f + 1) setxy c  (b - f) ]
      if ycor = d and scan = 3 [set f 0 setxy a d set heading 270 set scan 4 ]
        if xcor = c and scan = 4 [set f (f + 1) setxy a (d + f)  ]
          if ycor = b and scan = 4 [ set time timer  die]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;Drawing destination target points, new roads and barriers;;;;;;;;;;;;;;;;;;;;;
;; darwing a new destination point

to place-target
 if (mouse-down?)
    [  ask patch mouse-xcor mouse-ycor  [sprout-dest 1
    [set dist 0 ask patches in-cone 3 360 [set pcolor black] die]]]
end 
;; drawing a new barrier

to place-barrier
 if (mouse-down?)
    [  ask patch mouse-xcor mouse-ycor  [sprout-bar 1
    [ set color green set cost (Barrier-value * 60) set pcolor green ask patches in-cone 2 360 [ set cost (Barrier-value * 60) set pcolor green ] die]]]
end 
;; drawing a new road

to place-road
 if (mouse-down?)
    [  ask patch mouse-xcor mouse-ycor
    [ set pcolor red
    ifelse use-gis [
    if (Road-Type = "Primary") [set cover 201]
    if (Road-Type = "Secondary") [set cover 202]
    if (Road-Type = "Local") [set cover 203]]
    [set cost 2]]]
end 

;; icrease the width of rivers so the act as impermeable barriers - place roads over river.
To make-rivers
ask patches with [cover = 201] [sprout-road1 1]
ask patches with [cover = 202] [sprout-road2 1]
ask patches with [cover = 203] [sprout-road3 1]
ask patches with [cover = 101] [sprout-bar 1[ ask patches in-cone 1 360 [set cover  101 ] die]]
ask patches with [cover = 102] [sprout-bar 1[ ask patches in-cone 1 360 [set cover  102 ] die]]
ask patches with [cover = 103] [sprout-bar 1[ ask patches in-cone 1 360 [set cover  103 ] die]]
ask patches with [cover = 104] [sprout-bar 1[ ask patches in-cone 1 360 [set cover  104 ] die]]
ask patches with [cover = 105] [sprout-bar 1[ ask patches in-cone 1 360 [set cover  105 ] die]]
ask road1 [ask patch-here [set cover 201] die]
ask road2 [ask patch-here [set cover 202] die]
ask road3 [ask patch-here [set cover 203] die]
end 

;;;;;;;;;;;;;;;;;;;;Displaying model output;;;;;;;;;;;;;;;;;;;;;;;
;;Display base GIS data

to view-gis-layer
    ask patches [ set pcolor palette:scale-gradient palette:scheme-colors "Divergent" "Spectral" 7 cost 1 300 ]
    ask patches with [dist = 0] [sprout-dest 1 [set shape "cylinder" set size 15 set color white]]
end 
;;Display out-put as continous colour

to set-pcolor
ask patches
[ set pcolor palette:scale-gradient palette:scheme-colors "Divergent" "Spectral" 9 dist (mx)  0]
ask patches with [dist = 0] [sprout-dest 1 [set shape "cylinder" set size 7 set color white]]
end 
;;Display output as travel time zones

to set-zcolor
ask patches
[let mint (dist / 60)
if (fin-dist / 60) >= 0 and (fin-dist / 60) < 15 [set pcolor 103]
 if (fin-dist / 60) > 15 and (fin-dist / 60) < 30 [set pcolor 94]
 if (fin-dist / 60) > 30 and (fin-dist / 60) < 60 [set pcolor green ]
 if (fin-dist / 60) > 60 and (fin-dist / 60) < 99 [ set pcolor yellow  ]
  if (fin-dist / 60) > 90 and (fin-dist / 60) < 121 [ set pcolor orange  ]
   if (fin-dist / 60) > 120 and (fin-dist / 60) < 99999 [ set pcolor red  ]   ]
ask patches with [dist = 0] [sprout-dest 1 [set shape "cylinder" set size 7 set color white]]
set mx  ((median [dist] of patches) * 2)
if use-gis [set mx ((standard-deviation [dist] of patches) * 2)]
if (use-gis and (weather = "Rainy" or weather = "Flooding" ))[set mx mean ([dist] of patches) ]
end 

;;;;;;;;;;;;;;;;;;;;Restting the model with saved destination targets;;;;;;;;;;;;;;;;;;;;;;;

to clear
set time 0 set time-to-go 0
set-gis
set scan 1 set mx 0
set f 1
clear-turtles
ask patch c b [sprout-scanner  1 [set color yellow set size 15 set heading 180]]
reset-ticks
ask patches with [ saved-target = 100] [set dist 0]
set-zcolor
end 

to chkend
  clear-turtles
  set-zcolor
end 

There is only one version of this model, created over 7 years ago by Rohan Fisher.

Attached files

File Type Description Last updated
Fisher_Lassa_2017_Interactive, open source, travel time senario modelling.pdf pdf Journal article providing background to this work and describing the model. over 7 years ago, by Rohan Fisher Download
Model-1.zip data This contains the nlogo and all associated data files to run the model. over 7 years ago, by Rohan Fisher Download
Service access model - 1.png preview Preview for 'Service access model - 1' over 7 years ago, by Rohan Fisher Download

This model does not have any ancestors.

This model does not have any descendants.