.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_auto_examples/plot_forecasting.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr__auto_examples_plot_forecasting.py: Forecasting ============ On this example we present a full forecasting workflow for the Sioux Falls example model. .. GENERATED FROM PYTHON SOURCE LINES 8-17 .. code-block:: python ## 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 .. GENERATED FROM PYTHON SOURCE LINES 18-19 We create the example project inside our temp folder .. GENERATED FROM PYTHON SOURCE LINES 19-30 .. code-block:: python fldr = join(gettempdir(), uuid4().hex) project = create_example(fldr) logger = project.logger # 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;%(levelname)s ; %(message)s") stdout_handler.setFormatter(formatter) logger.addHandler(stdout_handler) .. GENERATED FROM PYTHON SOURCE LINES 31-34 .. code-block:: python ## Traffic assignment with skimming .. GENERATED FROM PYTHON SOURCE LINES 35-38 .. code-block:: python from aequilibrae.paths import TrafficAssignment, TrafficClass .. GENERATED FROM PYTHON SOURCE LINES 39-44 .. code-block:: python # 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 .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:354: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "id"] = np.arange(df.shape[0]) 2022-11-29 07:35:45,471;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:371: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "direction"] = df.direction.values.astype(np.int8) /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:354: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "id"] = np.arange(df.shape[0]) /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:371: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "direction"] = df.direction.values.astype(np.int8) /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:354: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "id"] = np.arange(df.shape[0]) 2022-11-29 07:35:45,508;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:371: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "direction"] = df.direction.values.astype(np.int8) /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:354: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "id"] = np.arange(df.shape[0]) /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:371: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "direction"] = df.direction.values.astype(np.int8) /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:354: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "id"] = np.arange(df.shape[0]) 2022-11-29 07:35:45,544;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:371: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "direction"] = df.direction.values.astype(np.int8) /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:354: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "id"] = np.arange(df.shape[0]) 2022-11-29 07:35:45,581;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:371: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "direction"] = df.direction.values.astype(np.int8) /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:354: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "id"] = np.arange(df.shape[0]) /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:371: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "direction"] = df.direction.values.astype(np.int8) /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:354: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "id"] = np.arange(df.shape[0]) 2022-11-29 07:35:45,617;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:371: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "direction"] = df.direction.values.astype(np.int8) /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:354: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "id"] = np.arange(df.shape[0]) 2022-11-29 07:35:45,654;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:371: FutureWarning: In a future version, `df.iloc[:, i] = newvals` will attempt to set the values inplace instead of always setting a new array. To retain the old behavior, use either `df[df.columns[i]] = newvals` or, if columns are non-unique, `df.isetitem(i, newvals)` df.loc[:, "direction"] = df.direction.values.astype(np.int8) .. GENERATED FROM PYTHON SOURCE LINES 45-59 .. code-block:: python # 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) .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:445: FutureWarning: The default value of numeric_only in DataFrameGroupBy.sum is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function. df = self.__graph_groupby.sum()[[cost_field]].reset_index() 2022-11-29 07:35:45,682;WARNING ; Cost field with wrong type. Converting to float64 /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:479: FutureWarning: The default value of numeric_only in DataFrameGroupBy.sum is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function. df = self.__graph_groupby.sum()[skim_fields].reset_index() .. GENERATED FROM PYTHON SOURCE LINES 60-66 .. code-block:: python # 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() .. raw:: html
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


.. GENERATED FROM PYTHON SOURCE LINES 67-72 .. code-block:: python # Let's get it in this better way demand = proj_matrices.get_matrix("demand_omx") demand.computational_view(["matrix"]) .. GENERATED FROM PYTHON SOURCE LINES 73-99 .. code-block:: python 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 .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:445: FutureWarning: The default value of numeric_only in DataFrameGroupBy.sum is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function. df = self.__graph_groupby.sum()[[cost_field]].reset_index() 2022-11-29 07:35:46,005;WARNING ; Cost field with wrong type. Converting to float64 2022-11-29 07:35:46,005;INFO ; bfw Assignment STATS 2022-11-29 07:35:46,005;INFO ; Iteration, RelativeGap, stepsize 2022-11-29 07:35:46,010;INFO ; 1,inf,1.0 2022-11-29 07:35:46,020;INFO ; 2,0.8485503636986156,0.3649733931991619 2022-11-29 07:35:46,031;INFO ; 3,0.38139263975960314,0.22983569243524993 2022-11-29 07:35:46,040;INFO ; 4,0.19621280093105328,0.18591303407405754 2022-11-29 07:35:46,050;INFO ; 5,0.09069069564886302,0.709081525570193 2022-11-29 07:35:46,060;INFO ; 6,0.20600049841796414,0.12290139708465252 2022-11-29 07:35:46,069;INFO ; 7,0.0671057020569446,0.3863865464644097 2022-11-29 07:35:46,080;INFO ; 8,0.10307514522959232,0.10930550628245674 2022-11-29 07:35:46,090;INFO ; 9,0.042221488560558955,0.24878058909094228 2022-11-29 07:35:46,099;INFO ; 10,0.05926436280283587,0.15904812211073494 2022-11-29 07:35:46,107;INFO ; 11,0.034539501887818985,0.5180973982981508 2022-11-29 07:35:46,111;INFO ; 12,0.059426522740212366,0.101971242325629 2022-11-29 07:35:46,115;INFO ; 13,0.023239892828420625,0.1780595247621586 2022-11-29 07:35:46,119;INFO ; 14,0.01787378174233466,0.9787872892076548 2022-11-29 07:35:46,122;INFO ; 15,0.04966137112489825,0.08320656230754342 2022-11-29 07:35:46,126;INFO ; 16,0.021382882927382725,0.11517403372477297 2022-11-29 07:35:46,130;INFO ; 17,0.01314154305058098,0.1064036961470442 2022-11-29 07:35:46,133;INFO ; 18,0.009902228306191804,0.10710395852809111 2022-11-29 07:35:46,137;INFO ; 19,0.008834657124558089,0.252467895277828 2022-11-29 07:35:46,141;INFO ; 20,0.010371041656588888,0.6727839455896467 2022-11-29 07:35:46,145;INFO ; 21,0.011090096024277666,0.07468062458005388 2022-11-29 07:35:46,148;INFO ; 22,0.006512685864200749,0.12485018976276105 2022-11-29 07:35:46,152;INFO ; 23,0.00523888532832478,0.06316016036308214 2022-11-29 07:35:46,155;INFO ; 24,0.003949527733957799,0.09717892036982514 2022-11-29 07:35:46,159;INFO ; 25,0.003282221717998643,0.15775902884958926 2022-11-29 07:35:46,163;INFO ; 26,0.0057928324189390375,0.4524765555189632 2022-11-29 07:35:46,167;INFO ; 27,0.006682358714677215,0.7851865434128832 2022-11-29 07:35:46,170;INFO ; 28,0.00599261954468699,0.039098102583274626 2022-11-29 07:35:46,174;INFO ; 29,0.004031364721003652,0.04253017715977122 2022-11-29 07:35:46,178;INFO ; 30,0.00276965205224939,0.02251286694569934 2022-11-29 07:35:46,182;INFO ; 31,0.002484645375580033,0.045801689794576335 2022-11-29 07:35:46,185;INFO ; 32,0.0016385526291291498,0.034295834113305265 2022-11-29 07:35:46,189;INFO ; 33,0.0014956909894299761,0.035391999643557624 2022-11-29 07:35:46,193;INFO ; 34,0.0011355396506463338,0.053589857140533936 2022-11-29 07:35:46,197;INFO ; 35,0.0012151969842906466,0.04757129085244828 2022-11-29 07:35:46,200;INFO ; 36,0.0012393652042090905,0.06536474008117803 2022-11-29 07:35:46,204;INFO ; 37,0.0010684964499824193,0.1070395355360692 2022-11-29 07:35:46,208;INFO ; 38,0.0010899690746481111,0.09864062890245766 2022-11-29 07:35:46,211;INFO ; 39,0.0009886949061956609,0.06027624172548778 2022-11-29 07:35:46,212;INFO ; bfw Assignment finished. 39 iterations and 0.0009886949061956609 final gap .. GENERATED FROM PYTHON SOURCE LINES 100-107 .. code-block:: python # Convergence report is easy to see import pandas as pd convergence_report = assig.report() convergence_report.head() .. raw:: html
iteration rgap alpha warnings beta0 beta1 beta2
0 1 inf 1.000000 1.000000 0.000000 0.000000
1 2 0.848550 0.364973 1.000000 0.000000 0.000000
2 3 0.381393 0.229836 1.000000 0.000000 0.000000
3 4 0.196213 0.185913 0.959771 0.040229 0.000000
4 5 0.090691 0.709082 0.687640 0.286705 0.025655


.. GENERATED FROM PYTHON SOURCE LINES 108-112 .. code-block:: python volumes = assig.results() volumes.head() .. raw:: html
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 4535.923098 NaN 4535.923098 6.000847 NaN 6.000847 1.000141 NaN 1.000141 0.175131 NaN 0.175131 4535.923098 NaN 4535.923098
2 8186.151917 NaN 8186.151917 4.008982 NaN 4.008982 1.002245 NaN 1.002245 0.349784 NaN 0.349784 8186.151917 NaN 8186.151917
3 4586.028377 NaN 4586.028377 6.000885 NaN 6.000885 1.000147 NaN 1.000147 0.177065 NaN 0.177065 4586.028377 NaN 4586.028377
4 6024.212847 NaN 6024.212847 6.634455 NaN 6.634455 1.326891 NaN 1.326891 1.215005 NaN 1.215005 6024.212847 NaN 6024.212847
5 8136.046638 NaN 8136.046638 4.008764 NaN 4.008764 1.002191 NaN 1.002191 0.347643 NaN 0.347643 8136.046638 NaN 8136.046638


.. GENERATED FROM PYTHON SOURCE LINES 113-117 .. code-block:: python # 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") .. GENERATED FROM PYTHON SOURCE LINES 118-122 .. code-block:: python # And save the skims assig.save_skims("base_year_assignment_skims", which_ones="all", format="omx") .. rst-class:: sphx-glr-script-out .. code-block:: none 2022-11-29 07:35:46,346;WARNING ; Matrix Record has been saved to the database .. GENERATED FROM PYTHON SOURCE LINES 123-126 .. code-block:: python ## Trip distribution .. GENERATED FROM PYTHON SOURCE LINES 127-131 .. code-block:: python ### Calibration # We will calibrate synthetic gravity models using the skims for TIME that we just generated .. GENERATED FROM PYTHON SOURCE LINES 132-136 .. code-block:: python import numpy as np from aequilibrae.distribution import GravityCalibration .. GENERATED FROM PYTHON SOURCE LINES 137-141 .. code-block:: python # Let's take another look at what we have in terms of matrices in the model proj_matrices.list() .. raw:: html
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 4f7f7b9dfd6e4be1a40e682aaa23133e 2022-11-29 07:35:45.734650 Skimming for assignment procedure. Class car


.. GENERATED FROM PYTHON SOURCE LINES 142-149 .. code-block:: python # We need the demand demand = proj_matrices.get_matrix("demand_aem") # And the skims imped = proj_matrices.get_matrix("base_year_assignment_skims_car") .. GENERATED FROM PYTHON SOURCE LINES 150-156 .. code-block:: python # 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 .. rst-class:: sphx-glr-script-out .. code-block:: none ['distance_blended', 'distance_final', 'free_flow_time_blended', 'free_flow_time_final'] .. GENERATED FROM PYTHON SOURCE LINES 157-174 .. code-block:: python # 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) .. GENERATED FROM PYTHON SOURCE LINES 175-180 .. code-block:: python # 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"]) .. GENERATED FROM PYTHON SOURCE LINES 181-186 .. code-block:: python # This also updates these new matrices as those being used for computation # As one can verify below imped.view_names .. rst-class:: sphx-glr-script-out .. code-block:: none ['final_time_with_intrazonals'] .. GENERATED FROM PYTHON SOURCE LINES 187-191 .. code-block:: python # We set the matrices for being used in computation demand.computational_view(["matrix"]) .. GENERATED FROM PYTHON SOURCE LINES 192-206 .. code-block:: python 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") .. GENERATED FROM PYTHON SOURCE LINES 207-212 .. code-block:: python ## 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 .. GENERATED FROM PYTHON SOURCE LINES 213-218 .. code-block:: python from aequilibrae.distribution import Ipf, GravityApplication, SyntheticGravityModel from aequilibrae.matrix import AequilibraeData import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 219-242 .. code-block:: python # 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() .. GENERATED FROM PYTHON SOURCE LINES 243-251 .. code-block:: python # 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) .. GENERATED FROM PYTHON SOURCE LINES 252-275 .. code-block:: python 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") .. rst-class:: sphx-glr-script-out .. code-block:: none 2022-11-29 07:35:47,329;WARNING ; Matrix Record has been saved to the database 2022-11-29 07:35:47,552;WARNING ; Matrix Record has been saved to the database .. GENERATED FROM PYTHON SOURCE LINES 276-281 .. code-block:: python # We update the matrices table/records and verify that the new matrices are indeed there proj_matrices.update_database() proj_matrices.list() .. raw:: html
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 4f7f7b9dfd6e4be1a40e682aaa23133e 2022-11-29 07:35:45.734650 Skimming for assignment procedure. Class car
5 demand_power_modeled demand_power_modeled.omx 1 Synthetic gravity trip distribution a380f3af4784418d96b5bffd608327ca 2022-11-29 07:35:47.176054 Synthetic gravity trip distribution. POWER
6 demand_expo_modeled demand_expo_modeled.omx 1 Synthetic gravity trip distribution abbb9e5800b64d3eb058d8cc5b51d50c 2022-11-29 07:35:47.459832 Synthetic gravity trip distribution. EXPO


.. GENERATED FROM PYTHON SOURCE LINES 282-285 .. code-block:: python ### We now run IPF for the future vectors .. GENERATED FROM PYTHON SOURCE LINES 286-301 .. code-block:: python 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") .. rst-class:: sphx-glr-script-out .. code-block:: none 2022-11-29 07:35:47,696;WARNING ; Matrix Record has been saved to the database 2022-11-29 07:35:47,793;WARNING ; Matrix Record has been saved to the database .. GENERATED FROM PYTHON SOURCE LINES 302-305 .. code-block:: python proj_matrices.list() .. raw:: html
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 4f7f7b9dfd6e4be1a40e682aaa23133e 2022-11-29 07:35:45.734650 Skimming for assignment procedure. Class car
5 demand_power_modeled demand_power_modeled.omx 1 Synthetic gravity trip distribution a380f3af4784418d96b5bffd608327ca 2022-11-29 07:35:47.176054 Synthetic gravity trip distribution. POWER
6 demand_expo_modeled demand_expo_modeled.omx 1 Synthetic gravity trip distribution abbb9e5800b64d3eb058d8cc5b51d50c 2022-11-29 07:35:47.459832 Synthetic gravity trip distribution. EXPO
7 demand_ipfd demand_ipfd.aem 1 Iterative Proportional fitting 34e3a964ad494af4bed79ed61b2507e1 2022-11-29 07:35:47.646432 None
8 demand_ipfd_omx demand_ipfd.omx 1 Iterative Proportional fitting 34e3a964ad494af4bed79ed61b2507e1 2022-11-29 07:35:47.646432 None


