Giter Club home page Giter Club logo

cityflow's People

Contributors

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

Stargazers

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

Watchers

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

cityflow's Issues

Unexpected roadnet rendering

I generated a raw roadnet.json with some roadLinks like below:

     {
          "type": "turn_left",
          "startRoad": "edge-1",
          "endRoad": "edge-10",
          "laneLinks": [
            {
              "startLaneIndex": 0,
              "endLaneIndex": 0,
              "points": [
                {
                  "x": 960,
                  "y": 390
                },
                {
                  "x": 978.6,
                  "y": 392.52
                },
                {
                  "x": 996.98,
                  "y": 399.63
                },
                {
                  "x": 1014.6,
                  "y": 410.62
                },
                {
                  "x": 1030.94,
                  "y": 424.8
                },
                {
                  "x": 1045.45,
                  "y": 441.46
                },
                {
                  "x": 1057.62,
                  "y": 459.91
                },
                {
                  "x": 1066.91,
                  "y": 479.44
                },
                {
                  "x": 1072.78,
                  "y": 499.36
                },
                {
                  "x": 1074.71,
                  "y": 518.97
                },
                {
                  "x": 1072.17,
                  "y": 537.57
                }
              ]
            }
          ]
        },

As posted, the lane link is organized by some points which should be performed like a real curve. But I got weird intersections without any internal lane link displaying:
image

Does the frontend tool support this feature?

How to use `set_tl_phase(intersection_id, phase_id)`

The docs provided for set_tl_phase(intersection_id, phase_id) explains:

phase_id is the no. of phase of the traffic light, defined in roadnetFile

But I found this to be a little vague. So I wanted to clarify.

If we take a look at an example roadnet.json file provided in the docs:

{
  "intersections": [
    {
      // id of the intersection
      "id": "intersection_1_0",
      // coordinate of center of intersection
      "point": {
        "x": 0,
        "y": 0
      },
      // width of the intersection
      "width": 10,
      // roads connected to the intersection
      "roads": [
        "road_1",
        "road_2"
      ],
      // roadLinks of the intersection
      "roadLinks": [
        {
          // 'turn_left', 'turn_right', 'go_straight'
          "type": "go_straight",
          // id of starting road
          "startRoad": "road_1",
          // id of ending road
          "endRoad": "road_2",
          // lanelinks of roadlink
          "laneLinks": [
            {
              // from startRoad's startLaneIndex lane to endRoad's endLaneIndex lane
              "startLaneIndex": 0,
              "endLaneIndex": 1,
              // points along the laneLink which describe the shape of laneLink
              "points": [
                {
                  "x": -10,
                  "y": 2
                },
                {
                  "x": 10,
                  "y": -2
                }
              ]
            }
          ]
        }
      ],
      // traffic light plan of the intersection
      "trafficLight": {
        "lightphases": [
          {
            // default duration of the phase
            "time": 30,
            // available roadLinks of current phase, index is the no. of roadlinks defined above.
            "availableRoadLinks": [
              0,
              2
            ]
          }
        ]
      },
      // true if it's a peripheral intersection (if it only connects to one road)
      "virtual": false
    }
  ],
  "roads": [
    {
      // id of road
      "id": "road_1",
      // id of start intersection
      "startIntersection": "intersection_1",
      // id of end intersection
      "endIntersection": "intersection_2",
      // points along the road which describe the shape of the road
      "points": [
        {
          "x": -200,
          "y": 0
        },
        {
          "x": 0,
          "y": 0
        }
      ],
      // property of each lane
      "lanes": [
        {
          "width": 4,
          "maxSpeed": 16.67
        }
      ]
    }
  ]
}

My understanding is phase_id is the index of the phase defined in "lightphases". Am I correct?

What if there are multiple "lightphases" as it does in this example roadnet file?

loading road net and flow configuration

Is there any other ways to load a road net or flow configuration rather than through predefining them in the configuration file? For example, load some road net, load one flow file, run it, then load another flow file, run it, etc...
Thanks!

Feature request: Easier identification of roads / vehicles from replay

it is difficult to figure out roadIds which are required for most information-querying APIs. One has to read the roadnet file in order to figure out which road is which, and this is difficult even if one reads the doc ( since roadnet files can be hundreds or of lines long even for very simple settings).

An easier way to identify roads and their IDs would be extremely helpful. An idea is to use the Simulator and display ID when you hover mouse over the road.

