Skip to content

Python-based tools for analyzing SQLite databases generated by Aimsun

Notifications You must be signed in to change notification settings

megacell/AimsunAnalysis_FrankShyu

Repository files navigation

Analysis Tool for Large-Scale AimSun-generated Databases

Author: Frank Shyu Contact: [email protected]

Introduction
This is python-based tool for extracting and analyzing SQLite Databases generated by simulation software Aimsun. To run the code, you will need to install

  1. python3.6
  2. numpy
  3. matplotlib

and you should be good to go!

There are four main directories in this repo: src, sqliteDatabases, outputCsvfiles, and outputFigures. For the last three directories, there are already "demo" files for demonstrating the usage of this repo in latter paragraphs.

The src directory contains nine files for different purposes, including calculation of the Average Marginal Regret (still named "Nash Distance" or ND in the comments and variable names of some files), the path flow of different paths, and path travel time of different paths, and the path velocity of different paths. For the detail implementation of code, please refer to the comments in each .py file.

The sqliteDatabases contains results of the Aimsun run, which are SQLite databases storing the output results of dynamic simulations. Since we might run multiple replications for the same experiment (i.e., same traffic demand, vehicle behavior model, traffic condition, and signal plans that differ random seeds ONLY ), each directory under sqliteDatabases must be further divided into directories storing results for different sets of replications. For instance, sqliteDatabases/DemoBenchmarkAccident/ stores all results from the benchmark network with an accident, with the app user percentange being the variable. However, for every app user percentage, we run five replications (i.e., used five different random seeds). Therefore, we divide the directory into:

sqliteDatabases/DemoBenchmarkAccident/run1
sqliteDatabases/DemoBenchmarkAccident/run2
sqliteDatabases/DemoBenchmarkAccident/run3,

each containing runs for app user percentage 10 to 90. Even if you use only one random seed in your experiment, please follow the heirarchy described above. For instance, you should use

sqliteDatabases/MyRuns/run1/app10
sqliteDatabases/MyRuns/run1/...
sqliteDatabases/MyRuns/run1/app90

instead of

sqliteDatabases/MyRuns/app10
sqliteDatabases/MyRuns/...
sqliteDatabases/MyRuns/app90.

The outputCsvfiles store the intermediate results of the runs in .csv format, which might come in handy when debugging either the code or the Aimsun scenarios. When running the code, directories will be generated with the same name as the directory you are working on, with additional information specifying the max/min allowed entrance time to the network. For instance, if you run a code on

sqliteDatabases/MyRuns/,

and specified that only vehicles entering after 7200 seconds into the simulation and before 14400 seconds into the simulation are allowed, there will be a output directory

outputCsvfiles/MyRuns_max_14400_min_7200.

will be generated. Finally, the outputFigures directory, as suggested by its name, stores the output figure of the code you run.

Demo Currently, four python file demos can be run. Please change directory to src. Then, you can type in

python3.6 std1_percentND.py ../sqliteDatabases/DemoBenchmarkAccident 14400 7200
python3.6 std2_percentPathTravelTime.py ../sqliteDatabases/DemoBenchmarkAccident 14400 7200
python3.6 std3_percentPathflow.py ../sqliteDatabases/DemoBenchmarkAccident 14400 7200
python3.6 std4_timeND.py ../sqliteDatabases/DemoBenchmarkAccident 21600 0 600

Note how the last command is different from the remaining three. The SQLite databases under DemoBenchmarkAccident contain simulations with length 6 hours, or 21600 seconds, starting from 12 a.m. (time = 0) to 6 a.m. (time = 21600). For the first three commands, we only look at vehicles entering in the middle two hours of simulation when the car accident is valid. For the last command, since std4 plots how the Nash Distance changes over time, we observe the entire simulation duration. The additional input argument "600" to std4_timeND.py is the size of the time step in seconds. A smaller time step (say 60 seconds) captures the change in time domain better but also generates a more noisy graph. After these commands, you should get five images stored under outputFigures that look identical to the ones stored under outputFigures/demoFigures.

About

Python-based tools for analyzing SQLite databases generated by Aimsun

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages