Giter Site home page Giter Site logo

tmelliott / transitnetworkmodel Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 0.0 23.67 MB

A realtime model of the Auckland Public Transport Network

Makefile 0.11% C++ 77.23% CMake 0.61% Shell 0.07% R 21.21% Stan 0.78%
transit gtfs gtfs-realtime particle-filter public-transport cpp11

transitnetworkmodel's Introduction

Transit Network Model

Three parts, running in real time:

  1. particle filter for vehicle location and speed
  2. Kalman filter for transit road network state (speed)
  3. travel- and arrival-time predictions for each vehicle/stop combination in the network

1. Particle Filter

IN: GTFS realtime protobuf feed

OUT: (updated) vehicle objects with updated particle states

2. Kalman filter

IN: particle filter state estimates, road state at time now - delta

OUT: road state at time now

3. Predictions

IN: particle filter state estimates, road state estimates

OUT: ETA to remaining stops along route


Dependencies

To-do

  • Application to run indefinitely
  • Use a Vehicle object concept with
    • vector<Particle> (N)
    • void update (gtfs::VehiclePosition, gtfs::TripUpdate): adjust the position, arrival/departure times etc, trigger particle transitions
    • void resample (N): perform particle filter weighted resample
    • properties vehicle_id, timestamp, trip_id, route_id, position, stop_sequence, arrival_time, departure_time
  • And the particles work in memory only
    • Particle
      • void initialize ()
      • void transition ()
      • void calc_likelihood (): uses parent Vehicle
      • void calc_weight ()
      • properties distance, velocity, stop_index, arrival_time, departure_time, segment_index, queue_time, begin_time, likelihood, weight
  • Similar concept for network route segments
    • Segment
      • vector<Path> shape: the GPS coordinates and cumulative distance of segment shape
      • double speed
      • void update (): perform Kalman filter update, using particle summaries (?)
  • The GTFS information can either be
    • loaded into an SQLite database, or
    • loaded into a MEMORY table via MySQL
  • Vehicle state summaries can be written to a file (?)
  • Making information available (via server) - road segment speeds + arrival time predictions
    • database (with no foreign key checks, and no transaction?)

(?) best way of collecting vehicle/segment data

  • sequentially append speed estimates to Segment, then periodically update and clear?
  • write to file? (makes keeping history easier?)

Project Structure

  • docs: documentation (HTML and LaTeX)
  • gps: a library containing methods for dealing with GPS coordinates
  • gtfs: a library with GTFS object classes, and methods for modeling them
    • Vehicle: Class representing a physical vehicle
    • Particle: Class representing a single vehicle state estimate
    • Segment: Class representing a road segment
  • include: header files for programs
  • protobuf: GTFS Realtime protobuf description and classes
  • src
    • transit_network_model.cpp: mostly just a wrapper for while (TRUE) { ... }
    • load_gtfs.cpp: a program that imports the latest GTFS data and segments it

transitnetworkmodel's People

Contributors

tmelliott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

transitnetworkmodel's Issues

Particles going past t_k

while () statements within the main while () loop allow trajectories to go into the future, rather than stopped at time t_k. This should be fixed ... and hopefully will fix up travel times!

Retain segments table

Reconfigure the load script to delete any old GTFS data and update with new, keeping the segments and intersections tables.

Add stop region to stops table

Each stop can be associated with a specific region,

  • CBD
  • Isthmus
  • North
  • West
  • South
  • East
  • Waiheke

That way we can subset delay information per region. This will require polygon defining each region.

Beginning of route

Currently the initialisation doesn't allow particles (or the vehicle) to be at a stop, so it's impossible to get travel times for the first segment.

Need to find nearest point on path; if that's near enough to the first stop, initialise the vehicle (all particles) AT the stop!

Add lengths to segments

Segments require a length so we can do stuff like figure out expected variance in travel time per minute.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.