London Underground Escalators System

London Underground Escalators System preview image

This model is seeking new collaborators — would you please help?

1 collaborator

Pp Muhammad Hijazy (Author)

Tags

commuter 

Tagged by Muhammad Hijazy over 1 year ago

crowd dynamics 

Tagged by Muhammad Hijazy over 1 year ago

escalator 

Tagged by Muhammad Hijazy over 1 year ago

london 

Tagged by Muhammad Hijazy over 1 year ago

subway 

Tagged by Muhammad Hijazy over 1 year ago

train 

Tagged by Muhammad Hijazy over 1 year ago

underground 

Tagged by Muhammad Hijazy over 1 year ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 6.0.2 • Viewed 519 times • Downloaded 19 times • Run 0 times
Download the 'London Underground Escalators System' 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

globals [
  blue-area   ;;the area between the start line (train platforms) and escalators.
  green-area   ;;the area between the escalators and gate line (exits).
  crowding-in-blue-area   ;;the number of turtles (commuters) in the blue area.
  crowding-in-green-area   ;;the number of turtles (commuters) in the green area.
  right-standing-line   ;;the number of turtles (commuters) standing in the right escalator.
  left-standing-line   ;;the number of turtles (commuters) standing in the left escalator.
  right-walking-line   ;;the number of turtles (commuters) walking in the right escalator.
  left-walking-line   ;;the number of turtles (commuters) walking in the left escalator.
  commuters-exited-escalators-while-walking--discount-on   ;;the number of turtles (commuters) who exited escalators from the walking line during the discount time.
  commuters-exited-escalators-while-standing--discount-on   ;;the number of turtles (commuters) who exited escalators from the standing line during the discount time.
  commuters-exited-escalators-while-walking--discount-off   ;;the number of turtles (commuters) who exited escalators from the walking line when the discount system is not implemented.
  commuters-exited-escalators-while-standing--discount-off   ;;the number of turtles (commuters) who exited escalators from the standing line when the discount system is not implemented.
  average-commuters-exited-escalators--one-discount-on-tick   ;;the average number (in a single tick) of turtles (commuters) who exited escalators during the discount time.
  average-commuters-exited-escalators--one-discount-off-tick   ;;the average number (in a single tick) of turtles (commuters) who exited escalators when the discount system is not implemented.
  number-in   ;;the number of turtles (commuters) who arrived in the start line (train platforms).
  number-out   ;;the number of turtles (commuters) who exited from the the gate line (exits).
  discount-on?   ;;true if the discount offered, and false if not.
  frequent-tick-counter   ;;a variable counting the unloading time in the mode of 'discrete unloading'.
  number-of-commuters-to-be-unload   ;;the number of turtles (commuters) who are still to be unloaded from trains in the current unloading time (cycle).
  number-of-ticks-taken--global   ;;a variable used to move values from the turtles-own [ number-of-ticks-taken ] in order to present them in a plot.
  commuters-could-not-be-unloaded   ;;the number of turtles (commuters) who could not be unloaded from trains to the start line (train platforms) due to overcrowding in the blue area.
  overall-discount-given   ;;the overall amount of discount which has been given to turtles (commuters) so far.
  ineffective-discount-given   ;;the overall amount of discount which has been given to the turtles (commuters) who decided to walk on the escalator regardless the discount offer, but tapped their Oyster cards anyway.
  overall-commuters-on-escalators-while-discount-on   ;;the overall number of turtles (commuters) who are on escalators during the discount time.
  overall-commuters-on-escalators-while-discount-off   ;;the overall number of turtles (commuters) who are on escalators when the discount system is not implemented.
  average-commuters-on-escalators-while-discount-on--one-tick   ;;the average number (in a single tick) of turtles (commuters) who are on escalators during the discount time.
  average-commuters-on-escalators-while-discount-off--one-tick   ;;the average number (in a single tick) of turtles (commuters) who are on escalators when the discount system is not implemented.
  discount-on-counter   ;;the number of ticks taken during the discount time.
  discount-plot   ;;a variable used in plots.
  stop-unloading-plot   ;;a variable used in plots.
  unloading-time-plot   ;;a variable used in plots.
  ticks-plot1   ;;a variable (counter) used in plots.
  ticks-plot2   ;;a variable (counter) used in plots.
]

