Autonomous Battery Electric Taxi Service

Autonomous Battery Electric Taxi Service preview image

1 collaborator

Default-person Cameron Culver (Author)

Tags

autonomous 

Tagged by Cameron Culver almost 5 years ago

car 

Tagged by Cameron Culver almost 5 years ago

cars 

Tagged by Cameron Culver almost 5 years ago

destination 

"drops passengers off at destination"

Tagged by Cameron Culver almost 5 years ago

navigation 

"vehicles navigate streets"

Tagged by Cameron Culver almost 5 years ago

on demand 

"simulates on demand transportation"

Tagged by Cameron Culver almost 5 years ago

on demand2 

"simulates on demand transportation"

Tagged by Cameron Culver almost 5 years ago

on demanda 

"simulates on demand transportation"

Tagged by Cameron Culver almost 5 years ago

on demandd 

"simulates on demand transportation"

Tagged by Cameron Culver almost 5 years ago

on demandn 

"simulates on demand transportation"

Tagged by Cameron Culver almost 5 years ago

passenger 

"Picks up passengers"

Tagged by Cameron Culver almost 5 years ago

profit 

"simulates company profitability"

Tagged by Cameron Culver almost 5 years ago

taxi 

"Transports passengers"

Tagged by Cameron Culver almost 5 years ago

transport 

"passenger movement"

Tagged by Cameron Culver almost 5 years ago

transportation 

"Transportation of passengers"

Tagged by Cameron Culver almost 5 years ago

vehicle 

"Simulates vehicles"

Tagged by Cameron Culver almost 5 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.4 • Viewed 472 times • Downloaded 24 times • Run 0 times
Download the 'Autonomous Battery Electric Taxi Service' modelDownload this modelEmbed this model

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


Comments and Questions

Use Instructions

To view and run the model online, click the link below, then click “Setup” → “Go”, and watch it run. Use “Watch a Car” to view a single vehicle operating, as it moves towards a passengers, picks them up, and then moves to the destination. Following a passenger drop off, the cycle repeats indefinitely, until the vehicle needs to re-energize, at which point it moves to either a gas station or charger, depending on vehicle type.

Posted almost 5 years ago

Click to Run Model

globals                       ;; Setup global variables
[
  grid-size-x              ;; Number of grids of streets in x direction
  grid-size-y              ;; Number of grids of streets in y direction
  grid-x-inc               ;; the amount of patches in between two roads in the x direction
  grid-y-inc               ;; the amount of patches in between two roads in the y direction
  num-passengers           ;; number of passengers dropped off
  roads                    ;; agentset containing the patches that are roads
  watch-a-car-true?        ;; enables or disables watch a car feature
  chargers                 ;; agentset containing patches which are chargers
  gas_stations             ;; agentset containing patches which are gas_stations
  initial-manual-cost      ;; initial purchase cost for manual vehicles
  initial-abet-cost        ;; initial purchase cost for ABET vehicles
]


breed [abet a-abet]           ;; There is a turtle breed of ABETs
breed [manual a-manual]       ;; There is a turtle breed of manual vehicles


turtles-own                   ;; Properties for all turtles
[
  speed                    ;; the speed of the turtle
  destination              ;; the patch where the passenger wants to go
  passenger                ;; the patch where the passenger is
  goal                     ;; where am I currently headed
  trip-status              ;; trip status (0 = heading to passenger, 1 = heading to destination, 2 = arrived)
  travel-distance          ;; distance traveled by the vehicles
  paid-distance            ;; distance traveled with a passenger
  energy_level             ;; vehicles have an energy level (battery or fuel)
  recharge-cost            ;; cost for vehicle to recharge or refill gas
]


abet-own                      ;; Properties for ABETs
[
  charge                   ;; ABET's have a "charge goal"
  charging_state           ;; ABET's have a "charging state condition"
]


manual-own                    ;; Properties for Manual Vehicles
[
  refuel                   ;; Manual vehicles have a "refuel goal"
  refueling_state          ;; Manual vehicles have a "refueling state condition"
]


patches-own                   ;; Properties for patches
[
  my-row                   ;; the row of the intersection counting from the upper left corner of the world.  -1 for non-intersection patches.
  my-column                ;; the column of the intersection counting from the upper left corner of the world.  -1 for non-intersection patches.
]

