7.15. 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
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, 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.  Which is true, but we won't use those fields
2023-04-05 06:54:44,650;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2023-04-05 06:54:44,700;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2023-04-05 06:54:44,750;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2023-04-05 06:54:44,797;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2023-04-05 06:54:44,841;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations
2023-04-05 06:54:44,882;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 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)
2023-04-05 06:54:44,912;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
proj_matrices.list()
name file_name cores procedure procedure_id timestamp description status
0 demand_omx demand.omx 1 None None 2020-11-24 08:47:18 Original data imported to OMX format
1 demand_mc demand_mc.omx 3 None None 2021-02-24 00:51:35 None
2 skims skims.omx 2 None None None Example skim
3 demand_aem demand.aem 1 None None 2020-11-24 08:46:42 Original data imported to AEM format


# 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
2023-04-05 06:54:45,228;WARNING ; Cost field with wrong type. Converting to float64
2023-04-05 06:54:45,228;INFO ; bfw Assignment STATS
2023-04-05 06:54:45,228;INFO ; Iteration, RelativeGap, stepsize
2023-04-05 06:54:45,235;INFO ; 1,inf,1.0
2023-04-05 06:54:45,242;INFO ; 2,0.8550751349428284,0.32839952448634563
2023-04-05 06:54:45,250;INFO ; 3,0.4763455007221067,0.18660240547488702
2023-04-05 06:54:45,258;INFO ; 4,0.2355126365951965,0.2411477440291793
2023-04-05 06:54:45,267;INFO ; 5,0.10924072010481088,0.8185470737942447
2023-04-05 06:54:45,274;INFO ; 6,0.1980945227617506,0.14054330572978305
2023-04-05 06:54:45,282;INFO ; 7,0.0668172221544687,0.36171152718899247
2023-04-05 06:54:45,290;INFO ; 8,0.06792122267870587,0.9634685345644044
2023-04-05 06:54:45,297;INFO ; 9,0.10705582933092855,0.13757153109677187
2023-04-05 06:54:45,303;INFO ; 10,0.04038814432034622,0.1609403425427973
2023-04-05 06:54:45,311;INFO ; 11,0.025801226183773084,0.716435057617116
2023-04-05 06:54:45,319;INFO ; 12,0.042846437173170424,0.08581544277016687
2023-04-05 06:54:45,326;INFO ; 13,0.016971662333407043,0.1660157969033195
2023-04-05 06:54:45,333;INFO ; 14,0.020396548012132195,0.4461322062863191
2023-04-05 06:54:45,342;INFO ; 15,0.025887901335905694,0.08515995223661561
2023-04-05 06:54:45,349;INFO ; 16,0.015188959427663162,0.1988698342670051
2023-04-05 06:54:45,358;INFO ; 17,0.01475141964322897,0.3548856159715819
2023-04-05 06:54:45,366;INFO ; 18,0.015582407302127808,0.06145415154081679
2023-04-05 06:54:45,373;INFO ; 19,0.008935871473338547,0.08603462968532699
2023-04-05 06:54:45,379;INFO ; 20,0.008477045208211683,0.1668913886047936
2023-04-05 06:54:45,388;INFO ; 21,0.009517581409988221,0.4917099156011133
2023-04-05 06:54:45,396;INFO ; 22,0.013060711845093087,0.060284308755231206
2023-04-05 06:54:45,402;INFO ; 23,0.006861821876765184,0.10954009782378307
2023-04-05 06:54:45,409;INFO ; 24,0.006201113315688483,0.12230718464290123
2023-04-05 06:54:45,415;INFO ; 25,0.0074574049738041406,0.3080614235512652
2023-04-05 06:54:45,423;INFO ; 26,0.006900497787039256,0.32835666337221175
2023-04-05 06:54:45,430;INFO ; 27,0.006963554132391016,0.7377893941135681
2023-04-05 06:54:45,437;INFO ; 28,0.006817764279834173,0.0443870768699142
2023-04-05 06:54:45,445;INFO ; 29,0.004277860366532555,0.05431813621783447
2023-04-05 06:54:45,451;INFO ; 30,0.004136181096381436,0.05758294976347482
2023-04-05 06:54:45,461;INFO ; 31,0.0031483923250298237,0.0918038853550363
2023-04-05 06:54:45,467;INFO ; 32,0.0034184967969881734,0.12279944254979965
2023-04-05 06:54:45,475;INFO ; 33,0.002738614050254322,0.08799214942487946
2023-04-05 06:54:45,481;INFO ; 34,0.0023403784016331874,0.1098259985006849
2023-04-05 06:54:45,490;INFO ; 35,0.0023185435502055523,0.18741920884713098
2023-04-05 06:54:45,497;INFO ; 36,0.0023838181828793143,0.1404967362503087
2023-04-05 06:54:45,504;INFO ; 37,0.0017801377860521138,0.25278698153070905
2023-04-05 06:54:45,511;INFO ; 38,0.0019264349761422953,0.30768123024764726
2023-04-05 06:54:45,519;INFO ; 39,0.0018408894375062524,0.3982324050247662
2023-04-05 06:54:45,526;INFO ; 40,0.0018205742523357215,0.5255149131180074
2023-04-05 06:54:45,534;INFO ; 41,0.0020224171108353135,0.012343794696331265
2023-04-05 06:54:45,542;INFO ; 42,0.001423836778473865,0.03045402621736974
2023-04-05 06:54:45,549;INFO ; 43,0.0011877471305860427,0.02283308748607117
2023-04-05 06:54:45,557;INFO ; 44,0.0012106681494599195,0.06969126002892805
2023-04-05 06:54:45,566;INFO ; 45,0.0011336232568064097,0.038970964685986896
2023-04-05 06:54:45,573;INFO ; 46,0.0009780989052684459,0.022071990851560294
2023-04-05 06:54:45,573;INFO ; bfw Assignment finished. 46 iterations and 0.0009780989052684459 final gap
# Convergence report is easy to see
import pandas as pd

convergence_report = assig.report()
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()
volumes.head()
matrix_ab matrix_ba matrix_tot Congested_Time_AB Congested_Time_BA Congested_Time_Max Delay_factor_AB Delay_factor_BA Delay_factor_Max VOC_AB VOC_BA VOC_max PCE_AB PCE_BA PCE_tot
link_id
1 4565.043510 NaN 4565.043510 6.000869 NaN 6.000869 1.000145 NaN 1.000145 0.176255 NaN 0.176255 4565.043510 NaN 4565.043510
2 8152.210795 NaN 8152.210795 4.008833 NaN 4.008833 1.002208 NaN 1.002208 0.348333 NaN 0.348333 8152.210795 NaN 8152.210795
3 4552.603997 NaN 4552.603997 6.000859 NaN 6.000859 1.000143 NaN 1.000143 0.175775 NaN 0.175775 4552.603997 NaN 4552.603997
4 5988.789717 NaN 5988.789717 6.596350 NaN 6.596350 1.319270 NaN 1.319270 1.207860 NaN 1.207860 5988.789717 NaN 5988.789717
5 8164.650309 NaN 8164.650309 4.008888 NaN 4.008888 1.002222 NaN 1.002222 0.348865 NaN 0.348865 8164.650309 NaN 8164.650309


# 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")
2023-04-05 06:54:45,651;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
proj_matrices.list()
name file_name cores procedure procedure_id timestamp description status
0 demand_omx demand.omx 1 None None 2020-11-24 08:47:18 Original data imported to OMX format
1 demand_mc demand_mc.omx 3 None None 2021-02-24 00:51:35 None
2 skims skims.omx 2 None None None Example skim
3 demand_aem demand.aem 1 None None 2020-11-24 08:46:42 Original data imported to AEM format
4 base_year_assignment_skims_car base_year_assignment_skims_car.omx 4 Traffic Assignment 43eea698f1f843afb4994f9921e73476 2023-04-05 06:54:44.970850 Skimming for assignment procedure. Class car


# 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 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")
2023-04-05 06:54:46,616;WARNING ; Matrix Record has been saved to the database
2023-04-05 06:54:46,800;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()
proj_matrices.list()
name file_name cores procedure procedure_id timestamp description status
0 demand_omx demand.omx 1 None None 2020-11-24 08:47:18 Original data imported to OMX format
1 demand_mc demand_mc.omx 3 None None 2021-02-24 00:51:35 None
2 skims skims.omx 2 None None None Example skim
3 demand_aem demand.aem 1 None None 2020-11-24 08:46:42 Original data imported to AEM format
4 base_year_assignment_skims_car base_year_assignment_skims_car.omx 4 Traffic Assignment 43eea698f1f843afb4994f9921e73476 2023-04-05 06:54:44.970850 Skimming for assignment procedure. Class car
5 demand_power_modeled demand_power_modeled.omx 1 Synthetic gravity trip distribution b5d8f3776bfc43cd88d23be890c212a8 2023-04-05 06:54:46.547665 Synthetic gravity trip distribution. POWER
6 demand_expo_modeled demand_expo_modeled.omx 1 Synthetic gravity trip distribution 23be58f94dbb43de977715ca80149f58 2023-04-05 06:54:46.729866 Synthetic gravity trip distribution. EXPO


### 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")
2023-04-05 06:54:46,885;WARNING ; Matrix Record has been saved to the database
2023-04-05 06:54:46,906;WARNING ; Matrix Record has been saved to the database