.. GENERATED FROM PYTHON SOURCE LINES 306-309 .. code-block:: python ## Future traffic assignment .. GENERATED FROM PYTHON SOURCE LINES 310-313 .. code-block:: python from aequilibrae.paths import TrafficAssignment, TrafficClass .. GENERATED FROM PYTHON SOURCE LINES 314-317 .. code-block:: python logger.info("\n\n\n TRAFFIC ASSIGNMENT FOR FUTURE YEAR") .. rst-class:: sphx-glr-script-out .. code-block:: none 2022-11-29 07:35:47,845;INFO ; TRAFFIC ASSIGNMENT FOR FUTURE YEAR .. GENERATED FROM PYTHON SOURCE LINES 318-324 .. code-block:: python demand = proj_matrices.get_matrix("demand_ipfd") # let's see what is the core we ended up getting. It should be 'gravity' demand.names .. rst-class:: sphx-glr-script-out .. code-block:: none ['matrix'] .. GENERATED FROM PYTHON SOURCE LINES 325-353 .. code-block:: python # 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 .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:445: FutureWarning: The default value of numeric_only in DataFrameGroupBy.sum is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function. df = self.__graph_groupby.sum()[[cost_field]].reset_index() 2022-11-29 07:35:48,161;WARNING ; Cost field with wrong type. Converting to float64 2022-11-29 07:35:48,162;INFO ; bfw Assignment STATS 2022-11-29 07:35:48,162;INFO ; Iteration, RelativeGap, stepsize 2022-11-29 07:35:48,169;INFO ; 1,inf,1.0 2022-11-29 07:35:48,180;INFO ; 2,0.8776038327947165,0.35194194800596224 2022-11-29 07:35:48,191;INFO ; 3,0.46258967612026347,0.18972760815724118 2022-11-29 07:35:48,199;INFO ; 4,0.24563915271016676,0.23462556986441843 2022-11-29 07:35:48,203;INFO ; 5,0.07289711677703088,0.9851363677496002 2022-11-29 07:35:48,208;INFO ; 6,0.2534950603426386,0.11811117417714245 2022-11-29 07:35:48,212;INFO ; 7,0.09786144704234179,0.14643197813926917 2022-11-29 07:35:48,216;INFO ; 8,0.04756352710660187,0.42838466394167934 2022-11-29 07:35:48,221;INFO ; 9,0.08360515652320759,0.10672419692532684 2022-11-29 07:35:48,224;INFO ; 10,0.028714574626005827,0.29611597755836144 2022-11-29 07:35:48,229;INFO ; 11,0.047169282097376315,0.9445534912617084 2022-11-29 07:35:48,233;INFO ; 12,0.07293746683610607,0.06518504262071433 2022-11-29 07:35:48,238;INFO ; 13,0.033350974561621546,0.08606333307299353 2022-11-29 07:35:48,242;INFO ; 14,0.020472338291126758,0.09817479898385979 2022-11-29 07:35:48,246;INFO ; 15,0.016253620188103963,0.13747824365693542 2022-11-29 07:35:48,251;INFO ; 16,0.015983432439245097,0.253858540863254 2022-11-29 07:35:48,255;INFO ; 17,0.015287099940930707,0.7327183354579772 2022-11-29 07:35:48,259;INFO ; 18,0.021645702405791327,0.0678687597580838 2022-11-29 07:35:48,264;INFO ; 19,0.012061826297201013,0.10020780999029054 2022-11-29 07:35:48,268;INFO ; 20,0.008460632935520858,0.09647217096919938 2022-11-29 07:35:48,272;INFO ; 21,0.010503373661221196,0.17833268414392842 2022-11-29 07:35:48,276;INFO ; 22,0.009940859217509026,0.246577113423649 2022-11-29 07:35:48,280;INFO ; 23,0.010297981112715848,0.6113648318204116 2022-11-29 07:35:48,284;INFO ; 24,0.00863823438083522,0.07874198226093891 2022-11-29 07:35:48,288;INFO ; 25,0.005240151241876607,0.03775729054234277 2022-11-29 07:35:48,292;INFO ; 26,0.003584860491281443,0.0711062143592039 2022-11-29 07:35:48,297;INFO ; 27,0.004019512572529646,0.11914416600173444 2022-11-29 07:35:48,301;INFO ; 28,0.004720935742142012,0.18035435139686343 2022-11-29 07:35:48,305;INFO ; 29,0.004583165222770935,0.29552829121812824 2022-11-29 07:35:48,309;INFO ; 30,0.0053674464252209,0.4939298053088995 2022-11-29 07:35:48,313;INFO ; 31,0.00557952084406729,0.7758423751739414 2022-11-29 07:35:48,317;INFO ; 32,0.006231460357159165,0.03289051663603803 2022-11-29 07:35:48,321;INFO ; 33,0.003300458686227179,0.035453424862890714 2022-11-29 07:35:48,325;INFO ; 34,0.0027799324897358696,0.05301054302592312 2022-11-29 07:35:48,330;INFO ; 35,0.004288188673638686,0.1242022629088111 2022-11-29 07:35:48,334;INFO ; 36,0.003433679398962094,0.18816133147740424 2022-11-29 07:35:48,338;INFO ; 37,0.003058272024156026,0.1535283724573769 2022-11-29 07:35:48,342;INFO ; 38,0.002589238831732664,0.17385645709400538 2022-11-29 07:35:48,346;INFO ; 39,0.0024613156544232057,0.21801192928100538 2022-11-29 07:35:48,351;INFO ; 40,0.0019219172856690691,0.2023089367400616 2022-11-29 07:35:48,360;INFO ; 41,0.0022959044191565485,0.5839046325399527 2022-11-29 07:35:48,364;INFO ; 42,0.0024995027368325796,0.9576107123639371 2022-11-29 07:35:48,368;INFO ; 43,0.002275332542700287,0.011247460567582246 2022-11-29 07:35:48,372;INFO ; 44,0.0013448027602777832,0.019751769861976184 2022-11-29 07:35:48,376;INFO ; 45,0.001359985013529228,0.039924537521524306 2022-11-29 07:35:48,380;INFO ; 46,0.0011648797407220364,0.041967674435139934 2022-11-29 07:35:48,384;INFO ; 47,0.0010939230665336264,0.05107267454988136 2022-11-29 07:35:48,388;INFO ; 48,0.001067754585098223,0.08932200635415237 2022-11-29 07:35:48,393;INFO ; 49,0.0010292927919723289,0.08477153084277053 2022-11-29 07:35:48,397;INFO ; 50,0.0009904668769673572,0.084435874374612 2022-11-29 07:35:48,401;INFO ; 51,0.0008746195106887933,0.05150245283632411 2022-11-29 07:35:48,405;INFO ; 52,0.0008480704121713653,0.04922268342008136 2022-11-29 07:35:48,409;INFO ; 53,0.0007721136133959812,0.05331652393504385 2022-11-29 07:35:48,417;INFO ; 54,0.0008553069741973425,0.07980020275648955 2022-11-29 07:35:48,427;INFO ; 55,0.0007276859594182507,0.12906250299287103 2022-11-29 07:35:48,438;INFO ; 56,0.0009138033989992133,0.18702824365855275 2022-11-29 07:35:48,448;INFO ; 57,0.0008823361173896108,0.12962633950098232 2022-11-29 07:35:48,458;INFO ; 58,0.0009428326602342531,0.20918923976571582 2022-11-29 07:35:48,468;INFO ; 59,0.0007206990225010789,0.3019238114918083 2022-11-29 07:35:48,472;INFO ; 60,0.0009924707332993137,0.6028993235085262 2022-11-29 07:35:48,482;INFO ; 61,0.000789434554676963,0.6557285418012307 2022-11-29 07:35:48,493;INFO ; 62,0.0009395442100285792,0.005467646156391774 2022-11-29 07:35:48,505;INFO ; 63,0.0007160912813084154,0.011757595712824047 2022-11-29 07:35:48,517;INFO ; 64,0.0006618628537000505,0.02020247770120896 2022-11-29 07:35:48,527;INFO ; 65,0.0007045404415201399,0.027078720583669127 2022-11-29 07:35:48,535;INFO ; 66,0.0005183446716617645,0.020415786369591633 2022-11-29 07:35:48,539;INFO ; 67,0.0006023408394383636,0.03019935564833873 2022-11-29 07:35:48,544;INFO ; 68,0.0006272435753628336,0.018244338743970214 2022-11-29 07:35:48,548;INFO ; 69,0.0006411882143816542,0.03278810827125554 2022-11-29 07:35:48,552;INFO ; 70,0.0005534708521347131,0.021945641720608068 2022-11-29 07:35:48,556;INFO ; 71,0.0004873658694529471,0.02249192092700199 2022-11-29 07:35:48,560;INFO ; 72,0.00039565793649800994,0.008182359238968403 2022-11-29 07:35:48,565;INFO ; 73,0.00032085775015311407,0.00807172064837359 2022-11-29 07:35:48,569;INFO ; 74,0.00024641986038898136,0.013621471401540025 2022-11-29 07:35:48,573;INFO ; 75,0.00026012133691338113,0.01064868458219174 2022-11-29 07:35:48,577;INFO ; 76,0.00023683662504139506,0.008124737925524575 2022-11-29 07:35:48,581;INFO ; 77,0.0002453416700624106,0.005859902021175667 2022-11-29 07:35:48,585;INFO ; 78,0.00017343014323460123,0.008917379284601911 2022-11-29 07:35:48,589;INFO ; 79,0.00019903717982824482,0.01560885458752535 2022-11-29 07:35:48,594;INFO ; 80,0.00019242567392314605,0.011542379401119733 2022-11-29 07:35:48,598;INFO ; 81,0.0001713866147538637,0.005900376182050248 2022-11-29 07:35:48,602;INFO ; 82,0.00015649240906291935,0.00666322176069894 2022-11-29 07:35:48,606;INFO ; 83,0.00012062926693792844,0.011598316013443632 2022-11-29 07:35:48,610;INFO ; 84,0.00016044812349446457,0.0060452220350742936 2022-11-29 07:35:48,617;INFO ; 85,0.00012903799866218957,0.009713197053435992 2022-11-29 07:35:48,621;INFO ; 86,0.00015486265853535596,0.010541890291283367 2022-11-29 07:35:48,625;INFO ; 87,0.00012362002871554417,0.007600235680948042 2022-11-29 07:35:48,630;INFO ; 88,0.0001640434228471744,0.015598336502141865 2022-11-29 07:35:48,634;INFO ; 89,0.00015378726457503534,0.012263339811168714 2022-11-29 07:35:48,638;INFO ; 90,0.00014010238454461907,0.006726686953864086 2022-11-29 07:35:48,647;INFO ; 91,0.00012719253615166656,0.01235282842506799 2022-11-29 07:35:48,657;INFO ; 92,0.00012242545045711977,0.009049305000954166 2022-11-29 07:35:48,668;INFO ; 93,0.00012848521822099494,0.00859083592134024 2022-11-29 07:35:48,680;INFO ; 94,0.00013451933336948324,0.006932784933944503 2022-11-29 07:35:48,691;INFO ; 95,0.00010889693825271467,0.01012252794220691 2022-11-29 07:35:48,699;INFO ; 96,0.00016048236655781775,0.018896373520703016 2022-11-29 07:35:48,704;INFO ; 97,0.0001296815412930233,0.029198441120118993 2022-11-29 07:35:48,708;INFO ; 98,0.00014433358803272566,0.011282638837988797 2022-11-29 07:35:48,712;INFO ; 99,0.0001031524356279424,0.010729220804896009 2022-11-29 07:35:48,716;INFO ; 100,0.0001422598467055488,0.019201282657683935 2022-11-29 07:35:48,720;INFO ; 101,0.00014243613529584112,0.029049557683735117 2022-11-29 07:35:48,725;INFO ; 102,0.00020784996340912182,0.05777842014766857 2022-11-29 07:35:48,729;INFO ; 103,0.0002757693156359683,0.14407324392888401 2022-11-29 07:35:48,733;INFO ; 104,0.00044458699389200035,0.20709650246664282 2022-11-29 07:35:48,737;INFO ; 105,0.00031851629415930236,0.16328447827212883 2022-11-29 07:35:48,742;INFO ; 106,0.0003181064517116748,0.5202884541460262 2022-11-29 07:35:48,746;INFO ; 107,0.0004556065136317193,0.0038914843883074727 2022-11-29 07:35:48,750;INFO ; 108,0.0002835871834126463,0.004087640764909962 2022-11-29 07:35:48,754;INFO ; 109,0.00029792737990242264,0.0045320111647514354 2022-11-29 07:35:48,759;INFO ; 110,0.00019903877943230438,0.00672288407622596 2022-11-29 07:35:48,763;INFO ; 111,0.0003024276690822406,0.00651606330602467 2022-11-29 07:35:48,767;INFO ; 112,0.00022731274372898939,0.0050031817788830715 2022-11-29 07:35:48,771;INFO ; 113,0.0001644602559321091,0.004215895768644252 2022-11-29 07:35:48,776;INFO ; 114,0.0001112078047127934,0.0013774455316302645 2022-11-29 07:35:48,780;INFO ; 115,0.00010332402879202421,0.0029071932973111815 2022-11-29 07:35:48,784;INFO ; 116,9.316569419590442e-05,0.002307737198104934 2022-11-29 07:35:48,789;INFO ; 117,7.634724039870011e-05,0.002024844972855024 2022-11-29 07:35:48,793;INFO ; 118,6.657310629065865e-05,0.002417305729260541 2022-11-29 07:35:48,797;INFO ; 119,6.506371884848914e-05,0.003729921695502827 2022-11-29 07:35:48,801;INFO ; 120,8.203510272733477e-05,0.003379802193619428 2022-11-29 07:35:48,805;INFO ; 121,6.898180585496858e-05,0.003606609097058515 2022-11-29 07:35:48,810;INFO ; 122,7.656761135574236e-05,0.007738653387266545 2022-11-29 07:35:48,814;INFO ; 123,9.943529623585701e-05,0.00678791307660858 2022-11-29 07:35:48,818;INFO ; 124,9.319734893457226e-05,0.005819799351805128 2022-11-29 07:35:48,822;INFO ; 125,8.916588662836365e-05,0.005228016209214343 2022-11-29 07:35:48,826;INFO ; 126,7.306585066194158e-05,0.006359744009738467 2022-11-29 07:35:48,831;INFO ; 127,0.00010385757388974851,0.011159394111624546 2022-11-29 07:35:48,835;INFO ; 128,8.05936736784518e-05,0.004771472133210507 2022-11-29 07:35:48,839;INFO ; 129,6.313851182388506e-05,0.002635236322476105 2022-11-29 07:35:48,843;INFO ; 130,5.6202010153868694e-05,0.0030179073796791516 2022-11-29 07:35:48,848;INFO ; 131,7.390136101437921e-05,0.007454688368877129 2022-11-29 07:35:48,852;INFO ; 132,5.9468603009545e-05,0.0021365839146009822 2022-11-29 07:35:48,856;INFO ; 133,5.52929805357748e-05,0.002196855161781862 2022-11-29 07:35:48,860;INFO ; 134,4.7780308700668604e-05,0.002096847857918493 2022-11-29 07:35:48,864;INFO ; 135,4.206933901679119e-05,0.002848811658417926 2022-11-29 07:35:48,868;INFO ; 136,5.625721258651054e-05,0.0046648448774161645 2022-11-29 07:35:48,872;INFO ; 137,5.320512911290679e-05,0.004567246239900218 2022-11-29 07:35:48,876;INFO ; 138,5.885812150721258e-05,0.004723475730022019 2022-11-29 07:35:48,880;INFO ; 139,4.258603688532726e-05,0.00469878781849139 2022-11-29 07:35:48,884;INFO ; 140,4.11809922868848e-05,0.001784712093096128 2022-11-29 07:35:48,889;INFO ; 141,2.966601747486545e-05,0.0018412274315540874 2022-11-29 07:35:48,893;INFO ; 142,3.4714596346865274e-05,0.0016398337842771051 2022-11-29 07:35:48,897;INFO ; 143,2.5353294239528754e-05,0.0007450587562479493 2022-11-29 07:35:48,901;INFO ; 144,2.039943087154869e-05,0.00026014344115989676 2022-11-29 07:35:48,905;INFO ; 145,1.994478346092747e-05,0.000724298856271267 2022-11-29 07:35:48,910;INFO ; 146,2.432116825352451e-05,0.0011389606493152427 2022-11-29 07:35:48,914;INFO ; 147,2.6007148675285818e-05,0.001133399367395307 2022-11-29 07:35:48,918;INFO ; 148,2.2052676368912567e-05,0.000877006244270951 2022-11-29 07:35:48,922;INFO ; 149,2.254951084511648e-05,0.0008194368339853549 2022-11-29 07:35:48,927;INFO ; 150,2.0287339517394753e-05,0.00187682800762765 2022-11-29 07:35:48,931;INFO ; 151,3.084708780104293e-05,0.0027981574484691758 2022-11-29 07:35:48,935;INFO ; 152,3.862103815228662e-05,0.004759943897566942 2022-11-29 07:35:48,939;INFO ; 153,4.4525156547539056e-05,0.005462807512163046 2022-11-29 07:35:48,943;INFO ; 154,3.788062330154353e-05,0.00443544486586971 2022-11-29 07:35:48,947;INFO ; 155,3.95777051306987e-05,0.004123223703249317 2022-11-29 07:35:48,951;INFO ; 156,3.495269226010886e-05,0.0042772832219027885 2022-11-29 07:35:48,955;INFO ; 157,3.1324734909741874e-05,0.004008660384606147 2022-11-29 07:35:48,960;INFO ; 158,3.398798957116159e-05,0.005816001778981821 2022-11-29 07:35:48,964;INFO ; 159,5.4360841228543735e-05,0.014525030228944 2022-11-29 07:35:48,968;INFO ; 160,4.785800380726318e-05,0.009336112309065597 2022-11-29 07:35:48,972;INFO ; 161,4.492219809380456e-05,0.010598819837264796 2022-11-29 07:35:48,977;INFO ; 162,5.7627044229195375e-05,0.029632981729059003 2022-11-29 07:35:48,981;INFO ; 163,8.120998132209187e-05,0.03841230444186879 2022-11-29 07:35:48,985;INFO ; 164,6.838827108190308e-05,0.025224029546498678 2022-11-29 07:35:48,989;INFO ; 165,6.410576872617294e-05,0.04079341149196225 2022-11-29 07:35:48,993;INFO ; 166,7.531469140452778e-05,0.03160048332314263 2022-11-29 07:35:48,997;INFO ; 167,9.454772262280899e-05,0.040379243475403385 2022-11-29 07:35:49,001;INFO ; 168,8.701404295462617e-05,0.03926131482529542 2022-11-29 07:35:49,005;INFO ; 169,9.833759771471985e-05,0.08174550592096679 2022-11-29 07:35:49,010;INFO ; 170,0.000101323285595152,0.08456975552741584 2022-11-29 07:35:49,014;INFO ; 171,0.00014858575384954267,0.14298559902605884 2022-11-29 07:35:49,018;INFO ; 172,0.00012492442130868043,0.19303263966784495 2022-11-29 07:35:49,022;INFO ; 173,0.00016932701292574935,0.2793387809139169 2022-11-29 07:35:49,026;INFO ; 174,0.00015742964467871989,0.3447108811846395 2022-11-29 07:35:49,030;INFO ; 175,0.00017358873326840673,0.5750829478358404 2022-11-29 07:35:49,034;INFO ; 176,0.00015226957040572161,0.8406421943144119 2022-11-29 07:35:49,039;INFO ; 177,0.00019260503632706645,0.0013249352494975658 2022-11-29 07:35:49,043;INFO ; 178,0.00015779248828345812,0.002602338675854627 2022-11-29 07:35:49,047;INFO ; 179,0.00014780762697808974,0.0021433136611779843 2022-11-29 07:35:49,051;INFO ; 180,0.00015305754475749826,0.0038915723292606967 2022-11-29 07:35:49,055;INFO ; 181,0.00012010600558306043,0.00247658064528874 2022-11-29 07:35:49,060;INFO ; 182,8.740452831852235e-05,0.0024521084033431594 2022-11-29 07:35:49,064;INFO ; 183,6.373248638426458e-05,0.0016891481091052144 2022-11-29 07:35:49,068;INFO ; 184,5.266680803789396e-05,0.0018353118475978147 2022-11-29 07:35:49,072;INFO ; 185,4.423668500818259e-05,0.0012562860381017395 2022-11-29 07:35:49,076;INFO ; 186,6.314903077624798e-05,0.002719341434138318 2022-11-29 07:35:49,080;INFO ; 187,5.6857006678658685e-05,0.002509782722968163 2022-11-29 07:35:49,084;INFO ; 188,5.5059448298824037e-05,0.0013461404689348276 2022-11-29 07:35:49,088;INFO ; 189,4.503328435251625e-05,0.0019826930322422416 2022-11-29 07:35:49,093;INFO ; 190,5.339145018522264e-05,0.0012837876408107766 2022-11-29 07:35:49,097;INFO ; 191,3.098724233809522e-05,0.0013107154287811615 2022-11-29 07:35:49,101;INFO ; 192,3.308008885332814e-05,0.0014103613336822226 2022-11-29 07:35:49,105;INFO ; 193,2.9350376864812637e-05,0.0015815276349007788 2022-11-29 07:35:49,110;INFO ; 194,2.6863077254417907e-05,0.0008375109454096235 2022-11-29 07:35:49,114;INFO ; 195,2.3968823327062422e-05,0.0010372694413473933 2022-11-29 07:35:49,118;INFO ; 196,2.2030877132808532e-05,0.0009241234687421242 2022-11-29 07:35:49,126;INFO ; 197,2.182604329942839e-05,0.0014462633099375218 2022-11-29 07:35:49,145;INFO ; 198,1.986409185137624e-05,0.0008913446970811066 2022-11-29 07:35:49,149;INFO ; 199,1.8217962008541884e-05,0.0014276957237979605 2022-11-29 07:35:49,153;INFO ; 200,1.7320212223703726e-05,0.0009792504798560502 2022-11-29 07:35:49,157;INFO ; 201,1.7582823969485302e-05,0.0014757677732895687 2022-11-29 07:35:49,161;INFO ; 202,1.6307169942381932e-05,0.001535176062875367 2022-11-29 07:35:49,165;INFO ; 203,1.3496040872766539e-05,0.001066969748420267 2022-11-29 07:35:49,169;INFO ; 204,1.280385029757512e-05,0.0009248912927135832 2022-11-29 07:35:49,173;INFO ; 205,1.133917717110072e-05,0.0011638065539680905 2022-11-29 07:35:49,177;INFO ; 206,1.1812052292740414e-05,0.0011654451276714984 2022-11-29 07:35:49,181;INFO ; 207,9.78726947556976e-06,0.0013099074935429143 2022-11-29 07:35:49,182;INFO ; bfw Assignment finished. 207 iterations and 9.78726947556976e-06 final gap .. GENERATED FROM PYTHON SOURCE LINES 354-361 .. code-block:: python # 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") .. rst-class:: sphx-glr-script-out .. code-block:: none 2022-11-29 07:35:49,299;WARNING ; Matrix Record has been saved to the database .. GENERATED FROM PYTHON SOURCE LINES 362-363 We can also plot convergence .. GENERATED FROM PYTHON SOURCE LINES 363-379 .. code-block:: python 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() .. image-sg:: /_auto_examples/images/sphx_glr_plot_forecasting_001.png :alt: plot forecasting :srcset: /_auto_examples/images/sphx_glr_plot_forecasting_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 380-381 Close the project .. GENERATED FROM PYTHON SOURCE LINES 381-382 .. code-block:: python project.close() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 4.600 seconds) .. _sphx_glr_download__auto_examples_plot_forecasting.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_forecasting.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_forecasting.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_