# 9.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.computational_view(['matrix']) # We will only assign one user class stored as 'matrix' inside the OMX file

project = Project()
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)

# Link flow results are here
results = assigclass.results

# skims are here
avg_skims = assigclass.results.skims # blended ones
last_skims = assigclass._aon_results.skims # those for the last iteration

__init__() → None

Initialize self. See help(type(self)) for accurate signature.

Methods

 Initialize self. algorithms_available() Returns all algorithms available for use execute() Processes assignment 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_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

Initialize self. See help(type(self)) for accurate signature.