Note
Click here to download the full example code
7.13. Forecasting¶
On this example we present a full forecasting workflow for the Sioux Falls example model.
## Imports
from uuid import uuid4
from tempfile import gettempdir
from os.path import join
from aequilibrae.utils.create_example import create_example
from aequilibrae import logger
import logging
import sys
We create the example project inside our temp folder
fldr = join(gettempdir(), uuid4().hex)
project = create_example(fldr)
# We the project open, we can tell the logger to direct all messages to the terminal as well
stdout_handler = logging.StreamHandler(sys.stdout)
formatter = logging.Formatter("%(asctime)s;%(name)s; %(message)s")
stdout_handler.setFormatter(formatter)
logger.addHandler(stdout_handler)
## Traffic assignment with skimming
from aequilibrae.paths import TrafficAssignment, TrafficClass
# we build all graphs
project.network.build_graphs()
# We get warnings that several fields in the project are filled with NaNs. Which is true, but we won't use those fields
Out:
2022-03-30 06:35:13,913;aequilibrae; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2022-03-30 06:35:13,968;aequilibrae; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2022-03-30 06:35:14,021;aequilibrae; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2022-03-30 06:35:14,075;aequilibrae; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2022-03-30 06:35:14,129;aequilibrae; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2022-03-30 06:35:14,183;aequilibrae; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
# we grab the graph for cars
graph = project.network.graphs["c"]
# let's say we want to minimize free_flow_time
graph.set_graph("free_flow_time")
# And will skim time and distance while we are at it
graph.set_skimming(["free_flow_time", "distance"])
# And we will allow paths to be compute going through other centroids/centroid connectors
# required for the Sioux Falls network, as all nodes are centroids
graph.set_blocked_centroid_flows(False)
Out:
/home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:453: UserWarning: Cost field with wrong type. Converting to float64
warn("Cost field with wrong type. Converting to float64")
# We get the demand matrix directly from the project record
# so let's inspect what we have in the project
proj_matrices = project.matrices
proj_matrices.list()
# Let's get it in this better way
demand = proj_matrices.get_matrix("demand_omx")
demand.computational_view(["matrix"])
assig = TrafficAssignment()
# Creates the assignment class
assigclass = TrafficClass(name='car', graph=graph, matrix=demand)
# The first thing to do is to add at list of traffic classes to be assigned
assig.add_class(assigclass)
# We set these parameters only after adding one class to the assignment
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.001
assig.execute() # we then execute the assignment
Out:
/home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:453: UserWarning: Cost field with wrong type. Converting to float64
warn("Cost field with wrong type. Converting to float64")
2022-03-30 06:35:14,753;aequilibrae; bfw Assignment STATS
2022-03-30 06:35:14,753;aequilibrae; Iteration, RelativeGap, stepsize
2022-03-30 06:35:14,762;aequilibrae; 1,inf,1.0
2022-03-30 06:35:14,771;aequilibrae; 2,0.8485503636986156,0.3649733931991619
2022-03-30 06:35:14,780;aequilibrae; 3,0.38139263975960314,0.22983569243524993
2022-03-30 06:35:14,789;aequilibrae; 4,0.19621280093105328,0.18591303407405754
2022-03-30 06:35:14,798;aequilibrae; 5,0.09069069564886302,0.709081525570193
2022-03-30 06:35:14,806;aequilibrae; 6,0.20600049841796414,0.12290139708465252
2022-03-30 06:35:14,815;aequilibrae; 7,0.0671057020569446,0.3863865464644097
2022-03-30 06:35:14,824;aequilibrae; 8,0.10307514522959232,0.10930550628245674
2022-03-30 06:35:14,832;aequilibrae; 9,0.042221488560558955,0.24878058909094228
2022-03-30 06:35:14,841;aequilibrae; 10,0.05926436280283587,0.15904812211073494
2022-03-30 06:35:14,850;aequilibrae; 11,0.034539501887818985,0.5180973982981508
2022-03-30 06:35:14,860;aequilibrae; 12,0.059426522740212366,0.101971242325629
2022-03-30 06:35:14,871;aequilibrae; 13,0.023239892828420625,0.1780595247621586
2022-03-30 06:35:14,880;aequilibrae; 14,0.01787378174233466,0.9787872892076548
2022-03-30 06:35:14,889;aequilibrae; 15,0.04966137112489825,0.08320656230754342
2022-03-30 06:35:14,899;aequilibrae; 16,0.021382882927382725,0.11517403372477297
2022-03-30 06:35:14,909;aequilibrae; 17,0.01314154305058098,0.1064036961470442
2022-03-30 06:35:14,927;aequilibrae; 18,0.009902228306191804,0.10710395852809111
2022-03-30 06:35:14,941;aequilibrae; 19,0.008834657124558089,0.252467895277828
2022-03-30 06:35:14,950;aequilibrae; 20,0.010371041656588888,0.6727839455896467
2022-03-30 06:35:14,964;aequilibrae; 21,0.011090096024277666,0.07468062458005388
2022-03-30 06:35:14,984;aequilibrae; 22,0.006512685864200749,0.12485018976276105
2022-03-30 06:35:14,995;aequilibrae; 23,0.00523888532832478,0.06316016036308214
2022-03-30 06:35:15,004;aequilibrae; 24,0.003949527733957799,0.09717892036982514
2022-03-30 06:35:15,013;aequilibrae; 25,0.003282221717998643,0.15775902884958926
2022-03-30 06:35:15,025;aequilibrae; 26,0.0057928324189390375,0.4524765555189632
2022-03-30 06:35:15,035;aequilibrae; 27,0.006682358714677215,0.7851865434128832
2022-03-30 06:35:15,044;aequilibrae; 28,0.00599261954468699,0.039098102583274626
2022-03-30 06:35:15,053;aequilibrae; 29,0.004031364721003652,0.04253017715977122
2022-03-30 06:35:15,065;aequilibrae; 30,0.00276965205224939,0.02251286694569934
2022-03-30 06:35:15,074;aequilibrae; 31,0.002484645375580033,0.045801689794576335
2022-03-30 06:35:15,087;aequilibrae; 32,0.0016385526291291498,0.034295834113305265
2022-03-30 06:35:15,097;aequilibrae; 33,0.0014956909894299761,0.035391999643557624
2022-03-30 06:35:15,105;aequilibrae; 34,0.0011355396506463338,0.053589857140533936
2022-03-30 06:35:15,114;aequilibrae; 35,0.0012151969842906466,0.04757129085244828
2022-03-30 06:35:15,126;aequilibrae; 36,0.0012393652042090905,0.06536474008117803
2022-03-30 06:35:15,135;aequilibrae; 37,0.0010684964499824193,0.1070395355360692
2022-03-30 06:35:15,153;aequilibrae; 38,0.0010899690746481111,0.09864062890245766
2022-03-30 06:35:15,164;aequilibrae; 39,0.0009886949061956609,0.06027624172548778
2022-03-30 06:35:15,165;aequilibrae; bfw Assignment finished. 39 iterations and 0.0009886949061956609 final gap
# Convergence report is easy to see
import pandas as pd
convergence_report = assig.report()
convergence_report.head()
volumes = assig.results()
volumes.head()
# We could export it to CSV or AequilibraE data, but let's put it directly into the results database
assig.save_results("base_year_assignment")
# And save the skims
assig.save_skims("base_year_assignment_skims", which_ones="all", format="omx")
Out:
2022-03-30 06:35:15,435;aequilibrae; Matrix Record has been saved to the database
## Trip distribution
### Calibration
# We will calibrate synthetic gravity models using the skims for TIME that we just generated
import numpy as np
from aequilibrae.distribution import GravityCalibration
# Let's take another look at what we have in terms of matrices in the model
proj_matrices.list()
# We need the demand
demand = proj_matrices.get_matrix("demand_aem")
# And the skims
imped = proj_matrices.get_matrix("base_year_assignment_skims_car")
# We can check which matrix cores were created for our skims to decide which one to use
imped.names
# Where free_flow_time_final is actually the congested time for the last iteration
Out:
['distance_blended', 'distance_final', 'free_flow_time_blended', 'free_flow_time_final']
# But before using the data, let's get some impedance for the intrazonals
# Let's assume it is 75% of the closest zone
imped_core = "free_flow_time_final"
imped.computational_view([imped_core])
# If we run the code below more than once, we will be overwriting the diagonal values with non-sensical data
# so let's zero it first
np.fill_diagonal(imped.matrix_view, 0)
# We compute it with a little bit of NumPy magic
intrazonals = np.amin(imped.matrix_view, where=imped.matrix_view > 0, initial=imped.matrix_view.max(), axis=1)
intrazonals *= 0.75
# Then we fill in the impedance matrix
np.fill_diagonal(imped.matrix_view, intrazonals)
# Since we are working with an OMX file, we cannot overwrite a matrix on disk
# So we give a new name to save it
imped.save(names=["final_time_with_intrazonals"])
# This also updates these new matrices as those being used for computation
# As one can verify below
imped.view_names
Out:
['final_time_with_intrazonals']
# We set the matrices for being used in computation
demand.computational_view(["matrix"])
for function in ["power", "expo"]:
gc = GravityCalibration(matrix=demand, impedance=imped, function=function, nan_as_zero=True)
gc.calibrate()
model = gc.model
# we save the model
model.save(join(fldr, f"{function}_model.mod"))
# We can save the result of applying the model as well
# we can also save the calibration report
with open(join(fldr, f"{function}_convergence.log"), "w") as otp:
for r in gc.report:
otp.write(r + "\n")
Out:
/home/runner/work/aequilibrae/aequilibrae/aequilibrae/distribution/gravity_application.py:315: RuntimeWarning: divide by zero encountered in power
self.output.matrix_view[i, :] = (np.power(self.impedance.matrix_view[i, :], -self.model.alpha) * p
/home/runner/work/aequilibrae/aequilibrae/aequilibrae/distribution/gravity_application.py:326: RuntimeWarning: invalid value encountered in multiply
self.output.matrix_view[:, :] = self.output.matrix_view[:, :] * non_inf
## Forecast
# * We create a set of * 'future' * vectors using some random growth factors
# * We apply the model for inverse power, as the TFLD seems to be a better fit for the actual one
from aequilibrae.distribution import Ipf, GravityApplication, SyntheticGravityModel
from aequilibrae.matrix import AequilibraeData
import numpy as np
# We compute the vectors from our matrix
origins = np.sum(demand.matrix_view, axis=1)
destinations = np.sum(demand.matrix_view, axis=0)
args = {
"file_path": join(fldr, "synthetic_future_vector.aed"),
"entries": demand.zones,
"field_names": ["origins", "destinations"],
"data_types": [np.float64, np.float64],
"memory_mode": False,
}
vectors = AequilibraeData()
vectors.create_empty(**args)
vectors.index[:] = demand.index[:]
# Then grow them with some random growth between 0 and 10% - Plus balance them
vectors.origins[:] = origins * (1 + np.random.rand(vectors.entries) / 10)
vectors.destinations[:] = destinations * (1 + np.random.rand(vectors.entries) / 10)
vectors.destinations *= vectors.origins.sum() / vectors.destinations.sum()
# Impedance
imped = proj_matrices.get_matrix("base_year_assignment_skims_car")
imped.computational_view(["final_time_with_intrazonals"])
# If we wanted the main diagonal to not be considered...
# np.fill_diagonal(imped.matrix_view, np.nan)
for function in ["power", "expo"]:
model = SyntheticGravityModel()
model.load(join(fldr, f"{function}_model.mod"))
outmatrix = join(proj_matrices.fldr, f"demand_{function}_model.aem")
apply = GravityApplication()
args = {
"impedance": imped,
"rows": vectors,
"row_field": "origins",
"model": model,
"columns": vectors,
"column_field": "destinations",
"nan_as_zero": True,
}
gravity = GravityApplication(**args)
gravity.apply()
# We get the output matrix and save it to OMX too,
gravity.save_to_project(name=f"demand_{function}_modeled", file_name=f"demand_{function}_modeled.omx")
Out:
2022-03-30 06:35:16,732;aequilibrae; Matrix Record has been saved to the database
2022-03-30 06:35:17,098;aequilibrae; Matrix Record has been saved to the database
# We update the matrices table/records and verify that the new matrices are indeed there
proj_matrices.update_database()
proj_matrices.list()
### We now run IPF for the future vectors
args = {
"matrix": demand,
"rows": vectors,
"columns": vectors,
"column_field": "destinations",
"row_field": "origins",
"nan_as_zero": True,
}
ipf = Ipf(**args)
ipf.fit()
ipf.save_to_project(name="demand_ipfd", file_name="demand_ipfd.aem")
ipf.save_to_project(name="demand_ipfd_omx", file_name="demand_ipfd.omx")
Out:
2022-03-30 06:35:17,341;aequilibrae; Matrix Record has been saved to the database
2022-03-30 06:35:17,533;aequilibrae; Matrix Record has been saved to the database
<aequilibrae.project.data.matrix_record.MatrixRecord object at 0x7f0bef448ca0>
proj_matrices.list()
## Future traffic assignment
from aequilibrae.paths import TrafficAssignment, TrafficClass
from aequilibrae import logger
logger.info("\n\n\n TRAFFIC ASSIGNMENT FOR FUTURE YEAR")
Out:
2022-03-30 06:35:17,605;aequilibrae;
TRAFFIC ASSIGNMENT FOR FUTURE YEAR
demand = proj_matrices.get_matrix("demand_ipfd")
# let's see what is the core we ended up getting. It should be 'gravity'
demand.names
Out:
['matrix']
# Let's use the IPF matrix
demand.computational_view("matrix")
assig = TrafficAssignment()
# Creates the assignment class
assigclass = TrafficClass(name='car', graph=graph, matrix=demand)
# The first thing to do is to add at list of traffic classes to be assigned
assig.add_class(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 = 500
assig.rgap_target = 0.00001
assig.execute() # we then execute the assignment
Out:
/home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:453: UserWarning: Cost field with wrong type. Converting to float64
warn("Cost field with wrong type. Converting to float64")
2022-03-30 06:35:18,058;aequilibrae; bfw Assignment STATS
2022-03-30 06:35:18,058;aequilibrae; Iteration, RelativeGap, stepsize
2022-03-30 06:35:18,071;aequilibrae; 1,inf,1.0
2022-03-30 06:35:18,084;aequilibrae; 2,0.8640822421161786,0.37292935195231486
2022-03-30 06:35:18,098;aequilibrae; 3,0.40024694275335776,0.17844919022612446
2022-03-30 06:35:18,111;aequilibrae; 4,0.20182146926554542,0.25092398016447004
2022-03-30 06:35:18,124;aequilibrae; 5,0.14777343987636024,0.25463241986636725
2022-03-30 06:35:18,138;aequilibrae; 6,0.1353590905785671,0.1798897068483709
2022-03-30 06:35:18,153;aequilibrae; 7,0.08251683407277165,0.3385597919367376
2022-03-30 06:35:18,166;aequilibrae; 8,0.13010592291417183,0.13070564747408114
2022-03-30 06:35:18,178;aequilibrae; 9,0.053777329464136325,0.24384177537366378
2022-03-30 06:35:18,194;aequilibrae; 10,0.07698484783814527,0.15043289622601314
2022-03-30 06:35:18,207;aequilibrae; 11,0.04871899017281356,0.36723565474618985
2022-03-30 06:35:18,221;aequilibrae; 12,0.06444096966611908,0.14621750937022399
2022-03-30 06:35:18,238;aequilibrae; 13,0.03115886806536968,0.37069792708493243
2022-03-30 06:35:18,250;aequilibrae; 14,0.05785384890361702,0.0841544833611363
2022-03-30 06:35:18,268;aequilibrae; 15,0.024642006497786768,0.20589779402995073
2022-03-30 06:35:18,277;aequilibrae; 16,0.029776037175472572,0.759006770427189
2022-03-30 06:35:18,288;aequilibrae; 17,0.05232068798997916,0.08681566374265748
2022-03-30 06:35:18,302;aequilibrae; 18,0.02285513076700145,0.14564578669240189
2022-03-30 06:35:18,314;aequilibrae; 19,0.017565437789536478,0.1923058715302588
2022-03-30 06:35:18,330;aequilibrae; 20,0.01132432219256183,0.18265444475584058
2022-03-30 06:35:18,342;aequilibrae; 21,0.013857026386117584,0.43319644765256143
2022-03-30 06:35:18,353;aequilibrae; 22,0.01663069216809704,0.8561745035309122
2022-03-30 06:35:18,372;aequilibrae; 23,0.017532874169244997,0.07861447298706668
2022-03-30 06:35:18,383;aequilibrae; 24,0.008641317980830298,0.11139754834694682
2022-03-30 06:35:18,394;aequilibrae; 25,0.007998325045162201,0.16205217333031008
2022-03-30 06:35:18,405;aequilibrae; 26,0.00803440141886617,0.32938046600562837
2022-03-30 06:35:18,415;aequilibrae; 27,0.009808514085828609,0.6797088116630732
2022-03-30 06:35:18,429;aequilibrae; 28,0.007541771630230079,0.061368183446967026
2022-03-30 06:35:18,441;aequilibrae; 29,0.005451140795173988,0.03636730878643076
2022-03-30 06:35:18,452;aequilibrae; 30,0.0036438837554848757,0.037906463779132905
2022-03-30 06:35:18,465;aequilibrae; 31,0.002344228466927835,0.033421474112148936
2022-03-30 06:35:18,477;aequilibrae; 32,0.0025251931872718493,0.05477821789629168
2022-03-30 06:35:18,488;aequilibrae; 33,0.0031269714283486557,0.12195784870427219
2022-03-30 06:35:18,498;aequilibrae; 34,0.002970909340975315,0.15955188001141868
2022-03-30 06:35:18,509;aequilibrae; 35,0.00342876964409134,0.2580128112407674
2022-03-30 06:35:18,522;aequilibrae; 36,0.004291044710031676,0.9459640185361629
2022-03-30 06:35:18,537;aequilibrae; 37,0.00578461168312251,0.022121979134642825
2022-03-30 06:35:18,553;aequilibrae; 38,0.003336360937181334,0.02551246960902463
2022-03-30 06:35:18,567;aequilibrae; 39,0.0023334944046044317,0.04807923203397432
2022-03-30 06:35:18,580;aequilibrae; 40,0.0027959267362353173,0.0656958923562387
2022-03-30 06:35:18,592;aequilibrae; 41,0.002287611715877224,0.0478937547516726
2022-03-30 06:35:18,603;aequilibrae; 42,0.0019895396740052013,0.044775203333665525
2022-03-30 06:35:18,613;aequilibrae; 43,0.0018430924388742366,0.05811037776869034
2022-03-30 06:35:18,627;aequilibrae; 44,0.0015555132228279678,0.04726075730261095
2022-03-30 06:35:18,639;aequilibrae; 45,0.0013143066189709644,0.03728183781182998
2022-03-30 06:35:18,652;aequilibrae; 46,0.0009021191252855489,0.02127066221641698
2022-03-30 06:35:18,666;aequilibrae; 47,0.0008483883741159835,0.03234679941672534
2022-03-30 06:35:18,676;aequilibrae; 48,0.0009266177002097058,0.03395779763559276
2022-03-30 06:35:18,687;aequilibrae; 49,0.0008953822588090007,0.06270771965115957
2022-03-30 06:35:18,698;aequilibrae; 50,0.0011549366136067109,0.15072758680627008
2022-03-30 06:35:18,708;aequilibrae; 51,0.0011097140152600442,0.15538163333241756
2022-03-30 06:35:18,718;aequilibrae; 52,0.0011474096105997535,0.17999717373373902
2022-03-30 06:35:18,731;aequilibrae; 53,0.0008333645100889973,0.22275692478089423
2022-03-30 06:35:18,746;aequilibrae; 54,0.0007607763289351458,0.16549754335749928
2022-03-30 06:35:18,757;aequilibrae; 55,0.0007368905402904042,0.2498364877092027
2022-03-30 06:35:18,774;aequilibrae; 56,0.000884053221262679,0.538714504205792
2022-03-30 06:35:18,787;aequilibrae; 57,0.001005443348680526,0.8084648236622918
2022-03-30 06:35:18,798;aequilibrae; 58,0.000747461579483486,0.006069358671767987
2022-03-30 06:35:18,808;aequilibrae; 59,0.0006400285373093239,0.01612750859229421
2022-03-30 06:35:18,820;aequilibrae; 60,0.0005820180437978713,0.008724694815418986
2022-03-30 06:35:18,835;aequilibrae; 61,0.00042948855599335396,0.011009044788899124
2022-03-30 06:35:18,848;aequilibrae; 62,0.0004244010028385218,0.00991688299964967
2022-03-30 06:35:18,858;aequilibrae; 63,0.00032061306947600966,0.012824515991954158
2022-03-30 06:35:18,874;aequilibrae; 64,0.0003930569682652042,0.010866054914672968
2022-03-30 06:35:18,887;aequilibrae; 65,0.00022323468235573693,0.008835066036782862
2022-03-30 06:35:18,899;aequilibrae; 66,0.0002089742307188207,0.004424554100754541
2022-03-30 06:35:18,916;aequilibrae; 67,0.00018382077988359419,0.007836275302565246
2022-03-30 06:35:18,928;aequilibrae; 68,0.00015286991089337644,0.006433699255677444
2022-03-30 06:35:18,939;aequilibrae; 69,0.0002484143327024828,0.009507983184299846
2022-03-30 06:35:19,047;aequilibrae; 70,0.00022490043530284733,0.009695251108478095
2022-03-30 06:35:19,073;aequilibrae; 71,0.00016947534616318952,0.004619535021213213
2022-03-30 06:35:19,085;aequilibrae; 72,0.00012516551312058446,0.0029559754987165676
2022-03-30 06:35:19,095;aequilibrae; 73,0.00010435546054245256,0.0021707566409139493
2022-03-30 06:35:19,110;aequilibrae; 74,0.00010692496771692026,0.002497887214058174
2022-03-30 06:35:19,122;aequilibrae; 75,0.00011579800928728354,0.005260475727459672
2022-03-30 06:35:19,137;aequilibrae; 76,0.0001384075537735438,0.005661230105417702
2022-03-30 06:35:19,148;aequilibrae; 77,0.0001498854930016576,0.006934149847735108
2022-03-30 06:35:19,159;aequilibrae; 78,0.00014089075020361287,0.011185259173635104
2022-03-30 06:35:19,173;aequilibrae; 79,0.00013592775811622536,0.01388139861729522
2022-03-30 06:35:19,187;aequilibrae; 80,0.00016597587325851114,0.02474520377361046
2022-03-30 06:35:19,199;aequilibrae; 81,0.0002248529184988508,0.02828217720467378
2022-03-30 06:35:19,214;aequilibrae; 82,0.00022526755220986046,0.043287987927642047
2022-03-30 06:35:19,226;aequilibrae; 83,0.0002995988222583355,0.05443440558600097
2022-03-30 06:35:19,236;aequilibrae; 84,0.0002943676866778313,0.06493852537024743
2022-03-30 06:35:19,247;aequilibrae; 85,0.0003293671083765304,0.07614441239762093
2022-03-30 06:35:19,259;aequilibrae; 86,0.00026831353424313406,0.06259001869507097
2022-03-30 06:35:19,275;aequilibrae; 87,0.0002829898151723774,0.04086780273092652
2022-03-30 06:35:19,289;aequilibrae; 88,0.00020451627040555314,0.0392116684544161
2022-03-30 06:35:19,300;aequilibrae; 89,0.00019053353576253002,0.016698061680574902
2022-03-30 06:35:19,313;aequilibrae; 90,0.0001548538639462388,0.03542109125365637
2022-03-30 06:35:19,324;aequilibrae; 91,0.0001881421544741506,0.030771112054799783
2022-03-30 06:35:19,337;aequilibrae; 92,0.0001500447948956757,0.052299402355829895
2022-03-30 06:35:19,347;aequilibrae; 93,0.00019178097718779778,0.045952336399559
2022-03-30 06:35:19,359;aequilibrae; 94,0.00022050598243492542,0.03523947316950556
2022-03-30 06:35:19,369;aequilibrae; 95,0.0002273732542280226,0.04990425947044629
2022-03-30 06:35:19,386;aequilibrae; 96,0.00020422731252323865,0.05276344674682311
2022-03-30 06:35:19,397;aequilibrae; 97,0.00019155910855896214,0.02236081775186587
2022-03-30 06:35:19,408;aequilibrae; 98,0.00016736631923181872,0.03655813792701671
2022-03-30 06:35:19,423;aequilibrae; 99,0.00017752644791664305,0.03242786057976886
2022-03-30 06:35:19,433;aequilibrae; 100,0.00012338576045857637,0.014732568011475997
2022-03-30 06:35:19,444;aequilibrae; 101,0.00013887392950292078,0.014843470059113073
2022-03-30 06:35:19,455;aequilibrae; 102,0.00013281959881746266,0.015176275085905473
2022-03-30 06:35:19,468;aequilibrae; 103,0.00012693218834403374,0.00980908264598729
2022-03-30 06:35:19,483;aequilibrae; 104,9.30776404496239e-05,0.00991723076546758
2022-03-30 06:35:19,496;aequilibrae; 105,9.942177515794031e-05,0.01354962523655338
2022-03-30 06:35:19,508;aequilibrae; 106,0.00010369951115410869,0.013622236941332405
2022-03-30 06:35:19,521;aequilibrae; 107,0.00013286107056316625,0.015150508728010246
2022-03-30 06:35:19,531;aequilibrae; 108,0.00014766203366773533,0.02684371945415645
2022-03-30 06:35:19,543;aequilibrae; 109,0.00015524988809836621,0.01623704253115988
2022-03-30 06:35:19,555;aequilibrae; 110,0.00010659754380363564,0.01069634919222407
2022-03-30 06:35:19,565;aequilibrae; 111,8.44143183091351e-05,0.0036904282324187227
2022-03-30 06:35:19,579;aequilibrae; 112,8.565971418548702e-05,0.007436795377352814
2022-03-30 06:35:19,592;aequilibrae; 113,7.251323824042111e-05,0.0045488184766465795
2022-03-30 06:35:19,602;aequilibrae; 114,6.561203356177781e-05,0.006055010381754182
2022-03-30 06:35:19,613;aequilibrae; 115,8.106612876853072e-05,0.00490019946570833
2022-03-30 06:35:19,623;aequilibrae; 116,8.018603126364028e-05,0.0065943175023865305
2022-03-30 06:35:19,636;aequilibrae; 117,8.188038123706757e-05,0.006965201568159744
2022-03-30 06:35:19,645;aequilibrae; 118,8.639998049955129e-05,0.008233897071969856
2022-03-30 06:35:19,656;aequilibrae; 119,8.343384481489934e-05,0.010577656796395577
2022-03-30 06:35:19,666;aequilibrae; 120,9.28315126697004e-05,0.01191344820708073
2022-03-30 06:35:19,677;aequilibrae; 121,8.712170184392309e-05,0.007257867424435106
2022-03-30 06:35:19,688;aequilibrae; 122,7.799120019269096e-05,0.016453580793161685
2022-03-30 06:35:19,699;aequilibrae; 123,8.172443007465513e-05,0.011212941579839828
2022-03-30 06:35:19,709;aequilibrae; 124,7.387464906311946e-05,0.023554813245845414
2022-03-30 06:35:19,720;aequilibrae; 125,0.0001082685588756055,0.037900504037610194
2022-03-30 06:35:19,730;aequilibrae; 126,0.00013681986756328095,0.04267093165844508
2022-03-30 06:35:19,740;aequilibrae; 127,0.00013693243921027195,0.05188763988423357
2022-03-30 06:35:19,753;aequilibrae; 128,0.00013733032648599423,0.052241850277523386
2022-03-30 06:35:19,764;aequilibrae; 129,0.00011043923669432712,0.017096792169477612
2022-03-30 06:35:19,775;aequilibrae; 130,0.0001077416876509317,0.0068693379112062195
2022-03-30 06:35:19,786;aequilibrae; 131,9.63209727562745e-05,0.01823187806587189
2022-03-30 06:35:19,805;aequilibrae; 132,8.311254607139367e-05,0.0123411940400802
2022-03-30 06:35:19,818;aequilibrae; 133,7.58696827884544e-05,0.007409206646628601
2022-03-30 06:35:19,828;aequilibrae; 134,7.67965476245599e-05,0.008940084348594265
2022-03-30 06:35:19,840;aequilibrae; 135,6.195799599729911e-05,0.005342224625468388
2022-03-30 06:35:19,851;aequilibrae; 136,5.682679180035631e-05,0.005233117892059727
2022-03-30 06:35:19,862;aequilibrae; 137,7.109173410886536e-05,0.006060773838685758
2022-03-30 06:35:19,874;aequilibrae; 138,6.320410663567255e-05,0.0062678586117379444
2022-03-30 06:35:19,885;aequilibrae; 139,7.231857684913043e-05,0.012993495256721851
2022-03-30 06:35:19,895;aequilibrae; 140,6.900047525418267e-05,0.008485542994760448
2022-03-30 06:35:19,906;aequilibrae; 141,5.975643044834034e-05,0.008369294913624483
2022-03-30 06:35:19,918;aequilibrae; 142,3.985952388008899e-05,0.004165633285972503
2022-03-30 06:35:19,928;aequilibrae; 143,4.310189268186914e-05,0.0026957774622298173
2022-03-30 06:35:19,939;aequilibrae; 144,3.914818920886589e-05,0.00501202673555048
2022-03-30 06:35:19,952;aequilibrae; 145,3.413300063964538e-05,0.0019788056804002853
2022-03-30 06:35:19,963;aequilibrae; 146,3.249624295537848e-05,0.0029229049025055387
2022-03-30 06:35:19,974;aequilibrae; 147,2.8412502047261662e-05,0.0034810875647030524
2022-03-30 06:35:19,988;aequilibrae; 148,3.348460214897343e-05,0.0018374835902372243
2022-03-30 06:35:20,001;aequilibrae; 149,3.090056732847303e-05,0.0027431294879373173
2022-03-30 06:35:20,014;aequilibrae; 150,3.8526696026758314e-05,0.00449782159627854
2022-03-30 06:35:20,025;aequilibrae; 151,3.865728442826923e-05,0.0052528900886873574
2022-03-30 06:35:20,036;aequilibrae; 152,4.4323893029449545e-05,0.0058211097892819684
2022-03-30 06:35:20,048;aequilibrae; 153,3.61832113365804e-05,0.003370457684091816
2022-03-30 06:35:20,061;aequilibrae; 154,3.142461590978521e-05,0.002280725603266664
2022-03-30 06:35:20,074;aequilibrae; 155,3.0846328340976406e-05,0.0045290905631862124
2022-03-30 06:35:20,087;aequilibrae; 156,3.661303806058412e-05,0.005044331153582943
2022-03-30 06:35:20,098;aequilibrae; 157,3.4069921108311114e-05,0.004939935736792037
2022-03-30 06:35:20,111;aequilibrae; 158,3.2526603461971433e-05,0.004418315695652205
2022-03-30 06:35:20,121;aequilibrae; 159,3.518570852360373e-05,0.005720752195921868
2022-03-30 06:35:20,132;aequilibrae; 160,3.901145970134266e-05,0.010504108581306574
2022-03-30 06:35:20,150;aequilibrae; 161,5.7244571174156904e-05,0.021042883915905322
2022-03-30 06:35:20,161;aequilibrae; 162,6.558227087535522e-05,0.025763436497034144
2022-03-30 06:35:20,173;aequilibrae; 163,8.34031960284889e-05,0.02266275296763202
2022-03-30 06:35:20,185;aequilibrae; 164,8.064852105498755e-05,0.020959016506469638
2022-03-30 06:35:20,196;aequilibrae; 165,9.817930839221043e-05,0.032566115250585566
2022-03-30 06:35:20,209;aequilibrae; 166,8.408358062700785e-05,0.02443460873055362
2022-03-30 06:35:20,225;aequilibrae; 167,8.800811145699258e-05,0.02908070024000702
2022-03-30 06:35:20,238;aequilibrae; 168,7.144187246761685e-05,0.01848394983085679
2022-03-30 06:35:20,250;aequilibrae; 169,8.261228684765797e-05,0.022972376682869448
2022-03-30 06:35:20,261;aequilibrae; 170,7.730341417126756e-05,0.02140761691793548
2022-03-30 06:35:20,272;aequilibrae; 171,8.351487328979362e-05,0.02911909029684487
2022-03-30 06:35:20,283;aequilibrae; 172,6.558009295502121e-05,0.032720058571128516
2022-03-30 06:35:20,296;aequilibrae; 173,8.1460486510221e-05,0.050436688377210895
2022-03-30 06:35:20,312;aequilibrae; 174,7.352610783949715e-05,0.031073484347687037
2022-03-30 06:35:20,322;aequilibrae; 175,7.20834985314472e-05,0.02228819454912721
2022-03-30 06:35:20,336;aequilibrae; 176,7.069618596455959e-05,0.02142248932164551
2022-03-30 06:35:20,348;aequilibrae; 177,8.409940984664768e-05,0.03354366174283368
2022-03-30 06:35:20,359;aequilibrae; 178,7.439496669302533e-05,0.020677561897787883
2022-03-30 06:35:20,369;aequilibrae; 179,6.007358195988385e-05,0.026639714824788285
2022-03-30 06:35:20,380;aequilibrae; 180,5.461665433947615e-05,0.022744121105807955
2022-03-30 06:35:20,391;aequilibrae; 181,4.7275808753786506e-05,0.018558845038839547
2022-03-30 06:35:20,402;aequilibrae; 182,5.200670488705403e-05,0.01948906141108359
2022-03-30 06:35:20,414;aequilibrae; 183,3.6487187323093606e-05,0.0076462618741046295
2022-03-30 06:35:20,426;aequilibrae; 184,3.6865510701699965e-05,0.0053078670417365855
2022-03-30 06:35:20,439;aequilibrae; 185,3.916130470156447e-05,0.007036779616811502
2022-03-30 06:35:20,449;aequilibrae; 186,3.962993890789461e-05,0.005536671618470833
2022-03-30 06:35:20,467;aequilibrae; 187,4.6237043321175434e-05,0.010892693966829932
2022-03-30 06:35:20,481;aequilibrae; 188,5.020836239315733e-05,0.01868651262672999
2022-03-30 06:35:20,492;aequilibrae; 189,7.300567369333636e-05,0.025336841997635955
2022-03-30 06:35:20,503;aequilibrae; 190,6.404195580641755e-05,0.02402694732258743
2022-03-30 06:35:20,514;aequilibrae; 191,6.184310923774902e-05,0.021052267044510485
2022-03-30 06:35:20,527;aequilibrae; 192,6.038886713021122e-05,0.012860126951572737
2022-03-30 06:35:20,537;aequilibrae; 193,4.6936452899112676e-05,0.010978431477204327
2022-03-30 06:35:20,548;aequilibrae; 194,3.636021592934711e-05,0.005393245209964354
2022-03-30 06:35:20,559;aequilibrae; 195,3.3656017220639456e-05,0.0058738381743069015
2022-03-30 06:35:20,569;aequilibrae; 196,4.038743185285662e-05,0.011962108097798647
2022-03-30 06:35:20,580;aequilibrae; 197,4.745471349840089e-05,0.011789712548040447
2022-03-30 06:35:20,593;aequilibrae; 198,3.505867666803582e-05,0.012307152742698292
2022-03-30 06:35:20,605;aequilibrae; 199,4.642255848980489e-05,0.013268156376934532
2022-03-30 06:35:20,617;aequilibrae; 200,3.9711676389985166e-05,0.014225792233677769
2022-03-30 06:35:20,632;aequilibrae; 201,3.4871415171198675e-05,0.003307293448942469
2022-03-30 06:35:20,645;aequilibrae; 202,2.3756526688255493e-05,0.002593882491174012
2022-03-30 06:35:20,656;aequilibrae; 203,2.2030166604475446e-05,0.0020959585556396703
2022-03-30 06:35:20,667;aequilibrae; 204,2.408163874597062e-05,0.0015406082073595234
2022-03-30 06:35:20,679;aequilibrae; 205,2.595361419820379e-05,0.0028492973337620395
2022-03-30 06:35:20,690;aequilibrae; 206,2.7394125180559924e-05,0.0023871998507281602
2022-03-30 06:35:20,702;aequilibrae; 207,2.1290829339898705e-05,0.004344874324705038
2022-03-30 06:35:20,714;aequilibrae; 208,2.428870494848446e-05,0.004166711724851157
2022-03-30 06:35:20,727;aequilibrae; 209,2.1624402147632748e-05,0.003751676047851544
2022-03-30 06:35:20,738;aequilibrae; 210,1.8483984963892405e-05,0.0054268381625540724
2022-03-30 06:35:20,750;aequilibrae; 211,2.799175457374037e-05,0.006654793474008459
2022-03-30 06:35:20,760;aequilibrae; 212,2.8299950420165198e-05,0.009859096815843259
2022-03-30 06:35:20,774;aequilibrae; 213,3.061338281472309e-05,0.0037204564303195947
2022-03-30 06:35:20,785;aequilibrae; 214,2.873602639579616e-05,0.011984276374615074
2022-03-30 06:35:20,797;aequilibrae; 215,4.3175208420947824e-05,0.01263481412177762
2022-03-30 06:35:20,808;aequilibrae; 216,3.91588111786499e-05,0.010474392269716032
2022-03-30 06:35:20,820;aequilibrae; 217,3.6378504649382026e-05,0.016346758842171624
2022-03-30 06:35:20,834;aequilibrae; 218,4.088583444821159e-05,0.021340715536920143
2022-03-30 06:35:20,846;aequilibrae; 219,4.3006174292222325e-05,0.028934239207787007
2022-03-30 06:35:20,859;aequilibrae; 220,6.159044536023042e-05,0.07188767651189076
2022-03-30 06:35:20,871;aequilibrae; 221,7.996165426203744e-05,0.061880594055853416
2022-03-30 06:35:20,882;aequilibrae; 222,5.780677561009128e-05,0.08708903400330371
2022-03-30 06:35:20,894;aequilibrae; 223,6.968793662653245e-05,0.05370810485869615
2022-03-30 06:35:20,906;aequilibrae; 224,6.909417731200611e-05,0.14071722987411867
2022-03-30 06:35:20,918;aequilibrae; 225,0.00010124514994858672,0.1849002078509574
2022-03-30 06:35:20,930;aequilibrae; 226,8.983580771243411e-05,0.21332966046502
2022-03-30 06:35:20,942;aequilibrae; 227,9.0593106097032e-05,0.29785375765312333
2022-03-30 06:35:20,954;aequilibrae; 228,8.630782157899777e-05,0.6035944558591091
2022-03-30 06:35:20,965;aequilibrae; 229,8.554887358184628e-05,0.8744768783481298
2022-03-30 06:35:20,976;aequilibrae; 230,6.87253053082474e-05,0.0005395317699496178
2022-03-30 06:35:20,988;aequilibrae; 231,4.506883016392143e-05,0.0009982656991577997
2022-03-30 06:35:20,999;aequilibrae; 232,7.314638735107332e-05,0.0015363342041115114
2022-03-30 06:35:21,010;aequilibrae; 233,5.685277489459044e-05,0.0018008264707584946
2022-03-30 06:35:21,020;aequilibrae; 234,6.220335522920968e-05,0.0023737313776120393
2022-03-30 06:35:21,031;aequilibrae; 235,5.352422681343023e-05,0.002433346586019852
2022-03-30 06:35:21,042;aequilibrae; 236,5.0129546897928204e-05,0.001956538489443802
2022-03-30 06:35:21,053;aequilibrae; 237,4.68151456966112e-05,0.002428204654193711
2022-03-30 06:35:21,065;aequilibrae; 238,6.115288815385408e-05,0.0034325288356155882
2022-03-30 06:35:21,075;aequilibrae; 239,6.398390651012139e-05,0.003614734878575821
2022-03-30 06:35:21,089;aequilibrae; 240,4.318650410810957e-05,0.001803408074624398
2022-03-30 06:35:21,101;aequilibrae; 241,4.645501143872556e-05,0.0021872018183055303
2022-03-30 06:35:21,112;aequilibrae; 242,3.1731173499134464e-05,0.0013139122225321544
2022-03-30 06:35:21,124;aequilibrae; 243,3.5171901346269106e-05,0.0008453297275525358
2022-03-30 06:35:21,135;aequilibrae; 244,2.683533293023639e-05,0.0018257183433974778
2022-03-30 06:35:21,145;aequilibrae; 245,3.1203263239777164e-05,0.001359301581766235
2022-03-30 06:35:21,156;aequilibrae; 246,1.8921441921264987e-05,0.0010518564699650245
2022-03-30 06:35:21,166;aequilibrae; 247,2.3390582354712506e-05,0.001076341913587382
2022-03-30 06:35:21,177;aequilibrae; 248,2.5097951791505416e-05,0.0010325834490978903
2022-03-30 06:35:21,187;aequilibrae; 249,1.9215146908946588e-05,0.0007148976579949088
2022-03-30 06:35:21,199;aequilibrae; 250,1.7810800392343976e-05,0.000374138211066436
2022-03-30 06:35:21,213;aequilibrae; 251,1.289871330248871e-05,0.00044252548634874744
2022-03-30 06:35:21,224;aequilibrae; 252,1.2551006764435497e-05,0.0004011613364555553
2022-03-30 06:35:21,235;aequilibrae; 253,9.369438355684967e-06,0.0003972318191172314
2022-03-30 06:35:21,235;aequilibrae; bfw Assignment finished. 253 iterations and 9.369438355684967e-06 final gap
# We could export it to CSV or AequilibraE data, but let's put it directly into the results database
assig.save_results("future_year_assignment")
# And save the skims
assig.save_skims("future_year_assignment_skims", which_ones="all", format="omx")
Out:
2022-03-30 06:35:21,457;aequilibrae; Matrix Record has been saved to the database
We can also plot convergence
import matplotlib.pyplot as plt
df = assig.report()
x = df.iteration.values
y = df.rgap.values
fig = plt.figure()
ax = fig.add_subplot(111)
plt.plot(x, y, "k--")
plt.yscale("log")
plt.grid(True, which="both")
plt.xlabel(r"Iterations")
plt.ylabel(r"Relative Gap")
plt.show()

Close the project
project.close()
Out:
2022-03-30 06:35:22,127;aequilibrae; Closed project on /tmp/7913d028c032499ea017a89703807e34
Total running time of the script: ( 0 minutes 8.603 seconds)