Code Monkey home page Code Monkey logo

cityflow_dyn's Introduction

A modified version of CityFlow, which is compatible with original CityFlow configs and input (but not fully tested), and support dynamic lanes (lanes can set different outgoing directions dynamically). You can find formal definition of dynamic lanes in [1].

Added or updated functions:

  • Engine.init: added two new arguments.
    • log_file set path to save running logs about Engine, which is used to debug CityFlow
    • log_level set debug log level
  • get_roadlink_vehicle_count: get vehicle count based on a roadlink. return a list of four integer, [ingoing lane number, total vehicle number on all ingoing lanes, outgoing lane number, total vehicle number on all outgoing lanes].
    • intersection_id the corresponding intersection of the roadlink
    • roadlink_index roadlink index
  • get_roadlink_waiting_vehicle_count: same as above, except vehicle number is changed to waiting vehicle number (speed < 0.1).
  • get_average_delay: get total average delay of all vehicles.
  • get_road_average_delay get average delay of all roads. return dict { road_name: delay }. the average delay of a road means the average delay for all vehicles during passing this road.
  • get_direction_change_lanes: get names of direction change lanes and its available direction. return dict { direction_change_lane_name: [available_directions] }.
  • get_direction_change_lane_direction: input name of a direction change lane, output its current direction.
  • set_log_file: set new log file position. Used for debug and test.
    • road_file new road file path
    • replay_file new replay file path
    • move_data default false, whether move current file to new location.
  • set_lane_direction: set new direction for direction change lanes.
    • lane: lane name
    • direction: direction name

To set a lane as direction change, we only need to modify the road network definition in roadnet.json. In the roadLinks definition for intersections, if a lane exists in multiple roadlinks, i.e. different roadlinks have same roadLink.LaneLink.startLaneIndex = X then lane X becomes a direction change lane. Refer to examples/directionchange/roadnet.json, lane index 2 of road road_0_1_0 is a direction change lane, and its available directions are go straight and turn left.

Known problems: the environment is not robust enough and sometimes may crash (in my experiments, 0.3% crash rate in 24000 step simulation). The probability is not high, but may be annoying when training long epochs and many agents. I tried to fix the problem but failed, so I used a wrapper to catch crash and re-generate a new environment automatically to avoid unexpected exception.

[1]Dynamic Lane Traffic Signal Control with Group Attention and Multi-Timescale Reinforcement Learning

Original README of CityFlow

Documentation Status Build Status

CityFlow is a multi-agent reinforcement learning environment for large-scale city traffic scenario.

Checkout these features!

  • A microscopic traffic simulator which simulates the behavior of each vehicle, providing highest level detail of traffic evolution.
  • Supports flexible definitions for road network and traffic flow
  • Provides friendly python interface for reinforcement learning
  • Fast! Elaborately designed data structure and simulation algorithm with multithreading. Capable of simulating city-wide traffic. See the performance comparison with SUMO [2].
performance compared with SUMO

Performance comparison between CityFlow with different number of threads (1, 2, 4, 8) and SUMO. From small 1x1 grid roadnet to city-level 30x30 roadnet. Even faster when you need to interact with the simulator through python API.

Screencast

demo

Featured Research and Projects Using CityFlow

Links

[2]SUMO home page
[3]Tianrang Intelligence home page

cityflow_dyn's People

Contributors

chacha-chen avatar hzfengsy avatar only-changer avatar soodoshll avatar thisisisaac avatar wnzhang avatar zhc134 avatar zyr17 avatar

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.