Thanks!

Running CityFlow

Could someone help me out with using the CityFlow engine? Right now I have got a DQN algorithm running on gym environments fine, however I want to test this on the CityFlow environment.

I have completed all installation steps, but I cannot seem to get the engine to start running when I call for it as the environment.

Any tips? I have read the other issue concerning the "dir" of the config file...

Update docs

Supplement documents of the latest version.

Error in non-Grid intersection

Hi,

When I use grid intersections I am able to create an instance of cityflow environment and everything works fine. But, when I switch to non-grid environment, I have some issues.

I built a non-grid intersection road-net and traffic-flow file, including one intersection with three roads, and tried to build an instance of the CityFlow environment by them, but faced a segmentation fault error. I tried both CityFlow environment and the engine.so through the anon_env.py from https://traffic-signal-control.github.io/. When I call it directly by CityFlow, I simply run:
eng = cityflow.Engine(config_file=config_file_, thread_num=1)
, which results in:
Segmentation fault

When, I run it by anon_env, the error is a bit more informative:
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
which happens when I call the eng.load_roadnet function from engine.
I ran this procedure by using the anon_env with the engine.so which I downloaded from here.
I attached my road-net and traffic-flow files, which I changed them as txt file since github does not allow json files.
traffic_flow.txt
roadnet.txt

I appreciate any help or comment.

chart file for replay

I'm trying to display some chart from the replay. any quick tutorial/sample on this?

Request for more detailed step-by-step guide

I have read the Cityflow doc multiple times but it comes very short to providing enough guidance to get me started.

Here are just a few questions from a long list of questions that weren't answered by the guide:

  1. What is "roadLinkIndices"?

  2. What does it mean if "availableRoadLinks":[] for a lightphases?

  3. Why must virtual intersections have "lightphases" when we don't care about the lights in the edges?

  4. How do I change the number of vehicles (i.e. the rate of spawning new vehicles)?

  5. How do you turn on yellow lights? And change the duration of yellow lights?

  6. Where is the origin (the point where x and y are both 0)?

  7. how is roadLinks different from laneLinks?

I see that CityFlow could be leaps better than SUMO, but there doesn't seem to be enough guide to getting started. And I am willing to read any extra material you can provide.

Since there is no guide, I am digging through roadnet.json and flow.json that others have made to deduce what these fields do, which is a painstaking process.

So a more detailed step-by-step guide that doesn't omit any necessary information would be great.

"point" in the road-net file

I was wondering how the point are determined in the road-net file?
For example, in the following example from a 2-lane example, I see that x and y and distributed in [-10,10]. But, not sure how the numbers are obtained. Can you please explain?

Thanks in advance

{ "type": "go_straight", "startRoad": "road_0_1_0", "endRoad": "road_1_1_0", "direction": 0, "laneLinks": [ { "startLaneIndex": 1, "endLaneIndex": 0, "points": [ {"x": -10.0, "y": -4.5}, {"x": -8.72, "y": -4.416}, {"x": -6.96, "y": -4.188}, {"x": -4.84, "y": -3.852}, {"x": -2.48, "y": -3.444}, {"x": 0.0, "y": -3.0}, {"x": 2.48, "y": -2.556}, {"x": 4.84, "y": -2.148}, {"x": 6.96, "y": -1.811999999999999}, {"x": 8.72, "y": -1.584}, {"x": 10.0, "y": -1.5} ] }, { "startLaneIndex": 1, "endLaneIndex": 1, "points": [ {"x": -10.0, "y": -4.5}, {"x": -8.72, "y": -4.5}, {"x": -6.96, "y": -4.5}, {"x": -4.84, "y": -4.5}, {"x": -2.48, "y": -4.5}, {"x": 0.0, "y": -4.5}, {"x": 2.48, "y": -4.5}, {"x": 4.84, "y": -4.5}, {"x": 6.96, "y": -4.499999999999999}, {"x": 8.72, "y": -4.5}, {"x": 10.0, "y": -4.5} ] } ] }, { "type": "turn_left", "startRoad": "road_2_1_2", "endRoad": "road_1_1_3", "direction": 2, "laneLinks": [ { "startLaneIndex": 0, "endLaneIndex": 0, "points": [ {"x": 10.0, "y": 1.5}, {"x": 8.868, "y": 1.268}, {"x": 7.524, "y": 0.624}, {"x": 6.046, "y": -0.354}, {"x": 4.512, "y": -1.588}, {"x": 3.0, "y": -3.0}, {"x": 1.588, "y": -4.512}, {"x": 0.354, "y": -6.046}, {"x": -0.624, "y": -7.524}, {"x": -1.268, "y": -8.868}, {"x": -1.5, "y": -10.0} ] }, { "startLaneIndex": 0, "endLaneIndex": 1, "points": [ {"x": 10.0, "y": 1.5}, {"x": 8.784, "y": 1.268}, {"x": 7.212, "y": 0.624}, {"x": 5.398, "y": -0.354}, {"x": 3.456, "y": -1.588}, {"x": 1.5, "y": -3.0}, {"x": -0.356, "y": -4.512}, {"x": -1.998, "y": -6.046}, {"x": -3.312, "y": -7.524}, {"x": -4.184, "y": -8.868}, {"x": -4.5, "y": -10.0} ] } ] }