to setup                      ;; On setup button, initialize model and create environment and agents

  clear-all
  setup-globals            ;; Setup global variables
  setup-patches            ;; ask the patches to draw themselves and set up a few variables

  if (num-manual + num-abet > count roads) [                   ;; warning message if too many cars are created to fit
    user-message (word "There are too many cars to fit on the road.")
    stop
  ]


  create-manual num-manual [                                                                      ;; Create manual vehicles
    set shape "car"                                                                               ;; sets turtle shape to be a car
    set color blue                                                                                ;; sets car color to blue
    set travel-distance 0                                                                         ;; sets initial travel-distance to 0
    set paid-distance 0                                                                           ;; sets initial paid-distance to 0
    move-to one-of roads with [ not any? turtles-on self ]                                        ;; Find a empty road and place the turtle there
    record-data
    set-passenger-destination
    set goal passenger                                                                            ;; sets goal to be passenger
    set energy_level random (max_manual_range - max_manual_range / 2 + 1) + max_manual_range / 2  ;; set the initial energy level between 50% and 100%
    set refueling_state 0                                                                         ;; sets the initial refueling_state to 0
    set initial-manual-cost manual-veh-price * num-manual                                         ;; calculates initial cost of purchasing manual vehicles
  ]

  create-abet num-abet [                                                                          ;; Create ABET vehicles
    set shape "car"                                                                               ;; sets turtle shape to be a car
    set color red                                                                                 ;; sets car color to red
    set travel-distance 0                                                                         ;; sets initial travel-distance to 0
    set paid-distance 0                                                                           ;; sets initial paid-distance to 0
    move-to one-of roads with [ not any? turtles-on self ]                                        ;; Find a empty road and place the turtle there
    record-data
    set-passenger-destination
    set goal passenger                                                                            ;; sets goal to be passenger
    set energy_level random (max_ABET_range - max_ABET_range / 2 + 1) + max_ABET_range / 2        ;; set the initial energy level between 50% and 100%
    set charging_state 0                                                                          ;; sets the initial charging_state to 0
    set initial-abet-cost abet-veh-price * num-abet                                               ;; calculates initial cost of purchasing ABET vehicles
  ]

  reset-ticks
end 

to set-passenger-destination  ;; Function to create passengers and destinations

  set trip-status 0                                 ;; set trip to 0 to indicate heading to pickup passenger

  let goal-candidates patches with [                ;; Find all patches where there can be a be a passenger or destination (not on road)
    pcolor = 38 and any? neighbors with [ pcolor = white ] ]

  set passenger one-of goal-candidates              ;; choose at random a location for the passenger

  set destination one-of goal-candidates with [   ;; choose at random a location for the destination
    self != [ passenger ] of myself ]

  if watch-a-car-true? = 1  ;; if watching vehicle

  [update-labels]
end 

to setup-globals              ;; Initialize the global variables to appropriate values
  set watch-a-car-true? 0
  set num-passengers 0
  set grid-size-x 9           ;; road grid-size-x for enviornment
  set grid-size-y 9           ;; road grid-size-y for enviornment
  set grid-x-inc world-width / grid-size-x
  set grid-y-inc world-height / grid-size-y
end 

to setup-patches              ;; Set up the roads and charger/gas station agentsets


  ask patches [                                               ;; Initialize the patch-owned variables and color the patches to brown
    set my-row -1
    set my-column -1
    set pcolor brown + 3
  ]

  set roads patches with [                                    ;; Define road patches
    (floor ((pxcor + max-pxcor - floor (grid-x-inc - 1)) mod grid-x-inc) = 0) or
    (floor ((pycor + max-pycor) mod grid-y-inc) = 0)
  ]

  ask roads [ set pcolor white ]                              ;; Colors road patches white

  set chargers patches with [ pxcor = -14 and pycor = -14]    ;; Defines charger with this location (-14, -14)
  ask chargers [ set pcolor red ]                             ;; Colors chargers red

  set gas_stations patches with [ pxcor = 13 and pycor = 14]  ;; Defines gas stations with this location ( 13, 14)
  ask gas_stations [ set pcolor blue ]                        ;; Colors gas stations blue
end 

