Note
Go to the end to download the full example code
Forecasting#
In 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
import logging
import sys
We create the example project inside our temp folder
fldr = join(gettempdir(), uuid4().hex)
project = create_example(fldr)
logger = project.logger
# We get the project open, and 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;%(levelname)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.
# This is true, but we won't use those fields
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/aequilibrae/project/network/network.py:342: 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)
2024-02-25 08:40:05,168;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2024-02-25 08:40:05,197;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2024-02-25 08:40:05,226;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2024-02-25 08:40:05,255;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2024-02-25 08:40:05,283;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2024-02-25 08:40:05,311;WARNING ; 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 the 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 computed going through other centroids/centroid connectors
# required for the Sioux Falls network, as all nodes are centroids
graph.set_blocked_centroid_flows(False)
2024-02-25 08:40:05,331;WARNING ; 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
print(proj_matrices.list())
name file_name ... description status
0 demand_omx demand.omx ... Original data imported to OMX format
1 demand_mc demand_mc.omx ... None
2 skims skims.omx ... Example skim
3 demand_aem demand.aem ... Original data imported to AEM format
[4 rows x 8 columns]
Let’s get it in this better way
demand = proj_matrices.get_matrix("demand_omx")
demand.computational_view(["matrix"])
assig = TrafficAssignment()
# Create 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
2024-02-25 08:40:05,619;INFO ; Traffic Class specification
2024-02-25 08:40:05,620;INFO ; {'car': {'Graph': "{'Mode': 'c', 'Block through centroids': False, 'Number of centroids': 24, 'Links': 76, 'Nodes': 24}", 'Matrix': "{'Source': '/tmp/32b3cf7c517e470aae897e460d46ab58/matrices/demand.omx', 'Number of centroids': 24, 'Matrix cores': ['matrix'], 'Matrix totals': {'matrix': 360600.0}}"}}
2024-02-25 08:40:05,620;INFO ; Traffic Assignment specification
2024-02-25 08:40:05,620;INFO ; {'VDF parameters': {'alpha': 'b', 'beta': 'power'}, 'VDF function': 'bpr', 'Number of cores': 4, 'Capacity field': 'capacity', 'Time field': 'free_flow_time', 'Algorithm': 'bfw', 'Maximum iterations': 250, 'Target RGAP': 0.0001}
2024-02-25 08:40:05,622;WARNING ; Cost field with wrong type. Converting to float64
2024-02-25 08:40:05,622;INFO ; bfw Assignment STATS
2024-02-25 08:40:05,622;INFO ; Iteration, RelativeGap, stepsize
2024-02-25 08:40:05,628;INFO ; 1,inf,1.0
2024-02-25 08:40:05,633;INFO ; 2,0.8550751349428284,0.32839952448634563
2024-02-25 08:40:05,638;INFO ; 3,0.4763455007221067,0.18660240547488702
2024-02-25 08:40:05,643;INFO ; 4,0.2355126365951965,0.2411477440291793
2024-02-25 08:40:05,653;INFO ; 5,0.10924072010481088,0.8185470737942447
2024-02-25 08:40:05,659;INFO ; 6,0.1980945227617506,0.14054330572978305
2024-02-25 08:40:05,666;INFO ; 7,0.0668172221544687,0.36171152718899247
2024-02-25 08:40:05,671;INFO ; 8,0.06792122267870587,0.9634685345644044
2024-02-25 08:40:05,678;INFO ; 9,0.10705582933092855,0.13757153109677187
2024-02-25 08:40:05,683;INFO ; 10,0.04038814432034622,0.16094034254279727
2024-02-25 08:40:05,690;INFO ; 11,0.027952481137756675,0.34089282287004663
2024-02-25 08:40:05,698;INFO ; 12,0.03269999206552449,0.546768053302855
2024-02-25 08:40:05,704;INFO ; 13,0.02404097017217699,0.13812236751252946
2024-02-25 08:40:05,710;INFO ; 14,0.021451030909508357,0.19705281508905503
2024-02-25 08:40:05,715;INFO ; 15,0.01711663825927446,0.33993816583363845
2024-02-25 08:40:05,721;INFO ; 16,0.017350824111296542,0.7287610532385275
2024-02-25 08:40:05,730;INFO ; 17,0.02116470546437133,0.08183287977099357
2024-02-25 08:40:05,736;INFO ; 18,0.012464530324249254,0.15115985804759682
2024-02-25 08:40:05,747;INFO ; 19,0.012549789919850798,0.1683404948154094
2024-02-25 08:40:05,753;INFO ; 20,0.011860719789715247,0.539990352272706
2024-02-25 08:40:05,759;INFO ; 21,0.012859165521052577,0.05496659199654951
2024-02-25 08:40:05,770;INFO ; 22,0.007671197552803821,0.061255615573593686
2024-02-25 08:40:05,776;INFO ; 23,0.005529178907230243,0.07401911120607248
2024-02-25 08:40:05,782;INFO ; 24,0.0054667973306647966,0.1917097792435792
2024-02-25 08:40:05,788;INFO ; 25,0.007073668823305794,0.42287206962831864
2024-02-25 08:40:05,797;INFO ; 26,0.009664731222551093,0.9410177051614992
2024-02-25 08:40:05,806;INFO ; 27,0.008756083467130284,0.051726110618755095
2024-02-25 08:40:05,812;INFO ; 28,0.005105221228053531,0.06397929882334376
2024-02-25 08:40:05,822;INFO ; 29,0.0035319062476948794,0.050590904988213295
2024-02-25 08:40:05,828;INFO ; 30,0.0031482926233624992,0.05843748781794705
2024-02-25 08:40:05,835;INFO ; 31,0.003063209044595043,0.09173138967979506
2024-02-25 08:40:05,842;INFO ; 32,0.002664650770772641,0.07094979246383042
2024-02-25 08:40:05,849;INFO ; 33,0.002302802037873577,0.12412864151959871
2024-02-25 08:40:05,858;INFO ; 34,0.002751030256061905,0.12799355702542584
2024-02-25 08:40:05,865;INFO ; 35,0.002125634778302838,0.16620387933942551
2024-02-25 08:40:05,873;INFO ; 36,0.0020994912232001157,0.10282963642083914
2024-02-25 08:40:05,880;INFO ; 37,0.0014407763657240283,0.14492101336869087
2024-02-25 08:40:05,886;INFO ; 38,0.001418044704397894,0.0652968986666325
2024-02-25 08:40:05,895;INFO ; 39,0.0009714813735966395,0.09399257335227715
2024-02-25 08:40:05,895;INFO ; bfw Assignment finished. 39 iterations and 0.0009714813735966395 final gap
Convergence report is easy to see
import pandas as pd
convergence_report = assig.report()
print(convergence_report.head())
iteration rgap alpha warnings beta0 beta1 beta2
0 1 inf 1.000000 1.000000 0.000000 0.0
1 2 0.855075 0.328400 1.000000 0.000000 0.0
2 3 0.476346 0.186602 1.000000 0.000000 0.0
3 4 0.235513 0.241148 1.000000 0.000000 0.0
4 5 0.109241 0.818547 0.607382 0.392618 0.0
volumes = assig.results()
print(volumes.head())
matrix_ab matrix_ba matrix_tot ... PCE_AB PCE_BA PCE_tot
link_id ...
1 4502.545113 NaN 4502.545113 ... 4502.545113 NaN 4502.545113
2 8222.240524 NaN 8222.240524 ... 8222.240524 NaN 8222.240524
3 4622.925028 NaN 4622.925028 ... 4622.925028 NaN 4622.925028
4 5897.692905 NaN 5897.692905 ... 5897.692905 NaN 5897.692905
5 8101.860609 NaN 8101.860609 ... 8101.860609 NaN 8101.860609
[5 rows x 15 columns]
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")
2024-02-25 08:40:05,957;WARNING ; 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
print(proj_matrices.list())
name ... status
0 demand_omx ...
1 demand_mc ...
2 skims ...
3 demand_aem ...
4 base_year_assignment_skims_car ...
[5 rows x 8 columns]
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
['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
['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")
Forecast#
We create a set of ‘future’ vectors using some random growth factors. We apply the model for inverse power, as the trip frequency length distribution (TFLD) seems to be a better fit for the actual one.
from aequilibrae.distribution import Ipf, GravityApplication, SyntheticGravityModel
from aequilibrae.matrix import AequilibraeData
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%, and 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")
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")
2024-02-25 08:40:06,638;WARNING ; Matrix Record has been saved to the database
2024-02-25 08:40:06,731;WARNING ; 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()
print(proj_matrices.list())
name ... status
0 demand_omx ...
1 demand_mc ...
2 skims ...
3 demand_aem ...
4 base_year_assignment_skims_car ...
5 demand_power_modeled ...
6 demand_expo_modeled ...
[7 rows x 8 columns]
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")
2024-02-25 08:40:06,805;WARNING ; Matrix Record has been saved to the database
2024-02-25 08:40:06,826;WARNING ; Matrix Record has been saved to the database
<aequilibrae.project.data.matrix_record.MatrixRecord object at 0x7ff1ca5ce730>
df = proj_matrices.list()
Future traffic assignment#
from aequilibrae.paths import TrafficAssignment, TrafficClass
logger.info("\n\n\n TRAFFIC ASSIGNMENT FOR FUTURE YEAR")
2024-02-25 08:40:06,845;INFO ;
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
['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 a 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
OPTIONAL
# If we want to execute select link analysis on a particular TrafficClass, we set the links we are analyzing.
# The format of the input select links is a dictionary (str: list[tuple]).
# Each entry represents a separate set of selected links to compute. The str name will name the set of links.
# The list[tuple] is the list of links being selected, of the form (link_id, direction), as it occurs in the Graph.
# Direction can be 0, 1, -1. 0 denotes bi-directionality
# For example, let's use Select Link on two sets of links:
select_links = {
"Leaving node 1": [(1, 1), (2, 1)],
"Random nodes": [(3, 1), (5, 1)],
}
# We call this command on the class we are analyzing with our dictionary of values
assigclass.set_select_links(select_links)
assig.execute() # we then execute the assignment
/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/aequilibrae/paths/traffic_class.py:166: UserWarning: Input string name has a space in it. Replacing with _
warnings.warn("Input string name has a space in it. Replacing with _")
2024-02-25 08:40:07,124;INFO ; Traffic Class specification
2024-02-25 08:40:07,125;INFO ; {'car': {'Graph': "{'Mode': 'c', 'Block through centroids': False, 'Number of centroids': 24, 'Links': 76, 'Nodes': 24}", 'Matrix': "{'Source': '/tmp/32b3cf7c517e470aae897e460d46ab58/matrices/demand_ipfd.aem', 'Number of centroids': 24, 'Matrix cores': ['matrix'], 'Matrix totals': {'matrix': 383178.2881905334}}", 'select_links': "{'Leaving node 1': [(1, 1), (2, 1)], 'Random nodes': [(3, 1), (5, 1)]}"}}
2024-02-25 08:40:07,125;INFO ; Traffic Assignment specification
2024-02-25 08:40:07,125;INFO ; {'VDF parameters': {'alpha': 'b', 'beta': 'power'}, 'VDF function': 'bpr', 'Number of cores': 4, 'Capacity field': 'capacity', 'Time field': 'free_flow_time', 'Algorithm': 'bfw', 'Maximum iterations': 250, 'Target RGAP': 0.0001}
2024-02-25 08:40:07,127;WARNING ; Cost field with wrong type. Converting to float64
2024-02-25 08:40:07,127;INFO ; bfw Assignment STATS
2024-02-25 08:40:07,127;INFO ; Iteration, RelativeGap, stepsize
2024-02-25 08:40:07,134;INFO ; 1,inf,1.0
2024-02-25 08:40:07,142;INFO ; 2,0.8751743987728927,0.3191922468344516
2024-02-25 08:40:07,148;INFO ; 3,0.5148943855359133,0.17016548477714577
2024-02-25 08:40:07,154;INFO ; 4,0.2855143074391096,0.1820596440202315
2024-02-25 08:40:07,162;INFO ; 5,0.11073856334472275,0.6577892879280489
2024-02-25 08:40:07,175;INFO ; 6,0.24396663392859413,0.11616466932026379
2024-02-25 08:40:07,182;INFO ; 7,0.11247428071783787,0.17783850478329255
2024-02-25 08:40:07,188;INFO ; 8,0.06137588538719,0.6089654825173924
2024-02-25 08:40:07,194;INFO ; 9,0.12716850206697475,0.14306806185983678
2024-02-25 08:40:07,200;INFO ; 10,0.04574106162423547,0.24382091906899286
2024-02-25 08:40:07,216;INFO ; 11,0.04943815385588104,0.5261606810549172
2024-02-25 08:40:07,226;INFO ; 12,0.06427622418288366,0.10810579529781267
2024-02-25 08:40:07,232;INFO ; 13,0.03806560577953316,0.2055073871686453
2024-02-25 08:40:07,238;INFO ; 14,0.03045913339191789,0.25812762259521393
2024-02-25 08:40:07,244;INFO ; 15,0.03304777381974532,0.72624755983576
2024-02-25 08:40:07,254;INFO ; 16,0.04082283202734483,0.09662643404269156
2024-02-25 08:40:07,266;INFO ; 17,0.019281934449515065,0.14745095544837647
2024-02-25 08:40:07,273;INFO ; 18,0.01901177080820419,0.22525133971951034
2024-02-25 08:40:07,279;INFO ; 19,0.015833844386344893,0.3063268704054275
2024-02-25 08:40:07,286;INFO ; 20,0.020791043512151698,0.08268614595071419
2024-02-25 08:40:07,298;INFO ; 21,0.011253277984943409,0.14753421873879669
2024-02-25 08:40:07,305;INFO ; 22,0.012657159676920448,0.2590761375385592
2024-02-25 08:40:07,312;INFO ; 23,0.01550556110866974,0.059306952458223906
2024-02-25 08:40:07,319;INFO ; 24,0.007058099142771472,0.07120475979481979
2024-02-25 08:40:07,326;INFO ; 25,0.007990573245120638,0.11482251713032551
2024-02-25 08:40:07,333;INFO ; 26,0.009135264412219887,0.3952794536874391
2024-02-25 08:40:07,340;INFO ; 27,0.011736021310491299,0.05713787381943355
2024-02-25 08:40:07,347;INFO ; 28,0.006375029328855654,0.054326060121934104
2024-02-25 08:40:07,354;INFO ; 29,0.0054328734784629,0.06772652355375203
2024-02-25 08:40:07,366;INFO ; 30,0.004394298061508366,0.119013894451448
2024-02-25 08:40:07,373;INFO ; 31,0.005249489323712751,0.31563918840009775
2024-02-25 08:40:07,380;INFO ; 32,0.005711624763590253,0.5102971707532196
2024-02-25 08:40:07,387;INFO ; 33,0.007575864643216441,0.03713870566813292
2024-02-25 08:40:07,394;INFO ; 34,0.004296459580628858,0.05481170990470343
2024-02-25 08:40:07,403;INFO ; 35,0.003782625330466585,0.06258209500389797
2024-02-25 08:40:07,411;INFO ; 36,0.004277308799687251,0.13564639843174994
2024-02-25 08:40:07,418;INFO ; 37,0.003607148763340441,0.09368329179095329
2024-02-25 08:40:07,424;INFO ; 38,0.0026259421869643646,0.13223488325940658
2024-02-25 08:40:07,432;INFO ; 39,0.0026926899181044465,0.14591448172858706
2024-02-25 08:40:07,442;INFO ; 40,0.0029432679259635964,0.3350219160310055
2024-02-25 08:40:07,449;INFO ; 41,0.0030794423591628066,0.6939902559618039
2024-02-25 08:40:07,460;INFO ; 42,0.0035223184760729475,0.022142095705204323
2024-02-25 08:40:07,467;INFO ; 43,0.0019176453821441051,0.014423886157406803
2024-02-25 08:40:07,474;INFO ; 44,0.001549297052288871,0.02438858472189468
2024-02-25 08:40:07,482;INFO ; 45,0.0014245591800736434,0.02846600172627678
2024-02-25 08:40:07,489;INFO ; 46,0.0012848677310513684,0.0380769458295948
2024-02-25 08:40:07,496;INFO ; 47,0.001346943537104665,0.039779057992369395
2024-02-25 08:40:07,504;INFO ; 48,0.0011835329362142127,0.04585882372675604
2024-02-25 08:40:07,512;INFO ; 49,0.0009697542817428783,0.033449616519300035
2024-02-25 08:40:07,520;INFO ; 50,0.0008364267411008423,0.042292657683255894
2024-02-25 08:40:07,527;INFO ; 51,0.0008890373776424373,0.05667113616018048
2024-02-25 08:40:07,538;INFO ; 52,0.0009339403266214509,0.06348495311294343
2024-02-25 08:40:07,546;INFO ; 53,0.000965569202399551,0.04458796423380549
2024-02-25 08:40:07,566;INFO ; 54,0.0007604820320653619,0.07487834394189695
2024-02-25 08:40:07,575;INFO ; 55,0.0009113951453293368,0.06141735447668986
2024-02-25 08:40:07,582;INFO ; 56,0.0010582260033622803,0.1265567787722579
2024-02-25 08:40:07,590;INFO ; 57,0.0012273207472562062,0.25735016405805355
2024-02-25 08:40:07,598;INFO ; 58,0.0011818624480240672,0.2420092603793473
2024-02-25 08:40:07,606;INFO ; 59,0.0011059297787929787,0.5202721634463537
2024-02-25 08:40:07,614;INFO ; 60,0.001383285389524617,0.016276506688365184
2024-02-25 08:40:07,622;INFO ; 61,0.0011372645809867648,0.013160949219905974
2024-02-25 08:40:07,633;INFO ; 62,0.0009655880399409981,0.009678220039314815
2024-02-25 08:40:07,642;INFO ; 63,0.0006998065815815409,0.010069397442631571
2024-02-25 08:40:07,649;INFO ; 64,0.0006376463502391555,0.013912785173846958
2024-02-25 08:40:07,658;INFO ; 65,0.0005702461913610448,0.00888175758583816
2024-02-25 08:40:07,664;INFO ; 66,0.0003892061425520018,0.00860096701964504
2024-02-25 08:40:07,672;INFO ; 67,0.0005030737091551298,0.013810472240411962
2024-02-25 08:40:07,682;INFO ; 68,0.00035302097623097134,0.01058768464129397
2024-02-25 08:40:07,697;INFO ; 69,0.00037626253369659433,0.008965902827273862
2024-02-25 08:40:07,705;INFO ; 70,0.0003678131948788984,0.012324616438029259
2024-02-25 08:40:07,714;INFO ; 71,0.0003541692962727624,0.008461811500746158
2024-02-25 08:40:07,725;INFO ; 72,0.0002626396774194881,0.014923022401130118
2024-02-25 08:40:07,734;INFO ; 73,0.00027508391980367194,0.013070823647278233
2024-02-25 08:40:07,746;INFO ; 74,0.00024527350449877187,0.008252133069722598
2024-02-25 08:40:07,758;INFO ; 75,0.00017995595919533558,0.010928920658881973
2024-02-25 08:40:07,766;INFO ; 76,0.00020621978454380454,0.01196876923925933
2024-02-25 08:40:07,778;INFO ; 77,0.00021317021437580259,0.028703992750094734
2024-02-25 08:40:07,786;INFO ; 78,0.00029416908439636814,0.037540508306565454
2024-02-25 08:40:07,795;INFO ; 79,0.0003501083992308858,0.06507469911077642
2024-02-25 08:40:07,806;INFO ; 80,0.00043130695450623437,0.09808734602798513
2024-02-25 08:40:07,815;INFO ; 81,0.00036290990074710594,0.07253288876180589
2024-02-25 08:40:07,824;INFO ; 82,0.0004190536853468342,0.08347542509864643
2024-02-25 08:40:07,834;INFO ; 83,0.00038923325458238713,0.07650651277589515
2024-02-25 08:40:07,849;INFO ; 84,0.00033800062111690306,0.04045728708012256
2024-02-25 08:40:07,859;INFO ; 85,0.0002893465650229788,0.06602214800870104
2024-02-25 08:40:07,866;INFO ; 86,0.0005131630534369235,0.10390795455084717
2024-02-25 08:40:07,875;INFO ; 87,0.000535823413299287,0.13429588940296325
2024-02-25 08:40:07,884;INFO ; 88,0.0005607109816025457,0.17494197312579793
2024-02-25 08:40:07,893;INFO ; 89,0.00038226672187719813,0.10856615225910721
2024-02-25 08:40:07,913;INFO ; 90,0.000425936884304986,0.18249192321392982
2024-02-25 08:40:07,922;INFO ; 91,0.00046435895781508766,0.1759528292416686
2024-02-25 08:40:07,931;INFO ; 92,0.0003747685761062179,0.08744853604002895
2024-02-25 08:40:07,940;INFO ; 93,0.000302992161299362,0.0723767203544899
2024-02-25 08:40:07,954;INFO ; 94,0.00032592700759371624,0.08340248817510156
2024-02-25 08:40:07,963;INFO ; 95,0.0002846631572653612,0.058201525000931155
2024-02-25 08:40:07,971;INFO ; 96,0.0002843277758070591,0.04727562196103801
2024-02-25 08:40:07,980;INFO ; 97,0.0002440574749230021,0.03525048835386052
2024-02-25 08:40:07,990;INFO ; 98,0.00026875483320118584,0.04722840313676394
2024-02-25 08:40:07,999;INFO ; 99,0.00023550824607748998,0.03839934685721819
2024-02-25 08:40:08,008;INFO ; 100,0.000200792169647963,0.03453112232677591
2024-02-25 08:40:08,016;INFO ; 101,0.00015938426500784547,0.06062399938087385
2024-02-25 08:40:08,025;INFO ; 102,0.0001806441509940231,0.039304453264177384
2024-02-25 08:40:08,037;INFO ; 103,0.0001535167099299698,0.03167281391549588
2024-02-25 08:40:08,047;INFO ; 104,0.00015010145587419072,0.02003192696172428
2024-02-25 08:40:08,054;INFO ; 105,0.0001145239461797446,0.01718176329051654
2024-02-25 08:40:08,063;INFO ; 106,0.00011280031501250603,0.013550097529657197
2024-02-25 08:40:08,073;INFO ; 107,8.74814456675593e-05,0.012724717541059477
2024-02-25 08:40:08,097;INFO ; 108,9.277204303219284e-05,0.010400036155993721
2024-02-25 08:40:08,107;INFO ; 109,7.419355904325669e-05,0.011790244207072715
2024-02-25 08:40:08,117;INFO ; 110,7.638336819561763e-05,0.007705840657446993
2024-02-25 08:40:08,130;INFO ; 111,5.5790174704699905e-05,0.008701787695498604
2024-02-25 08:40:08,142;INFO ; 112,5.202973884368533e-05,0.006478281319855596
2024-02-25 08:40:08,155;INFO ; 113,5.607149741293651e-05,0.006333357629265129
2024-02-25 08:40:08,164;INFO ; 114,4.302552689436121e-05,0.005977655781164309
2024-02-25 08:40:08,174;INFO ; 115,5.959410033330578e-05,0.003796677809623135
2024-02-25 08:40:08,183;INFO ; 116,4.1208510962436075e-05,0.0029368616971249904
2024-02-25 08:40:08,192;INFO ; 117,3.850584978623943e-05,0.0014271856751775418
2024-02-25 08:40:08,202;INFO ; 118,3.179288205203885e-05,0.003138899566595786
2024-02-25 08:40:08,212;INFO ; 119,3.91426117284476e-05,0.004400468683708101
2024-02-25 08:40:08,222;INFO ; 120,4.5722062301856145e-05,0.005923776345705935
2024-02-25 08:40:08,233;INFO ; 121,4.485551489754978e-05,0.003780835522767388
2024-02-25 08:40:08,243;INFO ; 122,3.909591665974157e-05,0.002646193589556619
2024-02-25 08:40:08,254;INFO ; 123,4.220162131078537e-05,0.005557186368801195
2024-02-25 08:40:08,267;INFO ; 124,3.908315806033473e-05,0.002914181614586738
2024-02-25 08:40:08,278;INFO ; 125,3.891722000452981e-05,0.004517857499107047
2024-02-25 08:40:08,288;INFO ; 126,4.032383494610489e-05,0.005136735819672502
2024-02-25 08:40:08,296;INFO ; 127,4.295327117164529e-05,0.00834224904360295
2024-02-25 08:40:08,306;INFO ; 128,4.440680789355792e-05,0.0066065890038936835
2024-02-25 08:40:08,316;INFO ; 129,3.881801683629375e-05,0.0036534030652988067
2024-02-25 08:40:08,325;INFO ; 130,4.2393386935324675e-05,0.004614768628399797
2024-02-25 08:40:08,341;INFO ; 131,4.1267211732015936e-05,0.003226731847233014
2024-02-25 08:40:08,357;INFO ; 132,3.225999876192584e-05,0.00594129942924565
2024-02-25 08:40:08,367;INFO ; 133,4.7865594003196406e-05,0.004681331345996398
2024-02-25 08:40:08,376;INFO ; 134,4.910616878108511e-05,0.009874720741398347
2024-02-25 08:40:08,386;INFO ; 135,5.1877005175882514e-05,0.005540356708935855
2024-02-25 08:40:08,397;INFO ; 136,5.4906098267834156e-05,0.008059717223930238
2024-02-25 08:40:08,411;INFO ; 137,6.29258615462991e-05,0.006262926954999543
2024-02-25 08:40:08,421;INFO ; 138,5.152396935155804e-05,0.007744099352863108
2024-02-25 08:40:08,435;INFO ; 139,5.4419577306710664e-05,0.005747172409655814
2024-02-25 08:40:08,446;INFO ; 140,3.9015244346374567e-05,0.004547170904625792
2024-02-25 08:40:08,456;INFO ; 141,3.2518993999241365e-05,0.0018535205849699553
2024-02-25 08:40:08,466;INFO ; 142,2.468734596518841e-05,0.003086317743647142
2024-02-25 08:40:08,476;INFO ; 143,2.6330986034797324e-05,0.0016592239820802926
2024-02-25 08:40:08,488;INFO ; 144,3.608556565143246e-05,0.003625530668595296
2024-02-25 08:40:08,503;INFO ; 145,3.971053323553448e-05,0.004822420184736065
2024-02-25 08:40:08,513;INFO ; 146,3.1157449818824116e-05,0.005789430740156337
2024-02-25 08:40:08,523;INFO ; 147,2.7333568409488776e-05,0.0038135345521345225
2024-02-25 08:40:08,533;INFO ; 148,3.1034612445420775e-05,0.0038870655491796023
2024-02-25 08:40:08,546;INFO ; 149,2.6291083575199078e-05,0.006482286780915554
2024-02-25 08:40:08,557;INFO ; 150,3.40094678575685e-05,0.007348789831230918
2024-02-25 08:40:08,567;INFO ; 151,3.1587679569411026e-05,0.0073634443921796276
2024-02-25 08:40:08,582;INFO ; 152,3.581762760953725e-05,0.005123445359501579
2024-02-25 08:40:08,592;INFO ; 153,3.920804714149658e-05,0.0035464616949759027
2024-02-25 08:40:08,607;INFO ; 154,3.485075192091596e-05,0.003260451797416738
2024-02-25 08:40:08,619;INFO ; 155,4.0194782945185994e-05,0.0025417530346401097
2024-02-25 08:40:08,630;INFO ; 156,3.50988920583392e-05,0.005178152389118472
2024-02-25 08:40:08,641;INFO ; 157,4.117365485196034e-05,0.0060626020876544135
2024-02-25 08:40:08,651;INFO ; 158,5.2279553811387244e-05,0.006377900818056326
2024-02-25 08:40:08,661;INFO ; 159,4.513542610761661e-05,0.00613101097422964
2024-02-25 08:40:08,672;INFO ; 160,4.8882088115305746e-05,0.0060028741951034135
2024-02-25 08:40:08,683;INFO ; 161,2.985740617822698e-05,0.0016110253657516417
2024-02-25 08:40:08,694;INFO ; 162,2.9267194367283363e-05,0.004853010411047603
2024-02-25 08:40:08,704;INFO ; 163,2.3937131577862173e-05,0.0014483096899476247
2024-02-25 08:40:08,716;INFO ; 164,2.765779761194046e-05,0.0027565193521607904
2024-02-25 08:40:08,730;INFO ; 165,2.876855152562792e-05,0.001831628176302203
2024-02-25 08:40:08,741;INFO ; 166,2.537762932914137e-05,0.001003699529175469
2024-02-25 08:40:08,752;INFO ; 167,2.2910724852049266e-05,0.0016151335917130149
2024-02-25 08:40:08,763;INFO ; 168,2.607739289990307e-05,0.002244518805129917
2024-02-25 08:40:08,776;INFO ; 169,2.858700959190604e-05,0.004743334852526586
2024-02-25 08:40:08,787;INFO ; 170,4.374443595418917e-05,0.007177073871569347
2024-02-25 08:40:08,798;INFO ; 171,3.5580334003483754e-05,0.004711551427551073
2024-02-25 08:40:08,809;INFO ; 172,4.076829681564313e-05,0.004728188845913447
2024-02-25 08:40:08,821;INFO ; 173,3.3168233471022746e-05,0.006268226953442663
2024-02-25 08:40:08,832;INFO ; 174,3.459088456228441e-05,0.0035817584819964397
2024-02-25 08:40:08,844;INFO ; 175,4.0245034969120026e-05,0.007827229791464364
2024-02-25 08:40:08,856;INFO ; 176,4.277286153924346e-05,0.0037730257079247246
2024-02-25 08:40:08,866;INFO ; 177,3.884359525285034e-05,0.010343608197812222
2024-02-25 08:40:08,877;INFO ; 178,3.5505269664177876e-05,0.006466021014990068
2024-02-25 08:40:08,889;INFO ; 179,4.23160090189053e-05,0.012096303534299887
2024-02-25 08:40:08,901;INFO ; 180,4.161954096305764e-05,0.014433907994290205
2024-02-25 08:40:08,912;INFO ; 181,4.385866312045939e-05,0.01358304353887882
2024-02-25 08:40:08,924;INFO ; 182,4.65610241401527e-05,0.01603098188432622
2024-02-25 08:40:08,935;INFO ; 183,5.735762623985161e-05,0.021793544762250927
2024-02-25 08:40:08,964;INFO ; 184,8.79613502938366e-05,0.03311085965333211
2024-02-25 08:40:08,976;INFO ; 185,6.069244920863114e-05,0.0417962445251903
2024-02-25 08:40:08,987;INFO ; 186,7.973773702641913e-05,0.03351957090491426
2024-02-25 08:40:08,998;INFO ; 187,8.759276175933146e-05,0.08169800217037587
2024-02-25 08:40:09,010;INFO ; 188,8.13557167290555e-05,0.03584463903643895
2024-02-25 08:40:09,022;INFO ; 189,7.876954414902043e-05,0.09410801592875513
2024-02-25 08:40:09,034;INFO ; 190,7.690268221997518e-05,0.04249279353999281
2024-02-25 08:40:09,046;INFO ; 191,9.655281439835302e-05,0.11734605167553976
2024-02-25 08:40:09,059;INFO ; 192,0.00010037710842643067,0.05897930988677592
2024-02-25 08:40:09,071;INFO ; 193,0.00011112505281370028,0.09839045797959708
2024-02-25 08:40:09,083;INFO ; 194,0.0001172976880687515,0.192901916827043
2024-02-25 08:40:09,110;INFO ; 195,8.716513941351405e-05,0.21127216028114199
2024-02-25 08:40:09,126;INFO ; 196,0.0001273988285661895,0.214046209435249
2024-02-25 08:40:09,139;INFO ; 197,0.0001403661621310454,0.48871442455225517
2024-02-25 08:40:09,154;INFO ; 198,0.00016500550577377732,0.6557608846691126
2024-02-25 08:40:09,166;INFO ; 199,0.00015628392555408773,0.001098237597439844
2024-02-25 08:40:09,179;INFO ; 200,8.365367760484624e-05,0.0011577890189035224
2024-02-25 08:40:09,193;INFO ; 201,7.762445156420053e-05,0.0012948367185908393
2024-02-25 08:40:09,205;INFO ; 202,6.803341075410233e-05,0.0012369160763155528
2024-02-25 08:40:09,217;INFO ; 203,5.6110755643412036e-05,0.0023155698771000414
2024-02-25 08:40:09,230;INFO ; 204,5.791714478964776e-05,0.0015159384716421412
2024-02-25 08:40:09,244;INFO ; 205,5.3117197717279404e-05,0.0028270022349129458
2024-02-25 08:40:09,256;INFO ; 206,5.714835441533892e-05,0.001869360551590956
2024-02-25 08:40:09,270;INFO ; 207,4.890230445205765e-05,0.0027662769564724644
2024-02-25 08:40:09,286;INFO ; 208,5.0448078190775315e-05,0.0015666367331021137
2024-02-25 08:40:09,299;INFO ; 209,4.2537991809133183e-05,0.0030281811726468864
2024-02-25 08:40:09,311;INFO ; 210,3.441750364798779e-05,0.0007835590549285011
2024-02-25 08:40:09,324;INFO ; 211,2.3662857356897335e-05,0.0009365762024569954
2024-02-25 08:40:09,338;INFO ; 212,3.299182514737407e-05,0.0010526146829917666
2024-02-25 08:40:09,353;INFO ; 213,3.2399910669629766e-05,0.0011598414963247586
2024-02-25 08:40:09,366;INFO ; 214,2.6710357030408222e-05,0.0007972807067406392
2024-02-25 08:40:09,379;INFO ; 215,1.9544717099704193e-05,0.0006319178761322575
2024-02-25 08:40:09,406;INFO ; 216,1.6920847348812834e-05,0.0005895844737360317
2024-02-25 08:40:09,422;INFO ; 217,1.422509636469241e-05,0.00022793263595290592
2024-02-25 08:40:09,434;INFO ; 218,1.523225484130839e-05,0.000715164367852452
2024-02-25 08:40:09,447;INFO ; 219,1.789726218842294e-05,0.000590267532537014
2024-02-25 08:40:09,459;INFO ; 220,1.624334221148068e-05,0.0006060558780826596
2024-02-25 08:40:09,472;INFO ; 221,2.1255402254091753e-05,0.0011267534161276958
2024-02-25 08:40:09,486;INFO ; 222,2.0379313772245795e-05,0.0018234135179961539
2024-02-25 08:40:09,499;INFO ; 223,2.088154803299229e-05,0.0011470753927410227
2024-02-25 08:40:09,511;INFO ; 224,1.7043951832304637e-05,0.0013504085933752055
2024-02-25 08:40:09,524;INFO ; 225,1.8652860327634315e-05,0.0012186435682888664
2024-02-25 08:40:09,537;INFO ; 226,1.6284278845558936e-05,0.0008040557191802872
2024-02-25 08:40:09,551;INFO ; 227,1.3736400469890268e-05,0.0006797161158739944
2024-02-25 08:40:09,565;INFO ; 228,1.2601608522822777e-05,0.0007298485082563993
2024-02-25 08:40:09,578;INFO ; 229,1.2898404297146098e-05,0.0007148021359426411
2024-02-25 08:40:09,592;INFO ; 230,1.3968774066133976e-05,0.0021390523143542625
2024-02-25 08:40:09,610;INFO ; 231,1.9190425877496155e-05,0.0018729504326254096
2024-02-25 08:40:09,625;INFO ; 232,1.9031110798128113e-05,0.002336395563913646
2024-02-25 08:40:09,643;INFO ; 233,1.9964255156903338e-05,0.0025452884645833446
2024-02-25 08:40:09,659;INFO ; 234,1.523339766097751e-05,0.000940440712619752
2024-02-25 08:40:09,674;INFO ; 235,1.3888996095974238e-05,0.0017103730637431354
2024-02-25 08:40:09,691;INFO ; 236,1.462341016994341e-05,0.0011959697135053944
2024-02-25 08:40:09,707;INFO ; 237,1.4764562759046479e-05,0.0023969453661072514
2024-02-25 08:40:09,730;INFO ; 238,1.6121903821681302e-05,0.002633009842629811
2024-02-25 08:40:09,749;INFO ; 239,1.3476729273031213e-05,0.0014782674968071756
2024-02-25 08:40:09,771;INFO ; 240,1.1842113700450975e-05,0.0037138890374857282
2024-02-25 08:40:09,790;INFO ; 241,1.1250124440696712e-05,0.0012035677683921006
2024-02-25 08:40:09,804;INFO ; 242,7.240299427449257e-06,0.0007300154369215753
2024-02-25 08:40:09,804;INFO ; bfw Assignment finished. 242 iterations and 7.240299427449257e-06 final gap
Now let us save our select link results, all we need to do is provide it with a name In addition to exporting the select link flows, it also exports the Select Link matrices in OMX format.
assig.save_select_link_results("select_link_analysis")
Say we just want to save our select link flows, we can call:
assig.save_select_link_flows("just_flows")
# Or if we just want the SL matrices:
assig.save_select_link_matrices("just_matrices")
# Internally, the save_select_link_results calls both of these methods at once.
# 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")
2024-02-25 08:40:09,868;WARNING ; 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()
Total running time of the script: (0 minutes 5.203 seconds)