<aequilibrae.project.data.matrix_record.MatrixRecord object at 0x7ffb438db7c0>
proj_matrices.list()
name file_name cores procedure procedure_id timestamp description status
0 demand_omx demand.omx 1 None None 2020-11-24 08:47:18 Original data imported to OMX format
1 demand_mc demand_mc.omx 3 None None 2021-02-24 00:51:35 None
2 skims skims.omx 2 None None None Example skim
3 demand_aem demand.aem 1 None None 2020-11-24 08:46:42 Original data imported to AEM format
4 base_year_assignment_skims_car base_year_assignment_skims_car.omx 4 Traffic Assignment 43eea698f1f843afb4994f9921e73476 2023-04-05 06:54:44.970850 Skimming for assignment procedure. Class car
5 demand_power_modeled demand_power_modeled.omx 1 Synthetic gravity trip distribution b5d8f3776bfc43cd88d23be890c212a8 2023-04-05 06:54:46.547665 Synthetic gravity trip distribution. POWER
6 demand_expo_modeled demand_expo_modeled.omx 1 Synthetic gravity trip distribution 23be58f94dbb43de977715ca80149f58 2023-04-05 06:54:46.729866 Synthetic gravity trip distribution. EXPO
7 demand_ipfd demand_ipfd.aem 1 Iterative Proportional fitting 7a62cb15718c4b7392498f93a20f6563 2023-04-05 06:54:46.869423 None
8 demand_ipfd_omx demand_ipfd.omx 1 Iterative Proportional fitting 7a62cb15718c4b7392498f93a20f6563 2023-04-05 06:54:46.869423 None


## Future traffic assignment
from aequilibrae.paths import TrafficAssignment, TrafficClass
logger.info("\n\n\n TRAFFIC ASSIGNMENT FOR FUTURE YEAR")
2023-04-05 06:54:46,923;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 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 analysing
# 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 analysing with our dictionary of values
assigclass.set_select_links(select_links)

assig.execute()  # we then execute the assignment
/home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/traffic_class.py:104: UserWarning: Input string name has a space in it. Replacing with _
  warnings.warn("Input string name has a space in it. Replacing with _")
2023-04-05 06:54:47,327;WARNING ; Cost field with wrong type. Converting to float64
2023-04-05 06:54:47,328;INFO ; bfw Assignment STATS
2023-04-05 06:54:47,328;INFO ; Iteration, RelativeGap, stepsize
2023-04-05 06:54:47,336;INFO ; 1,inf,1.0
2023-04-05 06:54:47,345;INFO ; 2,0.8875329780241354,0.3201848250267999
2023-04-05 06:54:47,356;INFO ; 3,0.5497329875472731,0.16650298618750525
2023-04-05 06:54:47,366;INFO ; 4,0.323893451804238,0.17429734524369087
2023-04-05 06:54:47,376;INFO ; 5,0.17694905941443584,0.29812955007437664
2023-04-05 06:54:47,386;INFO ; 6,0.1664430466700266,0.24589691779824158
2023-04-05 06:54:47,397;INFO ; 7,0.1338846962024004,0.20592548413497946
2023-04-05 06:54:47,405;INFO ; 8,0.1049708581265228,0.20953297987909542
2023-04-05 06:54:47,414;INFO ; 9,0.0974054718696716,0.20574498837405344
2023-04-05 06:54:47,424;INFO ; 10,0.08557233479679272,0.17647328650125682
2023-04-05 06:54:47,433;INFO ; 11,0.06368691657777613,0.20945526762530403
2023-04-05 06:54:47,441;INFO ; 12,0.07184446272874975,0.15301766436298925
2023-04-05 06:54:47,450;INFO ; 13,0.04516082262721909,0.21148020906306136
2023-04-05 06:54:47,461;INFO ; 14,0.06092508471994254,0.12300387067900453
2023-04-05 06:54:47,471;INFO ; 15,0.025808659728148373,0.5578457826753963
2023-04-05 06:54:47,482;INFO ; 16,0.0683354225603165,0.09032576691727728
2023-04-05 06:54:47,490;INFO ; 17,0.03256369130607155,0.12204257081063324
2023-04-05 06:54:47,505;INFO ; 18,0.020288778963611247,0.15909944154096592
2023-04-05 06:54:47,513;INFO ; 19,0.01872409968974328,0.600726309505817
2023-04-05 06:54:47,523;INFO ; 20,0.040929237173435405,0.08295965338563387
2023-04-05 06:54:47,534;INFO ; 21,0.0173974378733681,0.15078241339890947
2023-04-05 06:54:47,545;INFO ; 22,0.017699923737146496,0.09087636533944456
2023-04-05 06:54:47,555;INFO ; 23,0.012348037493058609,0.47048730523124566
2023-04-05 06:54:47,564;INFO ; 24,0.02079677950618704,0.6690722363076007
2023-04-05 06:54:47,572;INFO ; 25,0.015149350579191548,0.04465439152474888
2023-04-05 06:54:47,582;INFO ; 26,0.010409216860794575,0.10910773119985535
2023-04-05 06:54:47,592;INFO ; 27,0.01033177014848819,0.2744920194463344
2023-04-05 06:54:47,602;INFO ; 28,0.009974292218167938,0.35909181772711557
2023-04-05 06:54:47,613;INFO ; 29,0.009658162247470585,0.9500728956197241
2023-04-05 06:54:47,621;INFO ; 30,0.009900253365719137,0.06100215050734815
2023-04-05 06:54:47,630;INFO ; 31,0.005836170230756646,0.08012907148806266
2023-04-05 06:54:47,640;INFO ; 32,0.005964829537745595,0.09331344139758983
2023-04-05 06:54:47,648;INFO ; 33,0.004772753636644955,0.08550430246462018
2023-04-05 06:54:47,658;INFO ; 34,0.004253049062710224,0.1140961458902784
2023-04-05 06:54:47,668;INFO ; 35,0.004161581612582201,0.15483117828370901
2023-04-05 06:54:47,677;INFO ; 36,0.005086149628055217,0.36593757069506816
2023-04-05 06:54:47,686;INFO ; 37,0.005877787137519752,0.04418650116127216
2023-04-05 06:54:47,694;INFO ; 38,0.004051983049296236,0.05513459062247517
2023-04-05 06:54:47,703;INFO ; 39,0.003388448878967629,0.056347213478294626
2023-04-05 06:54:47,712;INFO ; 40,0.0031158091069150204,0.09448305820310472
2023-04-05 06:54:47,722;INFO ; 41,0.0033314678386324155,0.2595968901178862
2023-04-05 06:54:47,733;INFO ; 42,0.004589498333047726,0.5947471121776181
2023-04-05 06:54:47,743;INFO ; 43,0.004583103325563623,0.034937854609627214
2023-04-05 06:54:47,751;INFO ; 44,0.0034855189717573035,0.01795501669484237
2023-04-05 06:54:47,761;INFO ; 45,0.0021594515909994522,0.015237889612265243
2023-04-05 06:54:47,770;INFO ; 46,0.0015201980064803507,0.02650102679159836
2023-04-05 06:54:47,779;INFO ; 47,0.001478909543447863,0.03133024019918003
2023-04-05 06:54:47,787;INFO ; 48,0.0015474050861605912,0.042296342596129556
2023-04-05 06:54:47,796;INFO ; 49,0.0017241904284622477,0.0750858448420766
2023-04-05 06:54:47,805;INFO ; 50,0.001786240111834856,0.08994790704557001
2023-04-05 06:54:47,814;INFO ; 51,0.0013395401905190885,0.08897519155574617
2023-04-05 06:54:47,828;INFO ; 52,0.0016639971084888821,0.12452827755073878
2023-04-05 06:54:47,836;INFO ; 53,0.0019157328950587177,0.21257598218637114
2023-04-05 06:54:47,846;INFO ; 54,0.001874219182820863,0.14551338578158463
2023-04-05 06:54:47,855;INFO ; 55,0.001327708652146186,0.5166629626305033
2023-04-05 06:54:47,865;INFO ; 56,0.0022649520166786266,0.681331516285175
2023-04-05 06:54:47,876;INFO ; 57,0.0018864940140768884,0.007776485060565669
2023-04-05 06:54:47,886;INFO ; 58,0.0010665003545049002,0.015728415031557842
2023-04-05 06:54:47,896;INFO ; 59,0.0011820917547615503,0.019693915417992335
2023-04-05 06:54:47,904;INFO ; 60,0.0012435724444305812,0.036806336843092285
2023-04-05 06:54:47,913;INFO ; 61,0.0013798326871559477,0.03398187384081423
2023-04-05 06:54:47,922;INFO ; 62,0.0010003853991413186,0.03865379494045287
2023-04-05 06:54:47,932;INFO ; 63,0.0009365771163376435,0.026709787977170846
2023-04-05 06:54:47,940;INFO ; 64,0.0005745709083114423,0.005462693181691034
2023-04-05 06:54:47,950;INFO ; 65,0.0005449079300314392,0.007764826892529016
2023-04-05 06:54:47,959;INFO ; 66,0.0004659944573838312,0.00657503549145921
2023-04-05 06:54:47,969;INFO ; 67,0.000345242911189726,0.005545132950014346
2023-04-05 06:54:47,978;INFO ; 68,0.0003513984838763961,0.00800029740792924
2023-04-05 06:54:47,987;INFO ; 69,0.0003736738500698268,0.01254205324572157
2023-04-05 06:54:47,996;INFO ; 70,0.000295014462852671,0.011864677514150412
2023-04-05 06:54:48,005;INFO ; 71,0.0003742883614660836,0.015369042173297785
2023-04-05 06:54:48,014;INFO ; 72,0.0003954718726830285,0.027681880247437413
2023-04-05 06:54:48,022;INFO ; 73,0.0004330053576396822,0.035453281079383295
2023-04-05 06:54:48,033;INFO ; 74,0.0003867756133004936,0.031088972794437935
2023-04-05 06:54:48,044;INFO ; 75,0.00034348542880475975,0.017873725383527432
2023-04-05 06:54:48,053;INFO ; 76,0.0002967919339946479,0.027452116752121128
2023-04-05 06:54:48,064;INFO ; 77,0.00027601309820352526,0.03154594384859067
2023-04-05 06:54:48,073;INFO ; 78,0.00024159896397975362,0.016685616719247842
2023-04-05 06:54:48,083;INFO ; 79,0.0002823660972487077,0.01885999016520764
2023-04-05 06:54:48,093;INFO ; 80,0.00030285152579607555,0.03077555615064865
2023-04-05 06:54:48,102;INFO ; 81,0.0003036491568903193,0.052590122991178254
2023-04-05 06:54:48,112;INFO ; 82,0.000281497175062058,0.05600871238883498
2023-04-05 06:54:48,122;INFO ; 83,0.00028621295231774494,0.03810782530487133
2023-04-05 06:54:48,131;INFO ; 84,0.00024012777089030415,0.062272868018706434
2023-04-05 06:54:48,141;INFO ; 85,0.00025768724454043644,0.04853781949670654
2023-04-05 06:54:48,150;INFO ; 86,0.0002186196560703223,0.05415450864416192
2023-04-05 06:54:48,161;INFO ; 87,0.00025881109396098164,0.053200270869620286
2023-04-05 06:54:48,171;INFO ; 88,0.0002792999103030258,0.07135202048908011
2023-04-05 06:54:48,181;INFO ; 89,0.0003305522691417716,0.09958087580238491
2023-04-05 06:54:48,190;INFO ; 90,0.0002515417116629189,0.11301598547340415
2023-04-05 06:54:48,199;INFO ; 91,0.0003760956716875648,0.29725250196959485
2023-04-05 06:54:48,209;INFO ; 92,0.0004342771960300819,0.39050345704709705
2023-04-05 06:54:48,219;INFO ; 93,0.00037639617858140865,0.28613314987340904
2023-04-05 06:54:48,230;INFO ; 94,0.00032385811077734417,0.3774450040287059
2023-04-05 06:54:48,240;INFO ; 95,0.0003333638876783605,0.4251533099398291
2023-04-05 06:54:48,250;INFO ; 96,0.00030680101337645515,0.9696957586854609
2023-04-05 06:54:48,260;INFO ; 97,0.00031097753994411295,0.0019486176566524964
2023-04-05 06:54:48,270;INFO ; 98,0.0002613082117366081,0.0026902980777807365
2023-04-05 06:54:48,279;INFO ; 99,0.00023201108871097345,0.003175909886601439
2023-04-05 06:54:48,291;INFO ; 100,0.00022845443658912114,0.00856798770939696
2023-04-05 06:54:48,302;INFO ; 101,0.00027987997761208516,0.013388368752544035
2023-04-05 06:54:48,310;INFO ; 102,0.00026899490326368026,0.018067060886959363
2023-04-05 06:54:48,319;INFO ; 103,0.0002868876925050813,0.018862958398550893
2023-04-05 06:54:48,329;INFO ; 104,0.0003189034610338845,0.02571621848772325
2023-04-05 06:54:48,346;INFO ; 105,0.0002561888836164777,0.012849264658057706
2023-04-05 06:54:48,357;INFO ; 106,0.00018242802734066033,0.004424629504213847
2023-04-05 06:54:48,367;INFO ; 107,0.00014009171362419677,0.0068914822832576855
2023-04-05 06:54:48,376;INFO ; 108,0.0001329601854748482,0.0036752867447254994
2023-04-05 06:54:48,385;INFO ; 109,0.00012177837996945663,0.004422380735355617
2023-04-05 06:54:48,394;INFO ; 110,0.00010473425511358364,0.003619209787550745
2023-04-05 06:54:48,403;INFO ; 111,8.059838471628712e-05,0.0030093838505237565
2023-04-05 06:54:48,412;INFO ; 112,8.9607118492253e-05,0.0033877945877804384
2023-04-05 06:54:48,421;INFO ; 113,9.53226708008133e-05,0.0035124677489698397
2023-04-05 06:54:48,434;INFO ; 114,8.659293543034537e-05,0.0033478120571323474
2023-04-05 06:54:48,443;INFO ; 115,7.765137837125525e-05,0.0073096935201439495
2023-04-05 06:54:48,452;INFO ; 116,9.886002932817856e-05,0.008179339790050857
2023-04-05 06:54:48,462;INFO ; 117,9.84609442979147e-05,0.008703828174898622
2023-04-05 06:54:48,472;INFO ; 118,9.059281897497132e-05,0.005467725088599754
2023-04-05 06:54:48,481;INFO ; 119,8.796143433183202e-05,0.007169951162769291
2023-04-05 06:54:48,489;INFO ; 120,5.741242314968341e-05,0.0038232487351439167
2023-04-05 06:54:48,498;INFO ; 121,5.600385430978101e-05,0.0021513567871367383
2023-04-05 06:54:48,509;INFO ; 122,4.1046325512186676e-05,0.0015380055116519006
2023-04-05 06:54:48,518;INFO ; 123,3.640702184293077e-05,0.0019266846731897966
2023-04-05 06:54:48,529;INFO ; 124,5.4152897753778556e-05,0.0022629912655249785
2023-04-05 06:54:48,539;INFO ; 125,4.7628148043519886e-05,0.0032639321440660787
2023-04-05 06:54:48,550;INFO ; 126,4.940045247183765e-05,0.0021994853307939224
2023-04-05 06:54:48,561;INFO ; 127,4.182911357844356e-05,0.002309381489871109
2023-04-05 06:54:48,571;INFO ; 128,4.1350571465090156e-05,0.0023321413769791504
2023-04-05 06:54:48,582;INFO ; 129,3.48340760942594e-05,0.001621365720861427
2023-04-05 06:54:48,591;INFO ; 130,3.331501753811114e-05,0.002253393772904568
2023-04-05 06:54:48,607;INFO ; 131,3.7179630698802e-05,0.0033649732986622866
2023-04-05 06:54:48,618;INFO ; 132,5.153442889877174e-05,0.006362296930424516
2023-04-05 06:54:48,627;INFO ; 133,5.861870334244416e-05,0.0076611211186563425
2023-04-05 06:54:48,637;INFO ; 134,4.907222843414398e-05,0.003942145343720356
2023-04-05 06:54:48,646;INFO ; 135,4.554641035676136e-05,0.008696237553322238
2023-04-05 06:54:48,658;INFO ; 136,5.233936204809769e-05,0.00504443238640532
2023-04-05 06:54:48,668;INFO ; 137,6.004267653569572e-05,0.01159648141461553
2023-04-05 06:54:48,678;INFO ; 138,6.556426880465818e-05,0.006621079737350632
2023-04-05 06:54:48,690;INFO ; 139,6.312633413920978e-05,0.008051078321152635
2023-04-05 06:54:48,700;INFO ; 140,7.031390983287744e-05,0.011012194320041734
2023-04-05 06:54:48,716;INFO ; 141,7.028993335873414e-05,0.008744099663731563
2023-04-05 06:54:48,726;INFO ; 142,5.019736023348584e-05,0.008002284092063723
2023-04-05 06:54:48,736;INFO ; 143,5.907105111958936e-05,0.008906650274123077
2023-04-05 06:54:48,748;INFO ; 144,5.246138659916837e-05,0.006207265098822943
2023-04-05 06:54:48,757;INFO ; 145,4.604598449364376e-05,0.005357094881629162
2023-04-05 06:54:48,766;INFO ; 146,4.5818449838524944e-05,0.005804163969382528
2023-04-05 06:54:48,776;INFO ; 147,5.577699995191407e-05,0.004251971835538822
2023-04-05 06:54:48,788;INFO ; 148,4.8756333879753996e-05,0.005702508708584687
2023-04-05 06:54:48,797;INFO ; 149,3.4898164356958365e-05,0.002671518295821302
2023-04-05 06:54:48,807;INFO ; 150,3.4589709016405805e-05,0.003154097748015793
2023-04-05 06:54:48,817;INFO ; 151,3.3024167420830306e-05,0.004362980567312542
2023-04-05 06:54:48,826;INFO ; 152,3.7996990561398857e-05,0.005237217813064919
2023-04-05 06:54:48,835;INFO ; 153,3.3365028335748e-05,0.005443106180906196
2023-04-05 06:54:48,845;INFO ; 154,3.326706866623834e-05,0.0031056329031398902
2023-04-05 06:54:48,854;INFO ; 155,2.8325084325459634e-05,0.001461293939787732
2023-04-05 06:54:48,862;INFO ; 156,2.525983009927758e-05,0.0023447353072962307
2023-04-05 06:54:48,872;INFO ; 157,1.907690667907841e-05,0.0023849541551121947
2023-04-05 06:54:48,881;INFO ; 158,1.6690798485183553e-05,0.002024096070509824
2023-04-05 06:54:48,890;INFO ; 159,1.607009853348881e-05,0.0013638615686173293
2023-04-05 06:54:48,900;INFO ; 160,1.6748328021592107e-05,0.0018933653264892457
2023-04-05 06:54:48,912;INFO ; 161,1.536509502274411e-05,0.0013551356540993363
2023-04-05 06:54:48,920;INFO ; 162,1.5857365916458704e-05,0.0019273559100879648
2023-04-05 06:54:48,929;INFO ; 163,1.688920412613101e-05,0.0030753705141447376
2023-04-05 06:54:48,938;INFO ; 164,1.836989733476132e-05,0.0033795118963539767
2023-04-05 06:54:48,947;INFO ; 165,2.2291160698024532e-05,0.004429680006217231
2023-04-05 06:54:48,955;INFO ; 166,2.306511646500421e-05,0.0037126899424229512
2023-04-05 06:54:48,963;INFO ; 167,2.075375219205807e-05,0.004311325161182995
2023-04-05 06:54:48,973;INFO ; 168,2.0797520938126503e-05,0.003775980498160332
2023-04-05 06:54:48,982;INFO ; 169,2.6108898925457737e-05,0.006652648229452015
2023-04-05 06:54:48,990;INFO ; 170,2.306602578608781e-05,0.004868636002211045
2023-04-05 06:54:49,002;INFO ; 171,2.754345950923749e-05,0.004488711930837667
2023-04-05 06:54:49,010;INFO ; 172,2.0508702383066277e-05,0.002647336874825922
2023-04-05 06:54:49,021;INFO ; 173,1.7160239975866674e-05,0.0009822262909293437
2023-04-05 06:54:49,029;INFO ; 174,1.784584303046666e-05,0.0009052502003167941
2023-04-05 06:54:49,038;INFO ; 175,1.8528326499343535e-05,0.001221649236385264
2023-04-05 06:54:49,047;INFO ; 176,1.5236494153413046e-05,0.002152489072215227
2023-04-05 06:54:49,055;INFO ; 177,2.1813016065463764e-05,0.00340781344351089
2023-04-05 06:54:49,066;INFO ; 178,1.917805221403429e-05,0.0016288373103037742
2023-04-05 06:54:49,075;INFO ; 179,1.4988380241914947e-05,0.0011619260581690219
2023-04-05 06:54:49,084;INFO ; 180,1.4015606446555187e-05,0.0008646770481016388
2023-04-05 06:54:49,092;INFO ; 181,1.4846530202556331e-05,0.0017407775887631554
2023-04-05 06:54:49,102;INFO ; 182,1.257127096245084e-05,0.0009691274881466328
2023-04-05 06:54:49,111;INFO ; 183,1.726922499554211e-05,0.0021475687021785396
2023-04-05 06:54:49,121;INFO ; 184,1.5093584467669208e-05,0.002666281927808956
2023-04-05 06:54:49,130;INFO ; 185,1.96337842597903e-05,0.005989562483878685
2023-04-05 06:54:49,138;INFO ; 186,2.3960717525866445e-05,0.007190523663921945
2023-04-05 06:54:49,147;INFO ; 187,2.289030405809464e-05,0.003937946478221816
2023-04-05 06:54:49,155;INFO ; 188,2.2370176983854636e-05,0.005228361096079946
2023-04-05 06:54:49,164;INFO ; 189,2.628797991837572e-05,0.005641915576106362
2023-04-05 06:54:49,173;INFO ; 190,3.0411997873014292e-05,0.005568941882890748
2023-04-05 06:54:49,183;INFO ; 191,2.6887645260643313e-05,0.006487176586801191
2023-04-05 06:54:49,192;INFO ; 192,2.567199493569994e-05,0.0062554616366958015
2023-04-05 06:54:49,202;INFO ; 193,1.9601626450079366e-05,0.00397292265098252
2023-04-05 06:54:49,212;INFO ; 194,2.129169969166994e-05,0.00581740639498822
2023-04-05 06:54:49,229;INFO ; 195,2.5621057623392316e-05,0.005711738327671853
2023-04-05 06:54:49,238;INFO ; 196,2.159143537739626e-05,0.005563784852835593
2023-04-05 06:54:49,246;INFO ; 197,1.7328405310819284e-05,0.0036706733293779843
2023-04-05 06:54:49,255;INFO ; 198,2.8188571523706824e-05,0.01322186432024248
2023-04-05 06:54:49,264;INFO ; 199,3.593762886324639e-05,0.015648942349789984
2023-04-05 06:54:49,272;INFO ; 200,3.7221788857453604e-05,0.010166731905211373
2023-04-05 06:54:49,281;INFO ; 201,3.416861397344753e-05,0.013637794999729285
2023-04-05 06:54:49,289;INFO ; 202,3.7856057520590665e-05,0.005962290632823042
2023-04-05 06:54:49,298;INFO ; 203,2.7358055035894463e-05,0.008897904102751026
2023-04-05 06:54:49,307;INFO ; 204,2.5054909099866165e-05,0.0043124575452179745
2023-04-05 06:54:49,315;INFO ; 205,2.694264988549303e-05,0.008099916492309874
2023-04-05 06:54:49,324;INFO ; 206,2.588928632238849e-05,0.00702863865668131
2023-04-05 06:54:49,335;INFO ; 207,3.471536906575801e-05,0.007740070016951646
2023-04-05 06:54:49,344;INFO ; 208,3.753866081780742e-05,0.01210971469161366
2023-04-05 06:54:49,356;INFO ; 209,3.504336328139312e-05,0.008304468072660678
2023-04-05 06:54:49,365;INFO ; 210,3.0327352990913652e-05,0.010929484025290915
2023-04-05 06:54:49,375;INFO ; 211,3.330344070030632e-05,0.00688688337921208
2023-04-05 06:54:49,384;INFO ; 212,2.8034552695762525e-05,0.011647526665490737
2023-04-05 06:54:49,393;INFO ; 213,3.4259362046979295e-05,0.008607357040415702
2023-04-05 06:54:49,401;INFO ; 214,2.5855693786391353e-05,0.008108091480895576
2023-04-05 06:54:49,410;INFO ; 215,1.9454039392017463e-05,0.005691128422050421
2023-04-05 06:54:49,421;INFO ; 216,2.00766686541283e-05,0.008010345323870186
2023-04-05 06:54:49,430;INFO ; 217,3.388450748299725e-05,0.00933424139668618
2023-04-05 06:54:49,440;INFO ; 218,2.356944602714713e-05,0.00748112593031195
2023-04-05 06:54:49,449;INFO ; 219,2.1798332478399687e-05,0.0038346496072280685
2023-04-05 06:54:49,458;INFO ; 220,1.807628241281777e-05,0.006450389453380082
2023-04-05 06:54:49,468;INFO ; 221,2.254700095826184e-05,0.004614688455289334
2023-04-05 06:54:49,477;INFO ; 222,2.5194793773182173e-05,0.005965181635863786
2023-04-05 06:54:49,487;INFO ; 223,2.5902188185234882e-05,0.0044429183206707214
2023-04-05 06:54:49,495;INFO ; 224,2.6609005185632094e-05,0.0039830151983514354
2023-04-05 06:54:49,505;INFO ; 225,2.6009139429150125e-05,0.004689514103345383
2023-04-05 06:54:49,513;INFO ; 226,2.3695627483432556e-05,0.005517221713802217
2023-04-05 06:54:49,523;INFO ; 227,2.2713815962403185e-05,0.010856007805335221
2023-04-05 06:54:49,531;INFO ; 228,3.0953749423543615e-05,0.009781328355284715
2023-04-05 06:54:49,540;INFO ; 229,2.43300826133376e-05,0.005476536551199691
2023-04-05 06:54:49,553;INFO ; 230,2.412796862853625e-05,0.00482004866306197
2023-04-05 06:54:49,561;INFO ; 231,2.4806089893145824e-05,0.006099003990776419
2023-04-05 06:54:49,571;INFO ; 232,2.6372895227550095e-05,0.004437492287876559
2023-04-05 06:54:49,581;INFO ; 233,2.2882996056684834e-05,0.0031862059038002427
2023-04-05 06:54:49,590;INFO ; 234,1.4967523779344496e-05,0.0008442574015387043
2023-04-05 06:54:49,599;INFO ; 235,1.462053658338255e-05,0.0007242385079277675
2023-04-05 06:54:49,610;INFO ; 236,1.2048418271997432e-05,0.00035381888368992873
2023-04-05 06:54:49,620;INFO ; 237,1.3600281644121943e-05,0.000614305015888942
2023-04-05 06:54:49,631;INFO ; 238,1.1562418394501947e-05,0.0006553454707637627
2023-04-05 06:54:49,641;INFO ; 239,1.309117029984416e-05,0.0008793653233140667
2023-04-05 06:54:49,649;INFO ; 240,1.1731926130608215e-05,0.0005714348291573189
2023-04-05 06:54:49,658;INFO ; 241,9.003602259311368e-06,0.0005383168548790307
2023-04-05 06:54:49,658;INFO ; bfw Assignment finished. 241 iterations and 9.003602259311368e-06 final gap

Now let us save our select link results, all we need to do is provide it with a name In additional 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")
2023-04-05 06:54:49,755;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()
plot forecasting

Close the project

project.close()

Total running time of the script: ( 0 minutes 5.649 seconds)

Gallery generated by Sphinx-Gallery