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.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, proj_name)) 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
-
__init__
() → None¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
()Initialize self.
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
-
bpr_parameters
= ['alpha', 'beta']¶
-
all_algorithms
= ['all-or-nothing', 'msa', 'frank-wolfe', 'cfw', 'bfw']¶
-
__init__
() → None Initialize self. See help(type(self)) for accurate signature.
-
set_vdf
(vdf_function: str) → None¶ Sets the Volume-delay function to be used
- Args:
vdf_function(
str
:) Name of the VDF to be used
-
set_classes
(classes: List[aequilibrae.paths.traffic_class.TrafficClass]) → None¶ Sets Traffic classes to be assigned
- Args:
classes(
List[TrafficClass]
:) List of Traffic classes for assignment
-
algorithms_available
() → list¶ Returns all algorithms available for use
- Returns:
list
: List of string values to be used with set_algorithm
-
set_algorithm
(algorithm: str)¶ Chooses the assignment algorithm. e.g. ‘frank-wolfe’, ‘bfw’, ‘msa’
- Args:
algorithm (
list
): Algorithm to be used
-
set_vdf_parameters
(par: dict) → None¶ Sets the parameters for the Volume-delay function.
Parameter values can be scalars (same values for the entire network) or network field names (link-specific values) - Examples: {‘alpha’: 0.15, ‘beta’: 4.0} or {‘alpha’: ‘alpha’, ‘beta’: ‘beta’}
- Args:
par (
dict
): Dictionary with all parameters for the chosen VDF
-
set_cores
(cores: int) → None¶ Allows one to set the number of cores to be used AFTER traffic classes have been added
Inherited from
AssignmentResults
- Args:
cores (
int
): Number of CPU cores to use
-
set_time_field
(time_field: str) → None¶ Sets the graph field that contains free flow travel time -> e.g. ‘fftime’
- Args:
time_field (
str
): Field name
-
set_capacity_field
(capacity_field: str) → None¶ Sets the graph field that contains link capacity for the assignment period -> e.g. ‘capacity1h’
- Args:
capacity_field (
str
): Field name
-
execute
() → None¶ Processes assignment
-
_TrafficAssignment__check_attributes
(instance, value)¶
-
_TrafficAssignment__collect_data
()¶
-
_TrafficAssignment__validate_parameters
(kwargs) → bool¶
-