to go                         ;; Runs the simulation

  ask abet [
    if charging_state = 0 [                ;; If ABET is NOT currently charging
      if energy_level <= 0 [               ;; ABET battery has died
        facexy 0 0                         ;; Face car toward 0 0
        fd 0                               ;; Don't move car (dead)
        record-data                        ;; Record data for plotting
      ]

      if energy_level > 0 [                ;; ABET has battery remaining
        face next-patch                    ;; Face car toward next goal
        fd car_speed                       ;; Move car forward at car_speed
        set energy_level energy_level - 1  ;; Battery Level decreases by set amount
        record-data                        ;; Record data for plotting
      ]

    ]

    if charging_state = 1 [               ;; If ABET is currently charging
      facexy 0 0                          ;; Face car toward 0 0
      fd 0                                ;; Don't move car (charging)
      set recharge-cost recharge-cost + (recharge-rate * electricity-cost)  ;; Accumulate recharge cost with electricity rate
      set energy_level energy_level + recharge-rate ;; Energy level increases at recharge rate
      record-data                         ;; Record data for plotting
    ]
  ]

  ask manual [
    if refueling_state = 0 [              ;; If manual vehicle is NOT currently refueling
      if energy_level <= 0 [              ;; Manual vehicle is out of fuel
        facexy 0 0                        ;; Face car toward 0 0
        fd 0                              ;; Don't move car (dead)
        record-data                       ;; Record data for plotting
      ]

      if energy_level > 0 [               ;; Manual vehicle has fuel remaining
        face next-patch                   ;; Face car toward next goal
        fd car_speed                      ;; Move car forward at car_speed
        set energy_level energy_level - 1 ;; Battery Level decreases
        record-data                       ;; Record data for plotting
      ]
    ]

    if refueling_state = 1 [              ;; If manual vehicle is currently refueling
      facexy 0 0                          ;; Face car toward 0 0
      fd 0                                ;; Don't move car (Refueling)
      set recharge-cost recharge-cost + (recharge-rate * 25 * gas-cost)  ;; Accumulate recharge cost with gas rate
      set energy_level energy_level + recharge-rate * 25 ;; Energy level increases at recharge rate assuming gas fillup is 25x faster than recharging
      record-data                         ;; Record data for plotting
    ]
  ]

  label-subject                           ;; If watching a car, label it
  tick
end 

to record-data                ;; Data recorder for plots
  set travel-distance travel-distance + 1 ;; While moving, increase distance
  if trip-status = 1 [
    set paid-distance paid-distance + 1 ;; Wile moving with passenger onboard, increase paid distance
  ]
end 

to-report next-patch          ;; Define goal of vehicle (passenger, destination, or charge/refuel)

  ask abet [

    if goal = passenger and (member? patch-here [ neighbors4 ] of passenger) and charging_state = 0 [      ;; If goal is passenger and nearby passenger
      set trip-status 1                                          ;; Passenger is onboard
      set goal destination                                       ;; Set goal to destination
    ]

    if goal = destination and (member? patch-here [ neighbors4 ] of destination) and charging_state = 0 [  ;; If goal is destination and nearby destination
      set trip-status 2                                          ;; Off-board passenger
      set num-passengers num-passengers + 1                      ;; Count total number of passengers transported

      set-passenger-destination                                  ;; Execute set-passenger-destination function
      let Passenger_X_Cor [ pxcor ] of passenger                 ;; Find X Coordinate of new passenger
      let Passenger_Y_Cor [ pycor ] of passenger                 ;; Find Y Coordinate of new passenger
      let Destination_X_Cor [ pxcor ] of destination             ;; Find X Coordinate of new destination
      let Destination_Y_Cor [ pycor ] of destination             ;; Find Y Coordinate of new destination
      let Charger_X_Cor [ pxcor ] of one-of chargers             ;; Find X Coordinate of one of chargers
      let Charger_Y_Cor [ pycor ] of one-of chargers             ;; Find Y Coordinate of one of chargers

      let required_range 1.5 * (                                 ;; Find required minimum range for next trip and add 50% safety factor
        abs(Passenger_X_Cor -  [ xcor ] of myself ) +
        abs(Destination_X_Cor - Passenger_X_Cor) +
        abs(Charger_X_Cor - Destination_X_Cor) +
        abs(Passenger_Y_Cor -  [ ycor ] of myself) +
        abs(Destination_Y_Cor - Passenger_Y_Cor) +
        abs(Charger_Y_Cor - Destination_Y_Cor) )

      if required_range < energy_level [set goal passenger]     ;; Find required range is less than energy level, assign passenger goal
      if required_range >= energy_level [                       ;; If required range is greater than energy_level
        set charge one-of chargers                              ;; Set a charger location
        set goal charge ]                                       ;; Set goal to charge
    ]

    if goal = charge and (member? patch-here [ neighbors ] of charge) and energy_level < max_ABET_range [  ;; If goal is to charge and not at full energy level and nearby charger
      set charging_state 1                                      ;; Set charging state to 1
      set goal charge                                           ;; Reset goal to charge
    ]

    if goal = charge and energy_level >= max_ABET_range [       ;; If goal and at full battery level
      set charging_state 0                                      ;; Set charging state to 0
      set goal passenger                                        ;; Set goal to passenger
    ]
  ]

  ask manual [

    if goal = passenger and (member? patch-here [ neighbors4 ] of passenger) and refueling_state = 0 [      ;; If goal is passenger and nearby passenger
      set trip-status 1                                        ;; Passenger is onboard
      set goal destination                                     ;; Set goal to destination
    ]

    if goal = destination and (member? patch-here [ neighbors4 ] of destination) and refueling_state = 0 [  ;; If goal is destination and nearby destination
      set trip-status 2                                        ;; Off-board passenger
      set num-passengers num-passengers + 1                    ;; Count total number of passengers transported

      set-passenger-destination                                ;; Execute set-passenger-destination function
      let Passenger_X_Cor [ pxcor ] of passenger               ;; Find X Coordinate of new passenger
      let Passenger_Y_Cor [ pycor ] of passenger               ;; Find Y Coordinate of new passenger
      let Destination_X_Cor [ pxcor ] of destination           ;; Find X Coordinate of new destination
      let Destination_Y_Cor [ pycor ] of destination           ;; Find Y Coordinate of new destination
      let Gas_Station_X_Cor [ pxcor ] of one-of gas_stations   ;; Find X Coordinate of one of gas stations
      let Gas_Station_Y_Cor [ pycor ] of one-of gas_stations   ;; Find Y Coordinate of one of gas stations

      let required_range 1.5 * (                               ;; Find required minimum range for next trip and add 50% safety factor
        abs(Passenger_X_Cor -  [ xcor ] of myself ) +
        abs(Destination_X_Cor - Passenger_X_Cor) +
        abs(Gas_Station_X_Cor - Destination_X_Cor) +
        abs(Passenger_Y_Cor -  [ ycor ] of myself) +
        abs(Destination_Y_Cor - Passenger_Y_Cor) +
        abs(Gas_Station_Y_Cor - Destination_Y_Cor) )

      if required_range < energy_level [set goal passenger]   ;; Find required range is less than energy level, assign passenger goal
      if required_range >= energy_level [                     ;; If required range is greater than energy_level
        set refuel one-of gas_stations                        ;; Set a charger location
        set goal refuel ]                                     ;; Set goal to charge
    ]

    if goal = refuel and (member? patch-here [ neighbors ] of refuel) and energy_level < max_manual_range [  ;; If goal is to refuel and not at energy level and nearby gas_station
      set refueling_state 1                                   ;; Set refueling state to 1
      set goal refuel                                         ;; Reset goal to refuel
    ]

    if goal = refuel and energy_level >= max_manual_range [
      set refueling_state 0                                   ;; Set refueling state to 0
      set goal passenger                                      ;; Set goal to passenger
    ]
  ]

  let choices neighbors with [ pcolor = white ]                  ;; Define choices agentset which constrains vehicle to only drive on road patches
  let choice min-one-of choices [ distance [ goal ] of myself ]  ;; Choose option which minimizes distance between goal and vehicle
  report choice                                                  ;; Report out chosen patch
