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)
/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/aequilibrae/project/network/network.py:327: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
df = pd.read_sql(sql, conn).fillna(value=np.nan)
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()
Equilibrium Assignment: 0%| | 0/50 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
All-or-Nothing: 0%| | 0/24 [00:00<?, ?it/s]
with open(join(fldr, "aequilibrae.log")) as file:
for idx, line in enumerate(file):
print(idx + 1, "-", line)
1 - 2024-07-26 23:46:24,740;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2 - 2024-07-26 23:46:24,768;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
3 - 2024-07-26 23:46:24,795;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
4 - 2024-07-26 23:46:24,823;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
5 - 2024-07-26 23:46:24,851;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
6 - 2024-07-26 23:46:24,878;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
7 - 2024-07-26 23:46:24,897;WARNING ; Cost field with wrong type. Converting to float64
8 - 2024-07-26 23:46:25,144;INFO ; Traffic Class specification
9 - 2024-07-26 23:46:25,144;INFO ; {'car': {'Graph': "{'Mode': 'c', 'Block through centroids': False, 'Number of centroids': 24, 'Links': 76, 'Nodes': 24}", 'Matrix': "{'Source': '/tmp/abbea16a4670431c851241f2ac4cb98c/matrices/demand.omx', 'Number of centroids': 24, 'Matrix cores': ['matrix'], 'Matrix totals': {'matrix': 360600.0}}"}}
10 - 2024-07-26 23:46:25,144;INFO ; Traffic Assignment specification
11 - 2024-07-26 23:46:25,144;INFO ; {'VDF parameters': {'alpha': 0.15, 'beta': 4.0}, 'VDF function': 'bpr', 'Number of cores': 4, 'Capacity field': 'capacity', 'Time field': 'free_flow_time', 'Algorithm': 'bfw', 'Maximum iterations': 250, 'Target RGAP': 0.0001}
12 - 2024-07-26 23:46:25,146;WARNING ; Cost field with wrong type. Converting to float64
13 - 2024-07-26 23:46:25,149;INFO ; bfw Assignment STATS
14 - 2024-07-26 23:46:25,149;INFO ; Iteration, RelativeGap, stepsize
15 - 2024-07-26 23:46:25,156;INFO ; 1,inf,1.0
16 - 2024-07-26 23:46:25,164;INFO ; 2,0.8550751349428284,0.32839952448634563
17 - 2024-07-26 23:46:25,174;INFO ; 3,0.4763455007221067,0.18660240547488702
18 - 2024-07-26 23:46:25,183;INFO ; 4,0.2355126365951965,0.2411477440291793
19 - 2024-07-26 23:46:25,191;INFO ; 5,0.10924072010481088,0.8185470737942447
20 - 2024-07-26 23:46:25,202;INFO ; 6,0.1980945227617506,0.14054330572978305
21 - 2024-07-26 23:46:25,214;INFO ; 7,0.0668172221544687,0.36171152718899235
22 - 2024-07-26 23:46:25,223;INFO ; 8,0.06792122267870576,0.9634685345644022
23 - 2024-07-26 23:46:25,231;INFO ; 9,0.10705582933092841,0.13757153109677167
24 - 2024-07-26 23:46:25,239;INFO ; 10,0.04038814432034633,0.16094034254279746
25 - 2024-07-26 23:46:25,248;INFO ; 11,0.027952481137756665,0.3408928228700516
26 - 2024-07-26 23:46:25,256;INFO ; 12,0.03269999206552473,0.5467680533028664
27 - 2024-07-26 23:46:25,266;INFO ; 13,0.024040970172177465,0.13812236751253093
28 - 2024-07-26 23:46:25,274;INFO ; 14,0.02145103090950847,0.1970528150890548
29 - 2024-07-26 23:46:25,286;INFO ; 15,0.01711663825927433,0.33993816583363684
30 - 2024-07-26 23:46:25,298;INFO ; 16,0.01735082411129617,0.7287610532385379
31 - 2024-07-26 23:46:25,308;INFO ; 17,0.02116470546437171,0.08183287977099409
32 - 2024-07-26 23:46:25,318;INFO ; 18,0.012464530324248888,0.15115985804759452
33 - 2024-07-26 23:46:25,326;INFO ; 19,0.01254978991985068,0.1683404948154042
34 - 2024-07-26 23:46:25,338;INFO ; 20,0.011860719789715,0.5399903522726939
35 - 2024-07-26 23:46:25,355;INFO ; 21,0.012859165521052455,0.05496659199654795
36 - 2024-07-26 23:46:25,370;INFO ; 22,0.007671197552803449,0.061255615573591514
37 - 2024-07-26 23:46:25,379;INFO ; 23,0.0055291789072302415,0.07401911120607103
38 - 2024-07-26 23:46:25,389;INFO ; 24,0.005466797330664798,0.1917097792435685
39 - 2024-07-26 23:46:25,398;INFO ; 25,0.007073668823305666,0.4228720696282328
40 - 2024-07-26 23:46:25,410;INFO ; 26,0.009664731222549973,0.9410177051612054
41 - 2024-07-26 23:46:25,419;INFO ; 27,0.008756083467128792,0.051726110618746685
42 - 2024-07-26 23:46:25,430;INFO ; 28,0.005105221228052903,0.06397929882333767
43 - 2024-07-26 23:46:25,438;INFO ; 29,0.0035319062476952537,0.05059090498822049
44 - 2024-07-26 23:46:25,446;INFO ; 30,0.0031482926233629993,0.05843748781795877
45 - 2024-07-26 23:46:25,454;INFO ; 31,0.003063209044596168,0.0917313896798221
46 - 2024-07-26 23:46:25,466;INFO ; 32,0.002664650770773266,0.07094979246384611
47 - 2024-07-26 23:46:25,475;INFO ; 33,0.002302802037873827,0.12412864151961862
48 - 2024-07-26 23:46:25,486;INFO ; 34,0.0027510302560621543,0.12799355702542464
49 - 2024-07-26 23:46:25,494;INFO ; 35,0.0021256347783020885,0.1662038793394671
50 - 2024-07-26 23:46:25,502;INFO ; 36,0.00209949122320099,0.10282963642093347
51 - 2024-07-26 23:46:25,514;INFO ; 37,0.001440776365724902,0.14492101336881905
52 - 2024-07-26 23:46:25,523;INFO ; 38,0.0014180447043991415,0.06529689866673664
53 - 2024-07-26 23:46:25,534;INFO ; 39,0.0009714813735978865,0.0939925733525401
54 - 2024-07-26 23:46:25,534;INFO ; bfw Assignment finished. 39 iterations and 0.0009714813735978865 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.
Log image by https://oldschool.runescape.wiki/index.php?curid=66905#
Total running time of the script: (0 minutes 0.901 seconds)