Note
Go to the end to download the full example code
Checking AequilibraE’s log#
AequilibraE’s log is a very useful tool to get more information about what the software is doing under the hood.
Information such as Traffic Class and Traffic Assignment stats, and Traffic Assignment outputs. If you have created your project’s network from OSM, you will also find information on the number of nodes, links, and the query performed to obtain the data.
In this example, we’ll use Sioux Falls data to check the logs, but we strongly encourage you to go ahead and download a place of your choice and perform a traffic assignment!
Imports
from uuid import uuid4
from tempfile import gettempdir
from os.path import join
from aequilibrae.utils.create_example import create_example
from aequilibrae.paths import TrafficAssignment, TrafficClass
We create an empty project on an arbitrary folder
fldr = join(gettempdir(), uuid4().hex)
project = create_example(fldr)
We build our graphs
project.network.build_graphs()
graph = project.network.graphs["c"]
graph.set_graph("free_flow_time")
graph.set_skimming(["free_flow_time", "distance"])
graph.set_blocked_centroid_flows(False)
We get our demand matrix from the project and create a computational view
proj_matrices = project.matrices
demand = proj_matrices.get_matrix("demand_omx")
demand.computational_view(["matrix"])
Now let’s perform our traffic assignment
assig = TrafficAssignment()
assigclass = TrafficClass(name="car", graph=graph, matrix=demand)
assig.add_class(assigclass)
assig.set_vdf("BPR")
assig.set_vdf_parameters({"alpha": 0.15, "beta": 4.0})
assig.set_capacity_field("capacity")
assig.set_time_field("free_flow_time")
assig.set_algorithm("bfw")
assig.max_iter = 50
assig.rgap_target = 0.001
assig.execute()
with open(join(fldr, "aequilibrae.log")) as file:
for idx, line in enumerate(file):
print(idx + 1, "-", line)
1 - 2023-07-10 09:02:53,780;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2 - 2023-07-10 09:02:53,825;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
3 - 2023-07-10 09:02:53,870;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
4 - 2023-07-10 09:02:53,914;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
5 - 2023-07-10 09:02:53,958;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
6 - 2023-07-10 09:02:54,001;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
7 - 2023-07-10 09:02:54,030;WARNING ; Cost field with wrong type. Converting to float64
8 - 2023-07-10 09:02:54,396;INFO ; Traffic Class specification
9 - 2023-07-10 09:02:54,396;INFO ; {'car': {'Graph': "{'Mode': 'c', 'Block through centroids': False, 'Number of centroids': 24, 'Links': 76, 'Nodes': 24}", 'Matrix': "{'Source': '/tmp/9a065f8650564d30b208b2186fe696e6/matrices/demand.omx', 'Number of centroids': 24, 'Matrix cores': ['matrix'], 'Matrix totals': {'matrix': 360600.0}}"}}
10 - 2023-07-10 09:02:54,396;INFO ; Traffic Assignment specification
11 - 2023-07-10 09:02:54,396;INFO ; {'VDF parameters': {'alpha': 0.15, 'beta': 4.0}, 'VDF function': 'bpr', 'Number of cores': 2, 'Capacity field': 'capacity', 'Time field': 'free_flow_time', 'Algorithm': 'bfw', 'Maximum iterations': 250, 'Target RGAP': 0.0001}
12 - 2023-07-10 09:02:54,399;WARNING ; Cost field with wrong type. Converting to float64
13 - 2023-07-10 09:02:54,399;INFO ; bfw Assignment STATS
14 - 2023-07-10 09:02:54,399;INFO ; Iteration, RelativeGap, stepsize
15 - 2023-07-10 09:02:54,405;INFO ; 1,inf,1.0
16 - 2023-07-10 09:02:54,411;INFO ; 2,0.8550751349428284,0.32839952448634563
17 - 2023-07-10 09:02:54,418;INFO ; 3,0.4763455007221067,0.18660240547488702
18 - 2023-07-10 09:02:54,426;INFO ; 4,0.2355126365951965,0.2411477440291793
19 - 2023-07-10 09:02:54,432;INFO ; 5,0.10924072010481088,0.8185470737942447
20 - 2023-07-10 09:02:54,440;INFO ; 6,0.1980945227617506,0.14054330572978305
21 - 2023-07-10 09:02:54,445;INFO ; 7,0.0668172221544687,0.36171152718899247
22 - 2023-07-10 09:02:54,454;INFO ; 8,0.06792122267870587,0.9634685345644044
23 - 2023-07-10 09:02:54,460;INFO ; 9,0.10705582933092855,0.13757153109677187
24 - 2023-07-10 09:02:54,466;INFO ; 10,0.04038814432034622,0.1609403425427973
25 - 2023-07-10 09:02:54,473;INFO ; 11,0.025801226183773084,0.716435057617116
26 - 2023-07-10 09:02:54,479;INFO ; 12,0.042846437173170424,0.08581544277016687
27 - 2023-07-10 09:02:54,485;INFO ; 13,0.016971662333407043,0.1660157969033195
28 - 2023-07-10 09:02:54,491;INFO ; 14,0.020396548012132195,0.4461322062863191
29 - 2023-07-10 09:02:54,497;INFO ; 15,0.025887901335905694,0.08515995223661561
30 - 2023-07-10 09:02:54,503;INFO ; 16,0.015188959427663162,0.1988698342670051
31 - 2023-07-10 09:02:54,509;INFO ; 17,0.01475141964322897,0.3548856159715819
32 - 2023-07-10 09:02:54,516;INFO ; 18,0.015582407302127808,0.06145415154081679
33 - 2023-07-10 09:02:54,522;INFO ; 19,0.008935871473338547,0.08603462968532699
34 - 2023-07-10 09:02:54,528;INFO ; 20,0.008477045208211683,0.1668913886047936
35 - 2023-07-10 09:02:54,534;INFO ; 21,0.009517581409988221,0.4917099156011133
36 - 2023-07-10 09:02:54,539;INFO ; 22,0.013060711845093087,0.060284308755231206
37 - 2023-07-10 09:02:54,545;INFO ; 23,0.006861821876765184,0.10954009782378307
38 - 2023-07-10 09:02:54,551;INFO ; 24,0.006201113315688483,0.12230718464290123
39 - 2023-07-10 09:02:54,557;INFO ; 25,0.0074574049738041406,0.3080614235512652
40 - 2023-07-10 09:02:54,563;INFO ; 26,0.006900497787039256,0.32835666337221175
41 - 2023-07-10 09:02:54,569;INFO ; 27,0.006963554132391016,0.7377893941135681
42 - 2023-07-10 09:02:54,575;INFO ; 28,0.006817764279834173,0.0443870768699142
43 - 2023-07-10 09:02:54,582;INFO ; 29,0.004277860366532555,0.05431813621783447
44 - 2023-07-10 09:02:54,589;INFO ; 30,0.004136181096381436,0.05758294976347482
45 - 2023-07-10 09:02:54,595;INFO ; 31,0.0031483923250298237,0.0918038853550363
46 - 2023-07-10 09:02:54,602;INFO ; 32,0.0034184967969881734,0.12279944254979965
47 - 2023-07-10 09:02:54,609;INFO ; 33,0.002738614050254322,0.08799214942487946
48 - 2023-07-10 09:02:54,615;INFO ; 34,0.0023403784016331874,0.1098259985006849
49 - 2023-07-10 09:02:54,623;INFO ; 35,0.0023185435502055523,0.18741920884713098
50 - 2023-07-10 09:02:54,629;INFO ; 36,0.0023838181828793143,0.1404967362503087
51 - 2023-07-10 09:02:54,636;INFO ; 37,0.0017801377860521138,0.25278698153070905
52 - 2023-07-10 09:02:54,642;INFO ; 38,0.0019264349761422953,0.30768123024764726
53 - 2023-07-10 09:02:54,648;INFO ; 39,0.0018408894375062524,0.3982324050247662
54 - 2023-07-10 09:02:54,655;INFO ; 40,0.0018205742523357215,0.5255149131180074
55 - 2023-07-10 09:02:54,666;INFO ; 41,0.0020224171108353135,0.012343794696331265
56 - 2023-07-10 09:02:54,673;INFO ; 42,0.001423836778473865,0.03045402621736974
57 - 2023-07-10 09:02:54,681;INFO ; 43,0.0011877471305860427,0.02283308748607117
58 - 2023-07-10 09:02:54,689;INFO ; 44,0.0012106681494599195,0.06969126002892805
59 - 2023-07-10 09:02:54,697;INFO ; 45,0.0011336232568064097,0.038970964685986896
60 - 2023-07-10 09:02:54,704;INFO ; 46,0.0009780989052684459,0.022071990851560294
61 - 2023-07-10 09:02:54,704;INFO ; bfw Assignment finished. 46 iterations and 0.0009780989052684459 final gap
In lines 1-7, we receive some warnings that our fields name and lane have NaN values.
As they are not relevant to our example, we can move on.
In lines 8-9 we get the Traffic Class specifications. We can see that there is only one traffic class (car). Its graph key presents information on blocked flow through centroids, number of centroids, links, and nodes. In the matrix key, we find information on where in the disk the matrix file is located. We also have information on the number of centroids and nodes, as well as on the matrix/matrices used for computation. In our example, we only have one matrix named matrix, and the total sum of this matrix element is equal to 360,600. If you have more than one matrix its data will be also displayed in the matrix_cores and matrix_totals keys.
In lines 10-11 the log shows the Traffic Assignment specifications. We can see that the VDF parameters, VDF function, capacity and time fields, algorithm, maximum number of iterations, and target gap are just like the ones we set previously. The only information that might be new to you is the number of cores used for computation. If you haven’t set any, AequilibraE is going to use the largest number of CPU threads available.
Line 12 displays us a warning to indicate that AequilibraE is converting the data type of the cost field.
Lines 13-61 indicate that we’ll receive the outputs of a bfw algorithm.
In the log there are also the number of the iteration, its relative gap, and the stepsize.
The outputs in lines 15-60 are exactly the same as the ones provided by the function
assig.report(). Finally, the last line shows us that the bfw assignment has finished
after 46 iterations because its gap is smaller than the threshold we configured (0.001).
In case you execute a new traffic assignment using different classes or changing the parameters values, these new specification values would be stored in the log file as well so you can always keep a record of what you have been doing. One last reminder is that if we had created our project from OSM, the lines on top of the log would have been different to display information on the queries done to the server to obtain the data.
Total running time of the script: ( 0 minutes 1.070 seconds)