Bug report: `Engine.next_step()` segfaults

Engine.next_step() segfaults.

Background

I am using roadnet and flow generated with :

python generate_grid_scenario.py 1 1 --roadnetFile 1x1_roadnet.json --flowFile 1x1_flow.json --dir . --tlPlan --numLeftLanes 2 --numRightLanes 1 --numStraightLanes 5

A peculiar observation is: there are only cars that go straight. No cars try to make right or left turns even if there are right and left turn lanes.

Replay files

I have attached two replay files and a roadnet log file. replay_fine.txt goes to completion without any error, but replay_error.txt which is supposed to run for as many steps as replay_fine.txt only runs for 870 steps then it segfaults on next_step().

I first thought it was due the vertical lanes being completely clogged, but this doesn't cause segfault in replay_fine.txt even if it is clogged for a longer period of time.

The phase are set correctly, as there is a check for a proper phase index.

replays.zip

Build Error

OS: CentOS7
Python: 3.6.8
Cmake: 3.13.5
executed command: sudo ~/.virtualenvs/cityflow/bin/pip3 install .
gcc & g++: 4.8.5

Error message:

Installing collected packages: CityFlow
  Running setup.py install for CityFlow ... error
    ERROR: Command errored out with exit status 1:
     command: /home/isaac/.virtualenvs/cityflow/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-b1n7sori/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-b1n7sori/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-3d_a1qba/install-record.txt --single-version-externally-managed --compile --install-headers /home/isaac/.virtualenvs/cityflow/include/site/python3.6/CityFlow
         cwd: /tmp/pip-req-build-b1n7sori/
    Complete output (111 lines):
    running install
    running build
    running build_ext
    -- The C compiler identification is GNU 4.8.5
    -- The CXX compiler identification is GNU 4.8.5
    -- Check for working C compiler: /bin/cc
    -- Check for working C compiler: /bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /bin/c++
    -- Check for working CXX compiler: /bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Found Submodule: extern/pybind11/CMakeLists.txt
    -- Found Submodule: extern/rapidjson/include
    -- Found PythonInterp: /home/isaac/.virtualenvs/cityflow/bin/python3.6 (found version "3.6.8")
    -- Found PythonLibs: python3.6m
    -- pybind11 v2.3.dev0
    -- Looking for pthread.h
    -- Looking for pthread.h - found
    -- Looking for pthread_create
    -- Looking for pthread_create - not found
    -- Looking for pthread_create in pthreads
    -- Looking for pthread_create in pthreads - not found
    -- Looking for pthread_create in pthread
    -- Looking for pthread_create in pthread - found
    -- Found Threads: TRUE
    -- Boost version: 1.53.0
    -- Found the following Boost libraries:
    --   thread
    --   chrono
    --   system
    --   date_time
    --   atomic
    -- Boost version: 1.53.0
    -- Found the following Boost libraries:
    --   program_options
    -- Performing Test HAS_FLTO
    -- Performing Test HAS_FLTO - Success
    -- LTO enabled
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /tmp/pip-req-build-b1n7sori/build/temp.linux-x86_64-3.6
    Scanning dependencies of target cityflow_lib
    [  7%] Building CXX object src/CMakeFiles/cityflow_lib.dir/utility/utility.cpp.o
    [ 14%] Building CXX object src/CMakeFiles/cityflow_lib.dir/engine/engine.cpp.o
    [ 21%] Building CXX object src/CMakeFiles/cityflow_lib.dir/flow/flow.cpp.o
    [ 28%] Building CXX object src/CMakeFiles/cityflow_lib.dir/flow/route.cpp.o
    [ 35%] Building CXX object src/CMakeFiles/cityflow_lib.dir/roadnet/roadnet.cpp.o
    [ 42%] Building CXX object src/CMakeFiles/cityflow_lib.dir/roadnet/trafficlight.cpp.o
    [ 50%] Building CXX object src/CMakeFiles/cityflow_lib.dir/vehicle/router.cpp.o
    [ 57%] Building CXX object src/CMakeFiles/cityflow_lib.dir/vehicle/vehicle.cpp.o
    [ 64%] Building CXX object src/CMakeFiles/cityflow_lib.dir/vehicle/lanechange.cpp.o
    [ 71%] Linking CXX static library libcityflow_lib.a
    [ 71%] Built target cityflow_lib
    Scanning dependencies of target cityflow_test
    Scanning dependencies of target cityflow
    [ 78%] Building CXX object CMakeFiles/cityflow_test.dir/src/test.cpp.o
    [ 85%] Building CXX object CMakeFiles/cityflow.dir/src/simulator.cpp.o
    In file included from /tmp/pip-req-build-b1n7sori/extern/pybind11/include/pybind11/pytypes.h:12:0,
                     from /tmp/pip-req-build-b1n7sori/extern/pybind11/include/pybind11/cast.h:13,
                     from /tmp/pip-req-build-b1n7sori/extern/pybind11/include/pybind11/attr.h:13,
                     from /tmp/pip-req-build-b1n7sori/extern/pybind11/include/pybind11/pybind11.h:44,
                     from /tmp/pip-req-build-b1n7sori/src/simulator.cpp:3:
    /tmp/pip-req-build-b1n7sori/extern/pybind11/include/pybind11/detail/common.h:112:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.
    gmake[2]: *** [CMakeFiles/cityflow.dir/src/simulator.cpp.o] Error 1
    gmake[1]: *** [CMakeFiles/cityflow.dir/all] Error 2
    gmake[1]: *** Waiting for unfinished jobs....
    [ 92%] Linking CXX executable cityflow_test
    [ 92%] Built target cityflow_test
    gmake: *** [all] Error 2
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-b1n7sori/setup.py", line 68, in <module>
        zip_safe=False
      File "/home/isaac/.virtualenvs/cityflow/lib/python3.6/site-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib64/python3.6/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib64/python3.6/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/home/isaac/.virtualenvs/cityflow/lib/python3.6/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/lib64/python3.6/distutils/command/install.py", line 556, in run
        self.run_command('build')
      File "/usr/lib64/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib64/python3.6/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/usr/lib64/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/tmp/pip-req-build-b1n7sori/setup.py", line 32, in run
        self.build_extension(ext)
      File "/tmp/pip-req-build-b1n7sori/setup.py", line 57, in build_extension
        subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
      File "/usr/lib64/python3.6/subprocess.py", line 311, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '-j2']' returned non-zero exit status 2.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/isaac/.virtualenvs/cityflow/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-b1n7sori/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-b1n7sori/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-3d_a1qba/install-record.txt --single-version-externally-managed --compile --install-headers /home/isaac/.virtualenvs/cityflow/include/site/python3.6/CityFlow Check the logs for full command output.

