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-12-16 11:44:44,831;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations

2 - 2023-12-16 11:44:44,859;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations

3 - 2023-12-16 11:44:44,887;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations

4 - 2023-12-16 11:44:44,913;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations

5 - 2023-12-16 11:44:44,940;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations

6 - 2023-12-16 11:44:44,967;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations

7 - 2023-12-16 11:44:44,985;WARNING ; Cost field with wrong type. Converting to float64

8 - 2023-12-16 11:44:45,254;INFO ; Traffic Class specification

9 - 2023-12-16 11:44:45,254;INFO ; {'car': {'Graph': "{'Mode': 'c', 'Block through centroids': False, 'Number of centroids': 24, 'Links': 76, 'Nodes': 24}", 'Matrix': "{'Source': '/tmp/f0fcbf9ba7874a6daab274e0229f5917/matrices/demand.omx', 'Number of centroids': 24, 'Matrix cores': ['matrix'], 'Matrix totals': {'matrix': 360600.0}}"}}

10 - 2023-12-16 11:44:45,254;INFO ; Traffic Assignment specification

11 - 2023-12-16 11:44:45,254;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 - 2023-12-16 11:44:45,256;WARNING ; Cost field with wrong type. Converting to float64

13 - 2023-12-16 11:44:45,256;INFO ; bfw Assignment STATS

14 - 2023-12-16 11:44:45,256;INFO ; Iteration, RelativeGap, stepsize

15 - 2023-12-16 11:44:45,261;INFO ; 1,inf,1.0

16 - 2023-12-16 11:44:45,265;INFO ; 2,0.8550751349428284,0.32839952448634563

17 - 2023-12-16 11:44:45,270;INFO ; 3,0.4763455007221067,0.18660240547488702

18 - 2023-12-16 11:44:45,276;INFO ; 4,0.2355126365951965,0.2411477440291793

19 - 2023-12-16 11:44:45,281;INFO ; 5,0.10924072010481088,0.8185470737942447

20 - 2023-12-16 11:44:45,285;INFO ; 6,0.1980945227617506,0.14054330572978305

21 - 2023-12-16 11:44:45,293;INFO ; 7,0.0668172221544687,0.36171152718899235

22 - 2023-12-16 11:44:45,300;INFO ; 8,0.06792122267870576,0.9634685345644022

23 - 2023-12-16 11:44:45,313;INFO ; 9,0.10705582933092841,0.13757153109677167

24 - 2023-12-16 11:44:45,317;INFO ; 10,0.04038814432034633,0.16094034254279746

25 - 2023-12-16 11:44:45,325;INFO ; 11,0.025801226183773198,0.7164350576171225

26 - 2023-12-16 11:44:45,329;INFO ; 12,0.042846437173171124,0.08581544277016764

27 - 2023-12-16 11:44:45,336;INFO ; 13,0.01697166233340716,0.16601579690331966

28 - 2023-12-16 11:44:45,341;INFO ; 14,0.020396548012132316,0.4461322062863093

29 - 2023-12-16 11:44:45,346;INFO ; 15,0.025887901335905326,0.08515995223661456

30 - 2023-12-16 11:44:45,353;INFO ; 16,0.015188959427662786,0.1988698342670054

31 - 2023-12-16 11:44:45,360;INFO ; 17,0.014751419643229704,0.3548856159715747

32 - 2023-12-16 11:44:45,368;INFO ; 18,0.015582407302127807,0.061454151540816244

33 - 2023-12-16 11:44:45,373;INFO ; 19,0.008935871473338668,0.08603462968532627

34 - 2023-12-16 11:44:45,377;INFO ; 20,0.00847704520821181,0.166891388604795

35 - 2023-12-16 11:44:45,385;INFO ; 21,0.00951758140998847,0.49170991560108357

36 - 2023-12-16 11:44:45,393;INFO ; 22,0.013060711845092839,0.06028430875522849

37 - 2023-12-16 11:44:45,401;INFO ; 23,0.006861821876764934,0.1095400978237806

38 - 2023-12-16 11:44:45,405;INFO ; 24,0.00620111331568848,0.1223071846428894

39 - 2023-12-16 11:44:45,412;INFO ; 25,0.007457404973803511,0.3080614235512719

40 - 2023-12-16 11:44:45,416;INFO ; 26,0.00690049778703863,0.328356663372252

41 - 2023-12-16 11:44:45,421;INFO ; 27,0.006963554132391644,0.7377893941138409

42 - 2023-12-16 11:44:45,425;INFO ; 28,0.0068177642798356785,0.04438707686992304

43 - 2023-12-16 11:44:45,430;INFO ; 29,0.004277860366532809,0.054318136217835634

44 - 2023-12-16 11:44:45,437;INFO ; 30,0.004136181096380939,0.05758294976347074

45 - 2023-12-16 11:44:45,444;INFO ; 31,0.003148392325029327,0.09180388535500701

46 - 2023-12-16 11:44:45,456;INFO ; 32,0.0034184967969866763,0.12279944254969805

47 - 2023-12-16 11:44:45,461;INFO ; 33,0.002738614050252826,0.08799214942481376

48 - 2023-12-16 11:44:45,465;INFO ; 34,0.002340378401630818,0.10982599850058662

49 - 2023-12-16 11:44:45,469;INFO ; 35,0.002318543550203436,0.1874192088468983

50 - 2023-12-16 11:44:45,476;INFO ; 36,0.0023838181828763254,0.14049673625006598

51 - 2023-12-16 11:44:45,480;INFO ; 37,0.0017801377860501193,0.25278698153033746

52 - 2023-12-16 11:44:45,488;INFO ; 38,0.001926434976140927,0.30768123024704397

53 - 2023-12-16 11:44:45,492;INFO ; 39,0.0018408894375050086,0.3982324050234211

54 - 2023-12-16 11:44:45,501;INFO ; 40,0.0018205742523342274,0.5255149131154504

55 - 2023-12-16 11:44:45,505;INFO ; 41,0.002022417110833193,0.012343794696316789

56 - 2023-12-16 11:44:45,513;INFO ; 42,0.0014238367784733673,0.030454026217358272

57 - 2023-12-16 11:44:45,520;INFO ; 43,0.0011877471305847959,0.022833087486041986

58 - 2023-12-16 11:44:45,525;INFO ; 44,0.001210668149459547,0.06969126002889173

59 - 2023-12-16 11:44:45,532;INFO ; 45,0.001133623256805662,0.03897096468594406

60 - 2023-12-16 11:44:45,541;INFO ; 46,0.0009780989052674482,0.02207199085154608

61 - 2023-12-16 11:44:45,541;INFO ; bfw Assignment finished. 46 iterations and 0.0009780989052674482 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 0.817 seconds)

Gallery generated by Sphinx-Gallery