Documentation for the UE Solver

Conversions

ue_solver.conversions.networkx_to_geojson(graph_f, geojson_outf, simple_geom=False)[source]

Converts graph_f (a networkx graph) into a pandas DataFrame, then converts the DataFrame into a geoJSON file

Parameters:
  • graph_f (networkx) – Input road network
  • geojson_outf (str) – File path of out file
  • simple_geom (bool) – set to True if user wants to use less memory by only saving straight-line paths between origin and destination, rather than actual shape of path
ue_solver.conversions.df_to_geoJson(df, geojson_fileout, with_flow=False)[source]

Converts a pandas DataFrame to a geoJSON file

Parameters:
  • df (DataFrame) – Input DataFrame
  • geojson_outf (str) – File path of out file
ue_solver.conversions.graph_to_network_file(graph, filepath)[source]
Writes networkx traffic graph to a text file according to the FW program requirements.
Format is ‘~ Init/Term/Cap/Length/FreeFlowTime/B=0.15/Power=4/Speed limit/Toll/Type;’ tab delineated, with meta-data.
Parameters:
  • g (networkx) – Input road network
  • filepath (str) – Filepath where graph will be saved

Modify network

ue_solver.modify_network.label_road_network(input_shp, road_network_geojson, attributes, geojson_outf, rename_attributes = None)[source]

Generalized function of append_city_names. Allows user to specify which attributes to keep from the input shape file. Spatial join shape file with network, so that network file now has identifying labels

Parameters:
  • input_shp (str) – filepath for generalized shapefile for cities, neighborhoods, from any state
  • road_network_geojson (str) – filepath for input geoJSON network file
  • attributes ([str]) – either string or array of strings, selected attributes that will be joined
  • geojson_outf (str) – filepath for output file with identifying labels
  • rename_attributes ([str]) – either string or array of strings (should match attributes), can be used if user would like to rename the attributes to more user-friendly names
ue_solver.modify_network.update_capacity(attr_dict, percent_cap, geojson_inf, geojson_outf, graph_f=None)[source]
Parameters:
  • attr_dict (dict) – list of values that will be changed, example: {‘county’: [‘Alameda’, ‘Berkeley’, ‘Emeryville’]}
  • percent_cap (float) – percent of existing capacity roads will now have
  • geojson_in (str) – filepath network geoJSON file
  • geojson_out (str) – filepath save locations of modified network geoJSON file
  • graph_f (str) – path of updated networkx or None if don’t want to save networkx graph

Removes links in the road network to simulate roads being closed off or inaccessible.

Parameters:
  • geojson_inf (str) – filepath network geoJSON file
  • links_f (str) – filepath CSV file of links to delete
  • geojson_outf (str) – filepath network geoJSON file, to save modified network geojson
  • graph_outf (str) – filepath networkx file, reconstructed graph file from geoJSON outfile

Process results

ue_solver.process_results.results_to_geojson(results_f, geojson_inf, geojson_outf)[source]

Results file is merged with the network geojson file based on the init and term ids of each link. Saves geojson with merged results.

Parameters:
  • results_f (str) – filepath of results from solver
  • geojson_inf (str) – filepath to input network geoJSON
  • geojson_outf (str) – filepath to save geoJSON results
ue_solver.process_results.geoj_vmt_vht_delay(results_geoj, cities_aggregate_output_file, output_summary, totalODflow = 0, min_speed = 0, save_path = 0)[source]

Calculates VMT, VHT, and delay from results_geoj

Parameters:
  • results_geoj (str) – filepath for results geoJSON
  • cities_aggregate_output_file (str) – placeholder
  • output_summary (str) – placeholder
  • totalODflow (float) – total demand (number of passengers)
  • min_speed (float) – force speed to min_speed if link speed < min_speed
  • save_path (str) – filepath to save plot to