Adding Cityflow module to gym

I am working on a small repository that adds Cityflow to OpenAI's gym RL library, and I am planning on open-sourcing it soon. I am starting with a very simple and minimal setting, and am hoping to expand it down the road. One of the reasons I want to open-source it is Cityflow is an amazing library leaps a head of SUMO, and yet not as many people are aware of it. By adding it to one of the most popular RL libraries, I am hoping more people would get easier access to Cityflow.

Would you guys be willing to help with this repository? I would really appreciate any feedback or contributions.

Thanks

can't view saved replay

works on demo replay

viewing sample replay files: replay.txt and roadnet.json that you can download with download_replay.py works fine. When I turn on app.py and go to this address:

http://localhost:8080/?roadnetFile=roadnet.json&logFile=replay.txt

The replay is displayed fine.

Doesn't work for my replay

However, if I try to view my custom replay files (ep_9.txt and roadnet.json) that I have saved under /home/isaac/CityFlow/frontend/replay/debug with this URL:

http://localhost:8080/?roadnetFile=debug/roadnet.json&logFile=debug/ep_9.txt

the browser hangs.

Screen Shot 2019-09-06 at 17 18 45 PM

here is the output of python app.py:

 * Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
127.0.0.1 - - [06/Sep/2019 17:09:46] "GET /?roadnetFile=roadnet.json&logFile=replay.txt HTTP/1.1" 200 -
127.0.0.1 - - [06/Sep/2019 17:10:43] "GET /?roadnetFile=debug/roadnet.json&logFile=debug/ep_9.txt HTTP/1.1" 200 -

my replay files

replay.zip

Enable randomness in flow

For each vehicle in flow, there should be a probability keepProb, which means with probability keepProb the vehicle is put into roadnet. This adds randomness in each rollout, which prevent RL algorithm from overfitting.

Errors raised in loading roadnet file

I get errors on loading roadnet.json file. The strange thing is I have made no modifications to: config.json, roadnet.json, and flow.json or their paths. I have made sure of this by comparing git history. And the same setup worked just fine.

directory structure

1x1_config/
        config.json
        flow.json
        roadnet.json

If I run the blow python command inside 1x1_config:

>>> import cityflow
>>> eng = cityflow.Engine("config.json")

I get below error message:

roadnet: expected type object
load config failed!

cannot load built-in example config.json

I was able to reproduce the error with the builtin examples. Under the examples directory, I started python interpreter and typed:

>>> import cityflow
>>> eng = cityflow.Engine("config.json")

and got error:

cannot open roadnet file
loading roadnet file error!
load config failed!

The generated replayLogFile does not show vehicles in the replay simulator

I run an easy demo to generate replay files, 'roadnet.json', 'flow.json', 'config.json' are same as the files below in 'example' folder.
The demo code are shown as follows:

import cityflow

eng = cityflow.Engine('examples/config.json')

for i in range(500):
    eng.next_step()

I can get roadnetLogFile and replayLogFile, and the road, number of vehicles, current step are shown correctly.
However, vehicles are invisible in the replay simulator.
So, how to make vehicles display normally during the replay process?

`Converter.py` error

**python version: ** 3.6.8

command: python converter.py --sumonet /home/isaac/rainbow_dqn_traffic_signal_control/sumo_config/tlcs.net.xml --cityflownet /home/isaac/rainbow_dqn_traffic_signal_control/sumo_config/tlcs.json

output message:

/usr/share/sumo/tools
Converting sumo net file /home/isaac/rainbow_dqn_traffic_signal_control/sumo_config/tlcs.net.xml
Start processing 1 traffic lights
TL
Traceback (most recent call last):
  File "converter.py", line 535, in <module>
    main(args)
  File "converter.py", line 514, in main
    final_intersections = get_final_intersections(net,tls_dict,edge_dict)
  File "converter.py", line 450, in get_final_intersections
    intersection = node_to_intersection(node,tls_dict,edge_dict)
  File "converter.py", line 399, in node_to_intersection
    for phase,duration in tls_dict[nodeid]._programs['0']._phases:
TypeError: 'Phase' object is not iterable

Input file:
tlcs.net.xml.zip


When I provide route file -- tlcs_train.rou.xml.zip -- instead of tlcs.net.xml, it works fine.

Can I get the code that generates frontend/replat.txt and frontend/roadnet.json?

I'm very thanks for you about you create a new traffic simulator CityFlow with fundamentally optimized data structures and efficient algorithms. I'm very interesting in this learning platform. But I think the CityFlow's usage introduction is too simple. And I hope I can get the code that generates frontend/replat.txt and frontend/roadnet.json. Thank you for you help.

Is there a way to check for collisions?

I want to disable the automatic non-collision setting to use collisions as a demerit for reinforcment learning. Is this a viable / doable option with this simulator?

If so, i'd much appriciate it if you could help me out with how to approach this.

How do I change the route of a vehicle during simulation?

Who can help me! Because of the traffic jam, I want to change the route of the vehicles about to enter the simulation road, so as to ease/reduce traffic jams. I didn't find a python API that can change the vehicle path. I found lanechange.cpp and lanechange.h in the SRC folder but I'm not sure if the functions in them can change the vehicle path during simulating.

running SUMO simulation

Is there a way to take a SUMO simulation file and generate a cityflow json for the same? I want to overlay it with real world maps and traffic simulations. Any idea how to get around it?

