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()
with open(join(fldr, "aequilibrae.log")) as file:
    for idx, line in enumerate(file):
        print(idx + 1, "-", line)
1 - 2024-08-19 06:18:17,489;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations

2 - 2024-08-19 06:18:17,517;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations

3 - 2024-08-19 06:18:17,546;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations

4 - 2024-08-19 06:18:17,574;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations

5 - 2024-08-19 06:18:17,602;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations

6 - 2024-08-19 06:18:17,631;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations

7 - 2024-08-19 06:18:17,649;WARNING ; Cost field with wrong type. Converting to float64

8 - 2024-08-19 06:18:17,901;INFO ; Traffic Class specification

9 - 2024-08-19 06:18:17,902;INFO ; {'car': {'Graph': "{'Mode': 'c', 'Block through centroids': False, 'Number of centroids': 24, 'Links': 76, 'Nodes': 24}", 'Matrix': "{'Source': '/tmp/eeba37449b5242c09ede6af08cccc01e/matrices/demand.omx', 'Number of centroids': 24, 'Matrix cores': ['matrix'], 'Matrix totals': {'matrix': 360600.0}}"}}

10 - 2024-08-19 06:18:17,902;INFO ; Traffic Assignment specification

11 - 2024-08-19 06:18:17,902;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-08-19 06:18:17,904;WARNING ; Cost field with wrong type. Converting to float64

13 - 2024-08-19 06:18:17,904;INFO ; bfw Assignment STATS

14 - 2024-08-19 06:18:17,904;INFO ; Iteration, RelativeGap, stepsize

15 - 2024-08-19 06:18:17,912;INFO ; 1,inf,1.0

16 - 2024-08-19 06:18:17,917;INFO ; 2,0.8550751349428284,0.32839952448634563

17 - 2024-08-19 06:18:17,921;INFO ; 3,0.4763455007221067,0.18660240547488702

18 - 2024-08-19 06:18:17,926;INFO ; 4,0.2355126365951965,0.2411477440291793

19 - 2024-08-19 06:18:17,930;INFO ; 5,0.10924072010481088,0.8185470737942447

20 - 2024-08-19 06:18:17,935;INFO ; 6,0.1980945227617506,0.14054330572978305

21 - 2024-08-19 06:18:17,939;INFO ; 7,0.0668172221544687,0.36171152718899235

22 - 2024-08-19 06:18:17,945;INFO ; 8,0.06792122267870576,0.9634685345644022

23 - 2024-08-19 06:18:17,950;INFO ; 9,0.10705582933092841,0.13757153109677167

24 - 2024-08-19 06:18:17,957;INFO ; 10,0.04038814432034621,0.16094034254279752

25 - 2024-08-19 06:18:17,961;INFO ; 11,0.02795248113775691,0.3408928228700519

26 - 2024-08-19 06:18:17,968;INFO ; 12,0.032699992065524604,0.5467680533028708

27 - 2024-08-19 06:18:17,973;INFO ; 13,0.024040970172177347,0.13812236751253115

28 - 2024-08-19 06:18:17,978;INFO ; 14,0.02145103090950847,0.1970528150890536

29 - 2024-08-19 06:18:17,984;INFO ; 15,0.01711663825927409,0.339938165833639

30 - 2024-08-19 06:18:17,993;INFO ; 16,0.01735082411129593,0.7287610532385608

31 - 2024-08-19 06:18:17,998;INFO ; 17,0.021164705464372085,0.08183287977099543

32 - 2024-08-19 06:18:18,004;INFO ; 18,0.012464530324249264,0.1511598580475933

33 - 2024-08-19 06:18:18,009;INFO ; 19,0.012549789919850556,0.16834049481540092

34 - 2024-08-19 06:18:18,017;INFO ; 20,0.01186071978971438,0.5399903522726657

35 - 2024-08-19 06:18:18,025;INFO ; 21,0.012859165521051463,0.054966591996545584

36 - 2024-08-19 06:18:18,030;INFO ; 22,0.007671197552803449,0.061255615573588974

37 - 2024-08-19 06:18:18,037;INFO ; 23,0.0055291789072302415,0.07401911120606758

38 - 2024-08-19 06:18:18,042;INFO ; 24,0.0054667973306647966,0.191709779243585

39 - 2024-08-19 06:18:18,046;INFO ; 25,0.007073668823306543,0.4228720696283197

40 - 2024-08-19 06:18:18,053;INFO ; 26,0.009664731222551466,0.9410177051614603

41 - 2024-08-19 06:18:18,058;INFO ; 27,0.008756083467130159,0.0517261106187546

42 - 2024-08-19 06:18:18,062;INFO ; 28,0.005105221228053528,0.06397929882334243

43 - 2024-08-19 06:18:18,073;INFO ; 29,0.0035319062476952545,0.05059090498821875

44 - 2024-08-19 06:18:18,081;INFO ; 30,0.0031482926233624984,0.058437487817954215

45 - 2024-08-19 06:18:18,086;INFO ; 31,0.003063209044595543,0.09173138967981778

46 - 2024-08-19 06:18:18,090;INFO ; 32,0.0026646507707733915,0.07094979246385001

47 - 2024-08-19 06:18:18,097;INFO ; 33,0.002302802037873952,0.1241286415196512

48 - 2024-08-19 06:18:18,101;INFO ; 34,0.0027510302560630273,0.12799355702549403

49 - 2024-08-19 06:18:18,106;INFO ; 35,0.002125634778303211,0.1662038793394487

50 - 2024-08-19 06:18:18,113;INFO ; 36,0.002099491223200739,0.10282963642091511

51 - 2024-08-19 06:18:18,121;INFO ; 37,0.0014407763657242768,0.1449210133686946

52 - 2024-08-19 06:18:18,128;INFO ; 38,0.001418044704398517,0.06529689866671036

53 - 2024-08-19 06:18:18,132;INFO ; 39,0.0009714813735968882,0.09399257335234756

54 - 2024-08-19 06:18:18,133;INFO ; bfw Assignment finished. 39 iterations and 0.0009714813735968882 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.751 seconds)

Gallery generated by Sphinx-Gallery