turtles-own [
  oyster-card-holder?   ;;true if the turtle (commuter) is an Oyster card holder, and false if not.
  walk-escalator-regardless?   ;;true if the turtle (commuter) already decided to walk on the escalator (due to habit or personal circumstances) regardless of the discount offered, and false if not.
  motivated-by-discount?   ;;true if the turtle (commuter) can be motivated by discount to walk on the escalator, and false if not.
  discount-earned?   ;;true if the turtle (commuter) has earned discount, and false if not.
  number-of-ticks-taken   ;;the number of ticks that the turtle (commuter) took to move from the start line (train platforms) to the gate line (exits).
  exiting-escalator-while-walking?   ;;true if the turtle (commuter) exited the escalator from the walking line and false if it was from the standing line; the value 0 is used to mark the turtle (commuter) who has been counted in the green area.
]



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   SETUP procedure   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup
  clear-all
  ask patches [
    set pcolor white
    set plabel-color black
  ]
  set blue-area patches with [ pycor < -12 ]
  ask blue-area [ set pcolor blue ]
  set green-area patches with [ pycor > 12 ]
  ask green-area [ set pcolor green ]
  ask patches with [ (abs pxcor >= 8) and (abs pxcor <= 9) and (abs pycor <= 12) ] [ set pcolor gray + 2 ] ;;two escalators.
  ask patches with [ (abs pxcor = 10) or (abs pxcor = 7) and (abs pycor <= 12) ] [ set pcolor yellow ] ;;escalators' handles.
  ask (patch-set patch 6.66 20 patch 13.33 20 patch 0 20 patch -6.66 20 patch -13.33 20) [ set pcolor white ] ;;five gates (exits).
  set-default-shape turtles "person"
  set discount-on? false
  reset-ticks
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   GO procedure   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go
  tick
  calculate-crowding ;;go to calculate-crowding procedure.
  let crowding-level-in-blue-area (crowding-in-blue-area / count blue-area * 100)
  let number-of-commuters-arriving-every-tick--exchange number-of-commuters-arriving-every-tick ;;create a local variable indicating the number of commuters arriving every tick, which can have any value between the number-of-commuters-arriving-every-tick and the number-of-commuters-to-be-unload.
  if arrival-pattern = "discrete-unloading" [
    if frequent-tick-counter <= 0 [ ;;the case in which a new unloading period has not started yet
      set frequent-tick-counter frequency-in-which-trains-unload-commuters ;;reset frequent-tick-counter in the new unloading circle by the value of frequency-in-which-trains-unload-commuters slider.
      ifelse crowding-level-in-blue-area < overcrowding-level-in-which-trains-stop-unloading-commuters and unloading? [
        set number-of-commuters-to-be-unload number-of-commuters-to-be-unload + number-of-commuters-in-each-unload ;;reset number-of-commuters-to-be-unload in the new unloading circle by the value of number-of-commuters-in-each-unload slider.
      ]
      [
        set commuters-could-not-be-unloaded commuters-could-not-be-unloaded + number-of-commuters-in-each-unload ;;record the number of turtles (commuters) that could not be unloaded.
      ]
    ]
    if number-of-commuters-to-be-unload <= number-of-commuters-arriving-every-tick--exchange [ set number-of-commuters-arriving-every-tick--exchange number-of-commuters-to-be-unload ] ;;unload the remaining turtles (commuters).
    set frequent-tick-counter frequent-tick-counter - 1 ;;one tick has passed from the current unloading circle.
  ]
  ifelse crowding-level-in-blue-area >= overcrowding-level-in-which-trains-stop-unloading-commuters or not unloading? [
    ask (patch-set patch 13 -11 patch 16 -11 patch 19 -11 patch -13 -11 patch -16 -11 patch -19 -11) [ set pcolor red - 1 ] ;;indicate (by the red lights) that the unloading process has stopped.
    if arrival-pattern = "continues-unloading" [ set commuters-could-not-be-unloaded commuters-could-not-be-unloaded + number-of-commuters-arriving-every-tick ] ;;record the number of turtles (commuters) that could not be unloaded.
    set stop-unloading-plot -5
  ]
  [
    ask (patch-set patch 13 -11 patch 16 -11 patch 19 -11 patch -13 -11 patch -16 -11 patch -19 -11) [ set pcolor white ] ;;indicate that the unloading process is not stopped.
    set stop-unloading-plot 0
  ]

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; unloading procedure ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ifelse (arrival-pattern = "continues-unloading" and unloading? and crowding-level-in-blue-area < overcrowding-level-in-which-trains-stop-unloading-commuters) or (arrival-pattern = "discrete-unloading" and number-of-commuters-to-be-unload >= 1) [
    set unloading-time-plot -30
    ask n-of number-of-commuters-arriving-every-tick--exchange patches with [ pycor = -20 ] [ ;;turtles (commuters) are spawned in the start line (train platforms).
      sprout 1 [
        set color red
        set size 2
        ifelse random 100 <= likelihood-of-owning-oyster-card [ set oyster-card-holder? true ] [ set oyster-card-holder? false ]
        ifelse random 100 <= likelihood-that-commuters-walk-on-escalators-regardless-of-discount [ set walk-escalator-regardless? true ] [ set walk-escalator-regardless? false ]
        ifelse random 100 <= likelihood-that-commuters-are-motivated-by-discount-to-walk-on-escalators [ set motivated-by-discount? true ] [ set motivated-by-discount? false ]
        set exiting-escalator-while-walking? false
        set discount-earned? false
        setxy xcor + (random-float 1) - 0.5 ycor + (random-float 1) - 0.5
        set number-in number-in + 1
        if arrival-pattern = "discrete-unloading" [ set number-of-commuters-to-be-unload number-of-commuters-to-be-unload - 1 ]
      ]
    ]
  ]
  [
    set unloading-time-plot 0
  ]

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; implementing the discount system ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ask patch 5 -16.5 [
    ifelse crowding-level-in-blue-area >= overcrowding-level-in-blue-area [ set plabel "CROWDED" ] [ set plabel "" ] ;;indicate whether the blue area is crowded.
  ]
  ask patch 5 16 [
    ifelse (crowding-in-green-area / count green-area * 100) >= overcrowding-level-in-green-area [ set plabel "CROWDED" ] [ set plabel "" ] ;;indicate whether the green area is crowded.
  ]
  ifelse ([ plabel ] of patch 5 -16.5 = "CROWDED") and ([ plabel ] of patch 5 16 = "") and implement-discount-system? [ ;;decide whether the discount system is implemented.
    set discount-on? true
    ask (patch-set patch 6 3 patch 6 9 patch 6 -3 patch 6 -9 patch-set patch -11 3 patch -11 9 patch -11 -3 patch -11 -9) [ set pcolor lime + 2 ] ;;indicate (by the green lights) that the discount system has been implemented.
    ask patch 5 1 [ set plabel "DISCOUNT" ] ;;indicate (by the 'DISCOUNT ON' message) that the iscount system has been implemented.
    ask patch 1 -2 [ set plabel "ON" ] ;;indicate (by the 'DISCOUNT ON' message) that the iscount system has been implemented.
  ]
  [
    set discount-on? false
    ask (patch-set patch 6 3 patch 6 9 patch 6 -3 patch 6 -9 patch-set patch -11 3 patch -11 9 patch -11 -3 patch -11 -9) [ set pcolor white ]
    ask (patch-set patch 5 1 patch 1 -2) [ set plabel "" ]
  ]

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; movement of turtles (commuters) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ask turtles [
    set number-of-ticks-taken number-of-ticks-taken + 1
    ifelse patch-here = patch 6.66 20 or patch-here = patch 13.33 20 or patch-here = patch 0 20 or patch-here = patch -6.66 20 or patch-here = patch -13.33 20 [ ;;green area.
      set number-out number-out + 1
      if discount-earned? [
        set overall-discount-given overall-discount-given + 1
        if walk-escalator-regardless? [ set ineffective-discount-given ineffective-discount-given + 1 ]
      ]
      set number-of-ticks-taken--global number-of-ticks-taken
      die
    ]
    [
      ifelse pycor > 12 [ go-to-exits ]
      [
        ifelse abs pycor <= 12 [ riding-escalators ] ;;escalators area.
          [
            if pycor >= -13 and (pxcor = 8 or pxcor = 9) [ enter-right-escalator ]
            if pycor >= -13 and (pxcor = -8 or pxcor = -9) [ enter-left-escalator ]
          ]
            ifelse DISTANCE patch 8 -13 < DISTANCE patch -8 -13 [ go-to-right-escalator ] [ go-to-left-escalator ] ;;blue area.
        ]
      ]
    ]
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   when turtles (commuters) decide to go to the left escalator   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go-to-left-escalator ;;if the turtle (commuter) wants to walk on the escalator, go to the beginning (patch -9 -13) of the walking line; otherwise, go to the beginning (patch -8 -13) of the standing line.
  let targets neighbors with [ not any? turtles-here and pycor < -12 ]
  ifelse walk-escalator-regardless? or (oyster-card-holder? and motivated-by-discount? and discount-on?) [
    let target min-one-of targets [ distance patch -9 -13 ]
    if target != nobody [
      face target
      move-to target
    ]
  ]
  [
    let target min-one-of targets [ distance patch -8 -13 ]
    if target != nobody [
      face target
      move-to target
    ]
  ]
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   when turtles (commuters) decide to go to the right escalator   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go-to-right-escalator ;;if the turtle (commuter) wants to walk on the escalator, go to the beginning (patch 8 -13) of the walking line; otherwise, go to the beginning (patch 9 -13) of the standing line.
  let targets neighbors with [ not any? turtles-here and pycor < -12 ]
  ifelse walk-escalator-regardless? or (oyster-card-holder? and motivated-by-discount? and discount-on?) [
    let target min-one-of targets [ distance patch 8 -13 ]
    if target != nobody [
      face target
      move-to target
    ]
  ]
  [
    let target min-one-of targets [ distance patch 9 -13 ]
    if target != nobody [
      face target
      move-to target
    ]
  ]
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   turtles (commuters) entering the left escalator   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to enter-left-escalator
  let targets neighbors with [ not any? turtles-here and pycor = -12 and (pxcor = -8 or pxcor = -9) ]
  let target min-one-of targets [ distance myself ]
  ifelse walk-escalator-regardless? or (oyster-card-holder? and motivated-by-discount? and discount-on?) [
    ifelse target = patch -9 -12 [ ;;if the turtle (commuter) wants to walk on the escalator and patch -9 -12 is empty, then move to patch -9 -12.
      face target
      entering-escalator2
    ]
    [
      if target = patch -8 -12 [ ;;however, if patch -9 -12 is not empty but patch -8 -12 is empty, then move to patch -8 -12 and try to go to the walking line later.
        face target
        entering-escalator2
      ]
    ]
  ]
  [
    ifelse target = patch -8 -12 [ ;;if the turtle (commuter) wants to stand on the escalator and patch -8 -12 is empty, then move to patch -8 -12.
      face target
      entering-escalator2
    ]
    [
      if target = patch -9 -12 [ ;;however, if patch -8 -12 is not empty but patch -9 -12 is empty, then move to patch -9 -12 and try to go to the standing line later.
        face target
        entering-escalator2
      ]
    ]
  ]
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   turtles (commuters) entering the right escalator   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to enter-right-escalator
  let targets neighbors with [ not any? turtles-here and pycor = -12 and (pxcor = 8 or pxcor = 9) ]
  let target min-one-of targets [ distance myself ]
  ifelse walk-escalator-regardless? or (oyster-card-holder? and motivated-by-discount? and discount-on?) [
    ifelse target = patch 8 -12 [ ;;if the turtle (commuter) wants to walk on the escalator and patch 8 -12 is empty, then move to patch 8 -12.
      face target
      entering-escalator2
    ]
    [
      if target = patch 9 -12 [ ;;however, if patch 8 -12 is not empty but patch 9 -12 is empty, then move to patch 9 -12 and try to go to the walking line later.
        face target
        entering-escalator2
      ]
    ]
  ]
  [
    ifelse target = patch 9 -12 [ ;;if the turtle (commuter) wants to stand on the escalator and patch 9 -12 is empty, then move to patch 9 -12.
      face target
      entering-escalator2
    ]
    [
      if target = patch 8 -12 [ ;;however, if patch 9 -12 is not empty but patch -8 -12 is empty, then move to patch -8 -12 and try to go to the standing line later.
        face target
        entering-escalator2
      ]
    ]
  ]
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   a complement procedure to enter-left-escalator AND enter-right-escalator   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to entering-escalator2
  forward 1.5 ;;jump into the escalator.
  set heading 0
  if pxcor = 9 or pxcor = -8 [ set color brown - 2 ] ;;change color to indicate that the turtle (commuter)  is in the standing line.
  if pxcor = -9 or pxcor = 8 [ set color black ] ;;change color to indicate that the turtle (commuter)  is in the walkining line.
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   when turtles (commuters) are actually inside escalators   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to riding-escalators
  set heading 0
  forward 1
  ifelse walk-escalator-regardless? or (oyster-card-holder? and motivated-by-discount? and discount-on?) [
    if (pxcor = 9 or pxcor = -8) and not any? turtles-on patch-left-and-ahead 90 1 [ ;;if the turtle (commuter) wants to walk on the escalator and finds the place next to the left on the walking line is empty, then move to the walking line.
      move-to patch-left-and-ahead 90 1
      riding-escalators2
      stop ;; turtles are only allowed to do one move per tick
    ]
  ]
  [
    if (pxcor = -9 or pxcor = 8) and not any? turtles-on patch-right-and-ahead 90 1 [ ;;if the turtle (commuter) wants to stand on the escalator and finds the place next to the right on the standing line is empty, then move to the standing line.
      move-to patch-right-and-ahead 90 1
      riding-escalators2
      stop ;; turtles are only allowed to do one move per tick
    ]
  ]
  if (pxcor = -9 or pxcor = 8) and not any? turtles-on patch-ahead 1 [ move-to patch-ahead 1 ] ;;move on the walking line if the patch ahead is empty.
  riding-escalators2
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   a complement procedure to riding-escalators   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to riding-escalators2
  if pxcor = 9 or pxcor = -8 [ set color brown - 2 ] ;;change color to indicate that the turtle (commuter)  is in the standing line.
  if pxcor = -9 or pxcor = 8 [ set color black ] ;;change color to indicate that the turtle (commuter)  is in the walkining line.
  if discount-on? and oyster-card-holder? and (pxcor = -9 or pxcor = 8) [ set discount-earned? true ] ;;if the turtle (commuter) is an Oyster card holder and walking on the escalator during the discount time, then give discount to the turtle.
  if (pxcor = -9 or pxcor = 8) and pycor <= 12 and pycor > 6 [ set exiting-escalator-while-walking? true ] ;;set the variable exiting-escalator-while-walking? true if the turtle (commuter) is on the top quarter of the escalator's walking line.
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   when turtles (commuters) are in the green area and going to the nearest exit   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go-to-exits ;;when reaching the green area, go to the nearest exit.
  set color red

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;calculate the number of turtles (commuters) who have exited escalators from the walking lines and from the standing lines;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  if exiting-escalator-while-walking? != 0 [ ;;if the turtle (commuter) has not been marked (counted) yet, then do the following procedure.
    if exiting-escalator-while-walking? = true [
      ifelse discount-on? [
        set commuters-exited-escalators-while-walking--discount-on commuters-exited-escalators-while-walking--discount-on + 1
      ]
      [
        set commuters-exited-escalators-while-walking--discount-off commuters-exited-escalators-while-walking--discount-off + 1
      ]
    ]
    if exiting-escalator-while-walking? = false [
      ifelse discount-on? [
        set commuters-exited-escalators-while-standing--discount-on commuters-exited-escalators-while-standing--discount-on + 1
      ]
      [
        set commuters-exited-escalators-while-standing--discount-off commuters-exited-escalators-while-standing--discount-off + 1
      ]
    ]
    set exiting-escalator-while-walking? 0  ;;mark the turtle (commuter) as counted.
  ]

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;make the turtle (commuter) go to the nearest one of the five gate;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  let list-counter 0
  while [ list-counter < 5 ] [
    if min (list DISTANCE patch -13.33 20 DISTANCE patch -6.66 20 DISTANCE patch 0 20 DISTANCE patch 6.66 20 DISTANCE patch 13.33 20) = item list-counter (list DISTANCE patch -13.33 20 DISTANCE patch -6.66 20 DISTANCE patch 0 20 DISTANCE patch 6.66 20 DISTANCE patch 13.33 20) [
      let targets neighbors with [ not any? turtles-here and pycor > 12 ]
      let target min-one-of targets [ DISTANCE patch item list-counter (list -13.33 -6.66 0 6.66 13.33) 20 ]
      if target != nobody [
        face target
        move-to target
        stop
      ]
    ]
    set list-counter list-counter + 1
  ]
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   calculate some statistics   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to calculate-crowding ;;make some calculations about the crowding in the blue and green areas, and the load in the two escalators.
  set crowding-in-blue-area count turtles-on blue-area
  set crowding-in-green-area count turtles-on green-area
  set right-standing-line count turtles-on patches with [ pycor >= -12 and pycor <= 12 and pxcor = 9 ]
  set left-standing-line count turtles-on patches with [ pycor >= -12 and pycor <= 12 and pxcor = -8 ]
  set right-walking-line count turtles-on patches with [ pycor >= -12 and pycor <= 12 and pxcor = 8 ]
  set left-walking-line count turtles-on patches with [ pycor >= -12 and pycor <= 12 and pxcor = -9 ]
  ifelse discount-on? [
    set discount-plot 40
    set overall-commuters-on-escalators-while-discount-on overall-commuters-on-escalators-while-discount-on + (left-walking-line + left-standing-line + right-walking-line + right-standing-line)
    set discount-on-counter discount-on-counter + 1
    set average-commuters-on-escalators-while-discount-on--one-tick overall-commuters-on-escalators-while-discount-on / discount-on-counter
    set average-commuters-exited-escalators--one-discount-on-tick (commuters-exited-escalators-while-walking--discount-on + commuters-exited-escalators-while-standing--discount-on) / discount-on-counter
  ]
  [
    set discount-plot 0
    set overall-commuters-on-escalators-while-discount-off overall-commuters-on-escalators-while-discount-off + (left-walking-line + left-standing-line + right-walking-line + right-standing-line)
    set average-commuters-on-escalators-while-discount-off--one-tick overall-commuters-on-escalators-while-discount-off / (ticks - discount-on-counter)
    set  average-commuters-exited-escalators--one-discount-off-tick (commuters-exited-escalators-while-walking--discount-off + commuters-exited-escalators-while-standing--discount-off) / (ticks - discount-on-counter)
  ]
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   clear all plots   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to clear-plots
  clear-all-plots
  set ticks-plot1 0 ;;reset the plot ticks.
  set ticks-plot2 0 ;;reset the plot ticks.
end 

There are 2 versions of this model.

Uploaded by When Description Download
Muhammad Hijazy over 1 year ago made the code more compact Download this version
Muhammad Hijazy over 1 year ago Initial upload Download this version

Attached files

File Type Description Last updated
London Underground Escalators System.png preview Preview for 'London Underground Escalators System' over 1 year ago, by Muhammad Hijazy Download
MHijazy_London_Underground_Escalators_System2.png png interface over 1 year ago, by Muhammad Hijazy Download

This model does not have any ancestors.

This model does not have any descendants.