Feature request: changing replay saving & playing path

  1. currently, replay files must be inside CityFlow/frontend/replay. This necessitates copying files from a different directory every time I want to see a replay. Being able to play a replay file in any directory would be very helpful.

  2. Currently, replay files have to be saved to a path related to dir in config.json. However, this may not be an ideal setup. Often, environment-specific files such as config.json want to be saved in a completely unrelated path to log / replay files. Being able to save replay files using set_replay_file API to a path that is unrelated to dir in config.json would be helpful.

cannot open roadnet file

Background

I have two sets of copies of config files: config.json, 1x1_roadnet.json, and 1x1_flow.json. One in /home/isaac/gym_cityflow/gym_cityflow/envs/1x1_config and another in /DATA1/isaac/gym_cityflow/gym_cityflow/envs/1x1_config.

1x1_roadnet.json and 1x1_flow.json are exactly identical in both directories and config.json are almost identical except for "dir".

However, instantiating Engine from /home/isaac/gym_cityflow/gym_cityflow/envs/ works fine while doing the same under /DATA1/isaac/gym_cityflow/gym_cityflow/envs/ doesn't work.


config.json

the contents of config.json are:

/DATA1/isaac/gym_cityflow/gym_cityflow/envs/1x1_config/config.json

{
        "interval": 1.0,
        "seed": 1,
        "dir": "/DATA1/isaac/gym_cityflow/gym_cityflow/envs/1x1_config",
        "roadnetFile": "1x1_roadnet.json",
        "flowFile": "1x1_flow.json",
        "rlTrafficLight": true,
        "saveReplay": true,
        "roadnetLogFile": "roadnetlog.json",
        "replayLogFile": "replay.txt",
        "laneChange": false
}

and
/home/isaac/gym_cityflow/gym_cityflow/envs/1x1_config/config.json

{
        "interval": 1.0,
        "seed": 1,
        "dir": "/home/isaac/gym_cityflow/gym_cityflow/envs/1x1_config/",
        "roadnetFile": "1x1_roadnet.json",
        "flowFile": "1x1_flow.json",
        "rlTrafficLight": true,
        "saveReplay": true,
        "roadnetLogFile": "roadnetlog.json",
        "replayLogFile": "replay.txt",
        "laneChange": false
}

you can see that both config.json files are identical, except for "dir".


1x1_roadnet.json and 1x1_flow.json

both copies of 1x1_roadnet.json and 1x1_flow.json are exactly identical. They are created from: python generate_grid_scenario.py 1 1 --roadnetFile 1x1_roadnet.json --flowFile 1x1_flow.json --dir . --tlPlan --numLeftLanes 2 --numRightLanes 1 --numStraightLanes 5 --turn.


Error

When I start python interpreter under /home/isaac/gym_cityflow/gym_cityflow/envs and:

>>> import cityflow
>>> eng = cityflow.Engine("1x1_config/config.json")

I get no error and Engine is instantiated correctly.

However, when I do the same under /DATA1/isaac/gym_cityflow/gym_cityflow/envs, I get:

>>> import cityflow
>>> eng = cityflow.Engine("1x1_config/config.json")
cannot open roadnet file
loading roadnet file error!
load config failed!

set replay file path with Python API

Feature

The ability to set what file to wrtie the replays to in python runtime using Python API

Why useful

It is common to run hundreds or thousands of episodes. Sometimes we want to look at a specific episode for debugging purposes. Currently, older replays are either overwritten or newer replays are appended to the older replay files. This makes it difficult (impossible in the case older replays are overwritten) to navigate through hundreds of episodes.

How it will be used

while current_episode < total_episodes:
    cityflow.set_replay_path(str(current_episode) + ".txt")) # new API to be added
    # start cityflow

One-lane roads with straight and allowed turn-left traffic movements

I was wondering if CityFlow support the case that there are single lane in a three/four-way intersections in which turn-left is allowed. In other words, does it support the case that one lane can have both straight and turn-left traffic movements? If so, would you mind let me know how can I create the roadnet.json file?
I attached two drawing examples of the corresponding intersections:
four_roads.pdf
three_roads.pdf

Thanks in advance,
Afshin

Feature request: querying specific lane ID

The biggest barrier to trying a new setting (even for users with experience) is the time it takes to figure out the correct lane IDs. Since information from get_lane_vehicle_count() or get_lane_waiting_vehicle_count() require lane ID as a key, it is necessary for us to figure out which lane ID corresponds to which lane, and this is not a trivial task for large environments. It becomes necessary to go through the roadnet.json file and essentially draw out the map yourself by hand, trying to figure out the lane IDs.