end 

to watch-a-car-button         ;; Watch a car button

  ifelse watch-a-car-true? = 0
  [set watch-a-car-true? 1
    watch-a-car
  ]
  [set watch-a-car-true? 0
    stop-watching
  ]
end 

to watch-a-car                ;; Watch a car function

  stop-watching             ;; In case previously watching another car
  watch one-of turtles
  update-labels
end 

to update-labels              ;; Update labels of watched car

  if subject != nobody [
    ask subject [

      ask passenger [
        set pcolor yellow          ;; Color the passenger patch yellow
        set plabel-color yellow    ;; Label the passenger in yellow font
        set plabel "passenger"     ;; Label the passenger
      ]

      ask destination [
        set pcolor orange          ;; Color the destination patch orange
        set plabel-color orange    ;; Label the destination in orange font
        set plabel "destination"   ;; Label the destination
      ]

      set label [ plabel ] of goal ;; car displays its goal
    ]
  ]
end 

to stop-watching              ;; Stop watching a car

  ask patches with [ pcolor = yellow or pcolor = orange ] [   ;; Reset patch colors/labels
    stop-inspecting self
    set pcolor 38
    set plabel ""
  ]

  ask turtles [
    set label ""
    stop-inspecting self
  ]
  reset-perspective
end 

to label-subject              ;; Label watched vehicle
  if subject != nobody [
    ask subject [
      set label energy_level  ;; Label watched vehicle with energy level
      set label-color black   ;; Color label black
    ]
  ]
end 


;; Modified Version of Traffic Grid Goal Model by Uri Wilensky (2008).
;; Modified by David Caples, Cameron Culver

There is only one version of this model, created almost 5 years ago by Cameron Culver.

Attached files

File Type Description Last updated
Autonomous Battery Electric Taxi Service.png preview Preview for 'Autonomous Battery Electric Taxi Service' almost 5 years ago, by Cameron Culver Download

This model does not have any ancestors.

This model does not have any descendants.