6.5.7. aequilibrae.TrafficAssignment¶
- class aequilibrae.TrafficAssignment¶
Bases:
object
Traffic assignment class
For a comprehensive example on use, see the Use examples page.
from os.path import join from aequilibrae.matrix import AequilibraeMatrix from aequilibrae.paths import TrafficAssignment, TrafficClass fldr = 'D:/release/Sample models/sioux_falls_2020_02_15' proj_name = 'SiouxFalls.sqlite' dt_fldr = '0_tntp_data' prj_fldr = '1_project' demand = AequilibraeMatrix() demand.load(join(fldr, dt_fldr, 'demand.omx')) demand.computational_view(['matrix']) # We will only assign one user class stored as 'matrix' inside the OMX file project = Project() project.load(join(fldr, prj_fldr)) project.network.build_graphs() graph = project.network.graphs['c'] # we grab the graph for cars graph.set_graph('free_flow_time') # let's say we want to minimize time graph.set_skimming(['free_flow_time', 'distance']) # And will skim time and distance graph.set_blocked_centroid_flows(True) # Creates the assignment class assigclass = TrafficClass(graph, demand) assig = TrafficAssignment() # The first thing to do is to add at list of traffic classes to be assigned assig.set_classes([assigclass]) assig.set_vdf("BPR") # This is not case-sensitive # Then we set the volume delay function assig.set_vdf_parameters({"alpha": "b", "beta": "power"}) # And its parameters assig.set_capacity_field("capacity") # The capacity and free flow travel times as they exist in the graph assig.set_time_field("free_flow_time") # And the algorithm we want to use to assign assig.set_algorithm('bfw') # since I haven't checked the parameters file, let's make sure convergence criteria is good assig.max_iter = 1000 assig.rgap_target = 0.00001 assig.execute() # we then execute the assignment # Convergence report is here import pandas as pd convergence_report = pd.DataFrame(assig.assignment.convergence_report) convergence_report.head() # Assignment results can be viewed as a Pandas DataFrame results_df = assig.results() # information on the assignment setup can be recovered with info = assig.info() # Or save it directly to the results database results = assig.save_results(table_name='example_from_the_documentation') # skims are here avg_skims = assigclass.results.skims # blended ones last_skims = assigclass._aon_results.skims # those for the last iteration
- __init__() None ¶
Methods
__init__
()add_class
(traffic_class)Adds a traffic class to the assignment
algorithms_available
()Returns all algorithms available for use
execute
()Processes assignment
info
()Returns information for the traffic assignment procedure
report
()Returns the assignment convergence report
results
()Prepares the assignment results as a Pandas DataFrame
save_results
(table_name[, keep_zero_flows])Saves the assignment results to results_database.sqlite
save_skims
(matrix_name[, which_ones, format])Saves the skims (if any) to the skim folder and registers in the matrix list
set_algorithm
(algorithm)Chooses the assignment algorithm.
set_capacity_field
(capacity_field)Sets the graph field that contains link capacity for the assignment period -> e.g.
set_classes
(classes)Sets Traffic classes to be assigned
set_cores
(cores)Allows one to set the number of cores to be used AFTER traffic classes have been added
set_path_file_format
(file_format)Specify path saving format.
set_save_path_files
(save_it)Turn path saving on or off.
set_time_field
(time_field)Sets the graph field that contains free flow travel time -> e.g.
set_vdf
(vdf_function)Sets the Volume-delay function to be used
set_vdf_parameters
(par)Sets the parameters for the Volume-delay function.
Attributes
all_algorithms
bpr_parameters
- __init__() None ¶