An API that allows us to query specific lanes' IDs (ex. outgoing lane IDs for intersection 1, incoming lane IDs for intersection 5, left-turn lane IDs for intersection 3...) would hugely improve user experience. We would no longer have to try to read through the roadnet file. We wouldn't even have to know the mapping of lane IDs to lanes. We would just query a list of lane IDs for lanes of certain specifications.


Edit

Other metadata (ex. number of traffic light phases) querying API would also be helpful. It would be ideal to eliminate the need to dissect roadnet and flow file in general.

Build failed

OS: CentOS7
Python: 3.6.8
Cmake: 3.13.5

executed command: sudo ~/.virtualenvs/cityflow/bin/pip3 install .

    ERROR: Command errored out with exit status 1:
     command: /home/isaac/.virtualenvs/cityflow/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-2g19e6tp/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-2g19e6tp/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-z0iogwys/install-record.txt --single-version-externally-managed --compile --install-headers /home/isaac/.virtualenvs/cityflow/include/site/python3.6/CityFlow
         cwd: /tmp/pip-req-build-2g19e6tp/
    Complete output (117 lines):
    running install
    running build
    running build_ext
    -- The C compiler identification is GNU 4.8.5
    -- The CXX compiler identification is GNU 4.8.5
    -- Check for working C compiler: /bin/cc
    -- Check for working C compiler: /bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /bin/c++
    -- Check for working CXX compiler: /bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Found Submodule: extern/pybind11/CMakeLists.txt
    -- Found Submodule: extern/rapidjson/include
    -- Found PythonInterp: /home/isaac/.virtualenvs/cityflow/bin/python3.6 (found version "3.6.8")
    -- Found PythonLibs: python3.6m
    -- pybind11 v2.3.dev0
    -- Looking for pthread.h
    -- Looking for pthread.h - found
    -- Looking for pthread_create
    -- Looking for pthread_create - not found
    -- Looking for pthread_create in pthreads
    -- Looking for pthread_create in pthreads - not found
    -- Looking for pthread_create in pthread
    -- Looking for pthread_create in pthread - found
    -- Found Threads: TRUE
    -- Boost version: 1.53.0
    -- Found the following Boost libraries:
    --   thread
    --   chrono
    --   system
    --   date_time
    --   atomic
    -- Boost version: 1.53.0
    -- Found the following Boost libraries:
    --   program_options
    -- Performing Test HAS_FLTO
    -- Performing Test HAS_FLTO - Success
    -- LTO enabled
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /tmp/pip-req-build-2g19e6tp/build/temp.linux-x86_64-3.6
    Scanning dependencies of target cityflow_lib
    [  7%] Building CXX object src/CMakeFiles/cityflow_lib.dir/engine/engine.cpp.o
    [ 14%] Building CXX object src/CMakeFiles/cityflow_lib.dir/utility/utility.cpp.o
    In file included from /tmp/pip-req-build-2g19e6tp/src/utility/utility.cpp:1:0:
    /tmp/pip-req-build-2g19e6tp/src/utility/utility.h:84:54: error: expected class-name before ‘{’ token
         class JsonFormatError: public std::runtime_error {
                                                          ^
    /tmp/pip-req-build-2g19e6tp/src/utility/utility.h: In constructor ‘CityFlow::JsonFormatError::JsonFormatError(const string&)’:
    /tmp/pip-req-build-2g19e6tp/src/utility/utility.h:86:79: error: expected class-name before ‘(’ token
             explicit JsonFormatError(const std::string &info) : std::runtime_error(info){}
                                                                                   ^
    /tmp/pip-req-build-2g19e6tp/src/utility/utility.h:86:79: error: expected ‘{’ before ‘(’ token
    gmake[2]: *** [src/CMakeFiles/cityflow_lib.dir/utility/utility.cpp.o] Error 1
    gmake[2]: *** Waiting for unfinished jobs....
    In file included from /tmp/pip-req-build-2g19e6tp/src/vehicle/vehicle.h:4:0,
                     from /tmp/pip-req-build-2g19e6tp/src/flow/flow.h:4,
                     from /tmp/pip-req-build-2g19e6tp/src/engine/engine.h:4,
                     from /tmp/pip-req-build-2g19e6tp/src/engine/engine.cpp:1:
    /tmp/pip-req-build-2g19e6tp/src/utility/utility.h:84:54: error: expected class-name before ‘{’ token
         class JsonFormatError: public std::runtime_error {
                                                          ^
    /tmp/pip-req-build-2g19e6tp/src/utility/utility.h: In constructor ‘CityFlow::JsonFormatError::JsonFormatError(const string&)’:
    /tmp/pip-req-build-2g19e6tp/src/utility/utility.h:86:79: error: expected class-name before ‘(’ token
             explicit JsonFormatError(const std::string &info) : std::runtime_error(info){}
                                                                                   ^
    /tmp/pip-req-build-2g19e6tp/src/utility/utility.h:86:79: error: expected ‘{’ before ‘(’ token
    /tmp/pip-req-build-2g19e6tp/src/engine/engine.cpp: In member function ‘bool CityFlow::Engine::loadConfig(const string&)’:
    /tmp/pip-req-build-2g19e6tp/src/engine/engine.cpp:81:28: error: ‘const class CityFlow::JsonFormatError’ has no member named ‘what’
                 std::cerr << e.what() << std::endl;
                                ^
    /tmp/pip-req-build-2g19e6tp/src/engine/engine.cpp: In member function ‘bool CityFlow::Engine::loadFlow(const string&)’:
    /tmp/pip-req-build-2g19e6tp/src/engine/engine.cpp:149:28: error: ‘const class CityFlow::JsonFormatError’ has no member named ‘what’
                 std::cerr << e.what() << std::endl;
                                ^
    gmake[2]: *** [src/CMakeFiles/cityflow_lib.dir/engine/engine.cpp.o] Error 1
    gmake[1]: *** [src/CMakeFiles/cityflow_lib.dir/all] Error 2
    gmake: *** [all] Error 2
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-2g19e6tp/setup.py", line 68, in <module>
        zip_safe=False
      File "/home/isaac/.virtualenvs/cityflow/lib/python3.6/site-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib64/python3.6/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib64/python3.6/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/home/isaac/.virtualenvs/cityflow/lib/python3.6/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/lib64/python3.6/distutils/command/install.py", line 556, in run
        self.run_command('build')
      File "/usr/lib64/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/lib64/python3.6/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/usr/lib64/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib64/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/tmp/pip-req-build-2g19e6tp/setup.py", line 32, in run
        self.build_extension(ext)
      File "/tmp/pip-req-build-2g19e6tp/setup.py", line 57, in build_extension
        subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
      File "/usr/lib64/python3.6/subprocess.py", line 311, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '-j2']' returned non-zero exit status 2.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/isaac/.virtualenvs/cityflow/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-2g19e6tp/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-2g19e6tp/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-z0iogwys/install-record.txt --single-version-externally-managed --compile --install-headers /home/isaac/.virtualenvs/cityflow/include/site/python3.6/CityFlow Check the logs for full command output.

Inconsistency with pytorch

It seems that there is some level of inconsistency with pytorch, such that I cannot import cityflow and torch together. See below:

import cityflow
import torch 
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)  

feature request: turning replay on / off

Writing replay for all training episode turns out to be very expensive in disk memory (since each training lasts for tens of thousands of episodes, each hours long in real time). Ideally, I want to turn off saving replay during training to conserve disk space and turn on replay during evaluation (which happens during training, at least for Rainbow DQN). A simple API to turn on / off saving replay would be really helpful!

Thanks.

Does cityflow support vehicles with different size

If I simulate a bus having width of 2 lanes, a car (as usual with width of 1 lane) and a motorbike with a high speed, can cityflow support such difference in vehicles' sizes/speeds.
If yes, is there a way to get back the type (size) of vehicle back from simulator.

Turn-Right traffic on two lane road

I was wondering if it is valid to have turn-right traffic in an intersection that each of its roads have two lanes, one straight and one left?
In the real-world, usually, in the straight-only lanes cars are allowed to turn light on the green signal. I was not sure if it is considered in the CityFlow or not.

Simple main cpp demo

May your team provide a simplest running example of a pure C++ main.cpp?Thank you!

Memory usage

I use cityflow to simulate a 2*2 road net in macOS, when its step reaches around 500, it turns out the memory usage of the python program is more than 2GB. Is this a normal case or my personal issue that the simulator consumes this much memory?

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.