Algorithms for prediction of congestion from Network State
This code is the repository for implementing algorithms for real-time prediction of macroscopic congestion from network state variables using Deep Learning. The corresponding work is detailed in the following papers:
There is implementation of Graph Convolutional Network (GCN) based on the opensource codebase corresponding to:
The Neural Attention Framework used is based on the concepts discussed in:
The base default test network is represented by the following figure:
To generate plots for test scenarios on test network:
/src/test/python/model_test/test_run_scenarios.py
/src/test/python/model_test/scenario_<Scenario_Index>
.json config parameters:
{
"freeway_links_jam_density"
: List of jam density values (veh/km) for freeway links (between zones),
"check_queue_spillover"
: Update curves after checking queue spillover condition (true/false),
"plot_congestion_io_curves"
: Plot I-0 curves for congestion links (within zones) (true/false),
"freeway_links_length"
: List of lengths (km) for freeway links(between zones),
"get_curves_data"
: Output .csv files for data generated for each curve during simulation (true/false),
"plot_demand_congestion_curves"
: Plot curves for demand vs time and congestion vs time (true/false),
"congestion_links_fftt"
: List of free flow travel times (mins) for congestion links (within zones),
"num_bins"
: Number of time bins within a day,
"freeway_links_fftt"
: List of free flow travel times (mins) for freeway links (between zones),
"demand_start_times"
: List of start times (minutes from midnight) for OD demand from each input zone,
"congestion_links_length"
: List of lengths (km) for congestion links (within zones),
"threshold_output_for_congestion"
: List of minimum congestion metric value (mins) below which congestion is treated as zero,
"min_intervals"
: Time interval (mins) for each time bin,
"congestion_links_capacity"
: List of capacity values (veh/hr) for congestion links (within zones),
"demand_slopes"
: List of slopes (veh/hr/min) of OD demand curves (equal positive and negative slopes),
"demand_end_times"
:List of end times (minutes from midnight) for OD demand from each input zone,
"file_directory"
: File path for base directory,
"num_zones"
: Total number of zones,
"plot_route_choice_io_curves"
: Plot IO curves for freeway links to compare route choice (true/false),
"check_route_choice"
: Update curves if users choose route to satisfy Deterministic User Equilibrium (DUE) (true/false),
"congestion_links_jam_density"
: List of jam density values (veh/km) for congestion links (within zones),
"freeway_links_capacity"
: List of capacity values (veh/hr) for freeway links (between zones),
"congestion_nn_smoothening_number"
: Number of nearest neighbors used for smoothening congestion vs time curves
}
/src/main/python/model_test/generate_model_data.py
with following parameters: ./scenario_<Scenario_Index>/config_generate_model_data.json
) lstm_input_data/case_<Case_Index>.csv
)T
, then the previous two parameters are overwritten (T/F) The simplified Bay Area freeway network is represented by the following figure:
To generate data on simplified Bay Area freeway network for fitting models:
Contact corresponding author at sudatta.mohanty@berkeley.edu for H-W OD demand files, link count files and arrival count files generated for each scenario and run /src/main/python/bay_area_simplified_freeway_network/generate_model_data.py
with following parameters:
config_generate_model_data.json
) .json config parameters:
{
"num_zones"
: Total number of zones,
"num_links"
: Total number of (forward + backward) links,
"congestion_zone_nos"
: List of indices of zones for which congestion metric is calculated over time,
"congestion_nn_smoothening_number"
: Number of nearest neighbors used for smoothening congestion vs time curves,
"threshold_output_for_congestion"
: List of minimum congestion metric value (mins) below which congestion is treated as zero,
"start_day"
: Start day index for simulation,
"end_day"
: End day index for simulation,
"num_profiles"
: Number of possible simulation scanerios for each day (currently 10),
"arrival_count_dir_base_path"
: Base file path for directory containing arrival counts .csv files,
"arrival_count_file_name"
: File name (with extension) for file containing arrival counts,
"link_count_dir_base_path"
: Base file path for directory containing link counts .csv files,
"link_count_file_name"
: File name (with extension) for file containing link counts,
"od_count_dir_base_path"
: Base file path for directory containing OD counts .csv files,
"od_count_dir_name"
: Directory name for OD counts .csv files,
"od_count_base_file_name"
: Base file name (to be appended with index) (without extension) for OD counts .csv files,
"output_file_name"
:Output file name (with .csv extension),
"min_intervals"
: Length (mins) of each time bin
}
Output includes:
./model_test/config_lstm.json
or ./bay_area_simplified_freeway_network/config_lstm_zone_0.json
) .json config parameters:
{
"input_file_path"
: File path of file generated in Step 1,
"input_data_column_index_ranges"
: List of numbers of even size for input column indices(Each consecutive pair is considered a start and end column for inputs into the model. For example [1,3,5,7] implies that the input columns are 1,2,3,5,6,7),
"output_column_index"
: Column index for target output variable,
"n_days"
: Total number of days of data for running model,
"learning_rate"
: Learning rate for gradient descent during optimization,
"batch_size"
: Batch size (continuous indices in time),
"dropout"
: Dropout rate (currently not implemented),
"n_input"
: Number of inputs (must be equal to number of input columns 2),
"n_steps"
: Number of time intervals per input data,
"n_hidden"
: Number of hidden nodes per hidden layer,
"n_outputs"
: Number of time intervals per output data,
"min_lag"
: Number of time intervals between between first time bin of input and first time bin of output,
"n_layers"
: Number of hidden layers,
"display_step"
: Display outputs at this iteration interval,
"n_plot_loss_iter"
: If predicting less than a day, the loss is calculated only at the time intervals at `n_steps [n_plot_loss_iter,n_plot_loss_iter+1](this is to ensure we compare apples to apples!),
“attention_display_step”`:Number of iterations after which attention is displayed (for all consecutive iterations until one full day is covered)
}
Output includes:
display_step
(defined in config .json file) iterations n_steps * [n_plot_loss_iter, n_plot_loss_iter + 1]
time bins) every display_step
iterationsdisplay_step
iterations attention_display_step
iterations (the plots are displayed for all subsequent iterations until temporal attention for all times in the day are covered)attention_display_step
iterations (the plots are displayed for all subsequent iterations until spatial attention for all times in the day are covered)./model_test/config_graph_cnn_lstm.json
or ./bay_area_simplified_freeway_network/config_graph_cnn_lstm_zone_0.json
) .json config parameters:
{
"input_file_path"
: File path of file generated in Step 1,
"shortest_path_adjacency_graph_file_path"
: File path of graph adjacency/weight matrix using shortest path to determine weights,
"trajectory_clustering_adjacency_graph_file_path"
: File path of graph adjacency/weight matrix using trajectory to determine weights,
"input_data_column_index_ranges"
: List of numbers of even size for input column indices(Each consecutive pair is considered a start and end column for inputs into the model. For example [1,3,5,7] implies that the input columns are 1,2,3,5,6,7),
"output_column_index"
: Column index for target output variable,
"n_days"
: Total number of days of data for running model,
"learning_rate"
: Learning rate for gradient descent during optimization,
"decay_rate"
: Decay rate of learning rate per iteration,
"momentum"
: Momentum value for learning rate of previous iteration,
"batch_size"
: Batch size (continuous indices in time),
"eval_frequency"
: Display outputs at this iteration interval,
"regularization"
: L2 regularizations of weights and biases,
"dropout"
: Dropout rate (currently not implemented),
"lstm_n_hidden"
: Number of hidden nodes per hidden LSTM layer,
"lstm_n_outputs"
: Number of time intervals per output data,
"lstm_min_lag"
: Number of time intervals between between first time bin of input and first time bin of output,
"lstm_n_layers"
: Number of hidden LSTM layers,
"display_step"
: Display outputs at this iteration interval,
"n_plot_loss_iter"
: If predicting less than a day, the loss is calculated only at the time intervals at n_steps * [n_plot_loss_iter,n_plot_loss_iter+1]
(this is to ensure we compare apples to apples!),
"cnn_filter"
: Filter type for GCN (Currently only implemented “chebyshev5”),
"cnn_brelu"
: Bias and Relu for GCN (Currently only implemented “b1relu”),
"cnn_pool"
: Pooling for GCN (Currently only implemented maxpooling “mpool1”),
"cnn_num_conv_filters"
: List of number of convolutional filters for each layer of GCN,
"cnn_poly_order"
: List of polynomial orders (filter sizes) for each layer of GCN,
"cnn_pool_size"
: List of pooling size (1 for no pooling and power of 2 to make graph coarser),
"cnn_output_dim"
: Number of features per sample for GCN,
"attention_display_step"
:Number of iterations after which attention is displayed (for all consecutive iterations),
"graph_type"
: Type of graph used (knn / shortest_path / trajectory_clustering)
}
Output includes:
display_step
(defined in config .json file) iterations n_steps * [n_plot_loss_iter, n_plot_loss_iter + 1]
time bins) every display_step
iterationsdisplay_step
iterations attention_display_step
iterations (the plots are displayed for all subsequent iterations)attention_display_step
iterations (the plots are displayed for all subsequent iterations)