.. 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:41:23,019;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:41:23,081;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:41:23,143;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:41:23,202;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:41:23,263;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:41:23,321;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:41:23,367;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:41:23,803;WARNING ; Cost field with wrong type. Converting to float64 2022-11-29 07:41:23,803;INFO ; bfw Assignment STATS 2022-11-29 07:41:23,803;INFO ; Iteration, RelativeGap, stepsize 2022-11-29 07:41:23,814;INFO ; 1,inf,1.0 2022-11-29 07:41:23,824;INFO ; 2,0.8485503636986156,0.3649733931991619 2022-11-29 07:41:23,834;INFO ; 3,0.38139263975960314,0.22983569243524993 2022-11-29 07:41:23,847;INFO ; 4,0.19621280093105328,0.18591303407405754 2022-11-29 07:41:23,857;INFO ; 5,0.09069069564886302,0.709081525570193 2022-11-29 07:41:23,869;INFO ; 6,0.20600049841796414,0.12290139708465252 2022-11-29 07:41:23,882;INFO ; 7,0.0671057020569446,0.3863865464644097 2022-11-29 07:41:23,890;INFO ; 8,0.10307514522959232,0.10930550628245674 2022-11-29 07:41:23,902;INFO ; 9,0.042221488560558955,0.24878058909094228 2022-11-29 07:41:23,911;INFO ; 10,0.05926436280283587,0.15904812211073494 2022-11-29 07:41:23,920;INFO ; 11,0.034539501887818985,0.5180973982981508 2022-11-29 07:41:23,928;INFO ; 12,0.059426522740212366,0.101971242325629 2022-11-29 07:41:23,938;INFO ; 13,0.023239892828420625,0.1780595247621586 2022-11-29 07:41:23,950;INFO ; 14,0.01787378174233466,0.9787872892076548 2022-11-29 07:41:23,959;INFO ; 15,0.04966137112489825,0.08320656230754342 2022-11-29 07:41:23,968;INFO ; 16,0.021382882927382725,0.11517403372477297 2022-11-29 07:41:23,978;INFO ; 17,0.01314154305058098,0.1064036961470442 2022-11-29 07:41:23,987;INFO ; 18,0.009902228306191804,0.10710395852809111 2022-11-29 07:41:23,998;INFO ; 19,0.008834657124558089,0.252467895277828 2022-11-29 07:41:24,006;INFO ; 20,0.010371041656588888,0.6727839455896467 2022-11-29 07:41:24,015;INFO ; 21,0.011090096024277666,0.07468062458005388 2022-11-29 07:41:24,024;INFO ; 22,0.006512685864200749,0.12485018976276105 2022-11-29 07:41:24,033;INFO ; 23,0.00523888532832478,0.06316016036308214 2022-11-29 07:41:24,042;INFO ; 24,0.003949527733957799,0.09717892036982514 2022-11-29 07:41:24,050;INFO ; 25,0.003282221717998643,0.15775902884958926 2022-11-29 07:41:24,059;INFO ; 26,0.0057928324189390375,0.4524765555189632 2022-11-29 07:41:24,069;INFO ; 27,0.006682358714677215,0.7851865434128832 2022-11-29 07:41:24,081;INFO ; 28,0.00599261954468699,0.039098102583274626 2022-11-29 07:41:24,090;INFO ; 29,0.004031364721003652,0.04253017715977122 2022-11-29 07:41:24,099;INFO ; 30,0.00276965205224939,0.02251286694569934 2022-11-29 07:41:24,111;INFO ; 31,0.002484645375580033,0.045801689794576335 2022-11-29 07:41:24,118;INFO ; 32,0.0016385526291291498,0.034295834113305265 2022-11-29 07:41:24,127;INFO ; 33,0.0014956909894299761,0.035391999643557624 2022-11-29 07:41:24,136;INFO ; 34,0.0011355396506463338,0.053589857140533936 2022-11-29 07:41:24,145;INFO ; 35,0.0012151969842906466,0.04757129085244828 2022-11-29 07:41:24,157;INFO ; 36,0.0012393652042090905,0.06536474008117803 2022-11-29 07:41:24,165;INFO ; 37,0.0010684964499824193,0.1070395355360692 2022-11-29 07:41:24,173;INFO ; 38,0.0010899690746481111,0.09864062890245766 2022-11-29 07:41:24,182;INFO ; 39,0.0009886949061956609,0.06027624172548778 2022-11-29 07:41:24,182;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:41:24,374;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 e9fa5d13289a4ced804d82910ccb646a 2022-11-29 07:41:23.437204 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:41:25,688;WARNING ; Matrix Record has been saved to the database 2022-11-29 07:41:25,984;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 e9fa5d13289a4ced804d82910ccb646a 2022-11-29 07:41:23.437204 Skimming for assignment procedure. Class car
5 demand_power_modeled demand_power_modeled.omx 1 Synthetic gravity trip distribution 8b9f72d7b21540a2b397f02b17657d11 2022-11-29 07:41:25.479303 Synthetic gravity trip distribution. POWER
6 demand_expo_modeled demand_expo_modeled.omx 1 Synthetic gravity trip distribution b1161745a6ea4ed3b91f49cbf8b9a671 2022-11-29 07:41:25.858758 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:41:26,186;WARNING ; Matrix Record has been saved to the database 2022-11-29 07:41:26,314;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 e9fa5d13289a4ced804d82910ccb646a 2022-11-29 07:41:23.437204 Skimming for assignment procedure. Class car
5 demand_power_modeled demand_power_modeled.omx 1 Synthetic gravity trip distribution 8b9f72d7b21540a2b397f02b17657d11 2022-11-29 07:41:25.479303 Synthetic gravity trip distribution. POWER
6 demand_expo_modeled demand_expo_modeled.omx 1 Synthetic gravity trip distribution b1161745a6ea4ed3b91f49cbf8b9a671 2022-11-29 07:41:25.858758 Synthetic gravity trip distribution. EXPO
7 demand_ipfd demand_ipfd.aem 1 Iterative Proportional fitting 4896e56c032e40fba0f9e0f0aec55b62 2022-11-29 07:41:26.116444 None
8 demand_ipfd_omx demand_ipfd.omx 1 Iterative Proportional fitting 4896e56c032e40fba0f9e0f0aec55b62 2022-11-29 07:41:26.116444 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:41:26,386;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:41:26,828;WARNING ; Cost field with wrong type. Converting to float64 2022-11-29 07:41:26,828;INFO ; bfw Assignment STATS 2022-11-29 07:41:26,828;INFO ; Iteration, RelativeGap, stepsize 2022-11-29 07:41:26,839;INFO ; 1,inf,1.0 2022-11-29 07:41:26,850;INFO ; 2,0.867091292846019,0.32197433867661696 2022-11-29 07:41:26,862;INFO ; 3,0.5055379347296164,0.1627037478897683 2022-11-29 07:41:26,872;INFO ; 4,0.2732097525532206,0.1910691300436256 2022-11-29 07:41:26,884;INFO ; 5,0.10895974064209679,0.6670288618723861 2022-11-29 07:41:26,895;INFO ; 6,0.2280132998697513,0.1356973577069981 2022-11-29 07:41:26,907;INFO ; 7,0.09842433146442472,0.21519314771597273 2022-11-29 07:41:26,916;INFO ; 8,0.08317289845246523,0.4706374877324982 2022-11-29 07:41:26,928;INFO ; 9,0.10773938403291809,0.11999670270354114 2022-11-29 07:41:26,938;INFO ; 10,0.04788982675642811,0.3591483720822536 2022-11-29 07:41:26,949;INFO ; 11,0.057200771206820475,0.922973534296195 2022-11-29 07:41:26,962;INFO ; 12,0.08563983542491233,0.07918682217420323 2022-11-29 07:41:26,971;INFO ; 13,0.039938296722549615,0.18507454378514326 2022-11-29 07:41:26,981;INFO ; 14,0.0326369990984139,0.7600908627043362 2022-11-29 07:41:26,992;INFO ; 15,0.036585640943205835,0.06216080765074707 2022-11-29 07:41:27,006;INFO ; 16,0.018356649184765594,0.10336426840438416 2022-11-29 07:41:27,015;INFO ; 17,0.01627703318565919,0.15192343166662084 2022-11-29 07:41:27,031;INFO ; 18,0.012659485479604706,0.9594013862066872 2022-11-29 07:41:27,044;INFO ; 19,0.034977629745165724,0.05895662016280105 2022-11-29 07:41:27,056;INFO ; 20,0.013187186808745026,0.061518259810283894 2022-11-29 07:41:27,067;INFO ; 21,0.007864769213230422,0.10455920343375844 2022-11-29 07:41:27,077;INFO ; 22,0.007911319186227336,0.09913380433260993 2022-11-29 07:41:27,088;INFO ; 23,0.007954063168663818,0.171753224455896 2022-11-29 07:41:27,099;INFO ; 24,0.008626373783564142,0.3158726729880087 2022-11-29 07:41:27,108;INFO ; 25,0.007917625667280426,0.49817667214484407 2022-11-29 07:41:27,118;INFO ; 26,0.009998328685764467,0.03979646873358658 2022-11-29 07:41:27,128;INFO ; 27,0.0047515771238747975,0.04757306529595722 2022-11-29 07:41:27,138;INFO ; 28,0.004387188453820001,0.06734573811984251 2022-11-29 07:41:27,148;INFO ; 29,0.004568767804009187,0.09834777657986822 2022-11-29 07:41:27,161;INFO ; 30,0.003741395787267553,0.07937857712570884 2022-11-29 07:41:27,171;INFO ; 31,0.0034288491552659332,0.1028833129013462 2022-11-29 07:41:27,181;INFO ; 32,0.003657341766648959,0.12267721276619456 2022-11-29 07:41:27,191;INFO ; 33,0.0029015789936721057,0.10860159299280628 2022-11-29 07:41:27,200;INFO ; 34,0.002967628957664236,0.25419888991530165 2022-11-29 07:41:27,211;INFO ; 35,0.00398704663714311,0.4491111284884628 2022-11-29 07:41:27,221;INFO ; 36,0.0033709889456763273,0.646236430793795 2022-11-29 07:41:27,233;INFO ; 37,0.0036086782975488798,0.03820519829160206 2022-11-29 07:41:27,246;INFO ; 38,0.0029566258150419446,0.045569184563957775 2022-11-29 07:41:27,256;INFO ; 39,0.002790081848580272,0.03840156073713642 2022-11-29 07:41:27,267;INFO ; 40,0.002107065344825514,0.037679221377569926 2022-11-29 07:41:27,277;INFO ; 41,0.0019855692075169368,0.03613997971542551 2022-11-29 07:41:27,288;INFO ; 42,0.0015590080673693527,0.03972673297372743 2022-11-29 07:41:27,298;INFO ; 43,0.0012363639911708042,0.0632262547539914 2022-11-29 07:41:27,309;INFO ; 44,0.0013689484114205973,0.05927688672309608 2022-11-29 07:41:27,319;INFO ; 45,0.0012140267374493915,0.08744218314874795 2022-11-29 07:41:27,330;INFO ; 46,0.0011767680266703525,0.1219571359489961 2022-11-29 07:41:27,340;INFO ; 47,0.001427248522786352,0.07399914947520747 2022-11-29 07:41:27,350;INFO ; 48,0.00096820710425827,0.0691187002365229 2022-11-29 07:41:27,360;INFO ; 49,0.0010768368308055373,0.17033814052057034 2022-11-29 07:41:27,370;INFO ; 50,0.0009309451249805318,0.08208024738271023 2022-11-29 07:41:27,380;INFO ; 51,0.000999841297922514,0.0994350971029135 2022-11-29 07:41:27,391;INFO ; 52,0.0011890733948467435,0.31761488068601584 2022-11-29 07:41:27,401;INFO ; 53,0.001231551942739831,0.3283674231810475 2022-11-29 07:41:27,411;INFO ; 54,0.0012085990861447889,0.5417049548044551 2022-11-29 07:41:27,422;INFO ; 55,0.0013121287152552256,0.011376165026879183 2022-11-29 07:41:27,432;INFO ; 56,0.0009879429105291776,0.015050836944931962 2022-11-29 07:41:27,443;INFO ; 57,0.000719685889262109,0.00870005526770946 2022-11-29 07:41:27,454;INFO ; 58,0.000588560534717291,0.008533806432726523 2022-11-29 07:41:27,464;INFO ; 59,0.0005472529786834863,0.01319310120925449 2022-11-29 07:41:27,474;INFO ; 60,0.0005258541361499646,0.008726497590851846 2022-11-29 07:41:27,486;INFO ; 61,0.00036759765245808376,0.014813507460078881 2022-11-29 07:41:27,500;INFO ; 62,0.000369340485461683,0.008746120499781945 2022-11-29 07:41:27,510;INFO ; 63,0.00037421128809248243,0.018359072777223217 2022-11-29 07:41:27,518;INFO ; 64,0.0003690300748138154,0.011955674932955034 2022-11-29 07:41:27,528;INFO ; 65,0.0002972665070006979,0.007776177486414683 2022-11-29 07:41:27,539;INFO ; 66,0.0002768012340309554,0.017217913631598927 2022-11-29 07:41:27,551;INFO ; 67,0.00026405797012800315,0.010713890244337552 2022-11-29 07:41:27,566;INFO ; 68,0.0003436045766461971,0.033074252621814265 2022-11-29 07:41:27,584;INFO ; 69,0.00027356856948198774,0.01800956779207924 2022-11-29 07:41:27,600;INFO ; 70,0.00020105433976430048,0.007414116637618971 2022-11-29 07:41:27,612;INFO ; 71,0.00016425784973788068,0.009756412430100116 2022-11-29 07:41:27,623;INFO ; 72,0.00018894787142079885,0.010878835111796843 2022-11-29 07:41:27,634;INFO ; 73,0.00018824437363750408,0.007887998778464796 2022-11-29 07:41:27,646;INFO ; 74,0.00022585867648753364,0.017644387631585077 2022-11-29 07:41:27,657;INFO ; 75,0.00026262400379706096,0.016405966660738486 2022-11-29 07:41:27,668;INFO ; 76,0.00021767474317638933,0.01806489447538647 2022-11-29 07:41:27,681;INFO ; 77,0.00024192161330581431,0.027488224645993913 2022-11-29 07:41:27,691;INFO ; 78,0.00023365286279783726,0.026453300471569057 2022-11-29 07:41:27,702;INFO ; 79,0.00023750058989602436,0.025657774901444805 2022-11-29 07:41:27,711;INFO ; 80,0.0002065632665440503,0.02107135087982848 2022-11-29 07:41:27,721;INFO ; 81,0.00022237110859363703,0.010493335341438828 2022-11-29 07:41:27,734;INFO ; 82,0.00021134859743759095,0.01109242636600645 2022-11-29 07:41:27,745;INFO ; 83,0.00019802321676545338,0.014028612098294799 2022-11-29 07:41:27,759;INFO ; 84,0.00020171334310181108,0.016886633269205975 2022-11-29 07:41:27,770;INFO ; 85,0.0002392858022391699,0.016959409527154454 2022-11-29 07:41:27,782;INFO ; 86,0.00020083018476579225,0.009954706294940796 2022-11-29 07:41:27,794;INFO ; 87,0.00018096858120493923,0.023076761851094238 2022-11-29 07:41:27,804;INFO ; 88,0.0002116189615897541,0.02493178545134001 2022-11-29 07:41:27,815;INFO ; 89,0.00018931888885933835,0.01832333279773568 2022-11-29 07:41:27,826;INFO ; 90,0.0002453138967101981,0.01630587530802051 2022-11-29 07:41:27,836;INFO ; 91,0.00023451560135348657,0.025109052844099884 2022-11-29 07:41:27,848;INFO ; 92,0.0002329870751715686,0.03280922899450013 2022-11-29 07:41:27,858;INFO ; 93,0.00019410905348131105,0.015440843975420622 2022-11-29 07:41:27,869;INFO ; 94,0.00018600231725232088,0.025523549209680592 2022-11-29 07:41:27,881;INFO ; 95,0.0002343568067592318,0.025157239917956105 2022-11-29 07:41:27,892;INFO ; 96,0.00019018112739769568,0.03475554470438933 2022-11-29 07:41:27,903;INFO ; 97,0.00023726538995292752,0.018650419283597182 2022-11-29 07:41:27,920;INFO ; 98,0.00017150138405814787,0.023283936545179015 2022-11-29 07:41:27,933;INFO ; 99,0.0002296766658792735,0.022495634096791825 2022-11-29 07:41:27,943;INFO ; 100,0.0001899376477887286,0.01737649271780603 2022-11-29 07:41:27,955;INFO ; 101,0.0001751653863785703,0.007672903796916729 2022-11-29 07:41:27,967;INFO ; 102,0.00011721423699554636,0.00923425973687862 2022-11-29 07:41:27,979;INFO ; 103,0.0001367011342367571,0.011156275337164333 2022-11-29 07:41:27,992;INFO ; 104,0.0001620904323861578,0.01792495370314508 2022-11-29 07:41:28,004;INFO ; 105,0.00019809659868190514,0.011836907385989059 2022-11-29 07:41:28,017;INFO ; 106,0.0001308592159885253,0.013217620089079663 2022-11-29 07:41:28,029;INFO ; 107,0.0001417872319957479,0.02143583056464993 2022-11-29 07:41:28,045;INFO ; 108,0.0001257961830119357,0.012031470439450954 2022-11-29 07:41:28,057;INFO ; 109,0.00017353639145269165,0.01784546459561057 2022-11-29 07:41:28,072;INFO ; 110,0.0001371734231033438,0.008891160019237544 2022-11-29 07:41:28,084;INFO ; 111,0.00013979608276849388,0.01624105443721693 2022-11-29 07:41:28,094;INFO ; 112,0.00013595403114644895,0.008555566404475008 2022-11-29 07:41:28,104;INFO ; 113,0.00013439374507322234,0.008310076112959796 2022-11-29 07:41:28,115;INFO ; 114,0.00014477907306049701,0.035996343149953154 2022-11-29 07:41:28,126;INFO ; 115,0.0001775166590804069,0.016056754894366126 2022-11-29 07:41:28,136;INFO ; 116,0.00015112934376764806,0.040737414688596395 2022-11-29 07:41:28,146;INFO ; 117,0.00022508093954427502,0.02843579472772765 2022-11-29 07:41:28,156;INFO ; 118,0.0001497149240000087,0.02604302462579274 2022-11-29 07:41:28,167;INFO ; 119,0.00018522367980090983,0.021739978624438362 2022-11-29 07:41:28,178;INFO ; 120,0.00015702934207384212,0.05295567156400172 2022-11-29 07:41:28,190;INFO ; 121,0.0001809692422012244,0.03264427356495709 2022-11-29 07:41:28,201;INFO ; 122,0.00016513659151413062,0.08101064171551824 2022-11-29 07:41:28,214;INFO ; 123,0.00019067193993812666,0.04080450424277707 2022-11-29 07:41:28,226;INFO ; 124,0.00026614523534075846,0.0882735574524056 2022-11-29 07:41:28,237;INFO ; 125,0.00022960985225400218,0.043179444773747556 2022-11-29 07:41:28,247;INFO ; 126,0.00022996980368264892,0.13019250132945345 2022-11-29 07:41:28,259;INFO ; 127,0.0002148148081306177,0.0430691865967617 2022-11-29 07:41:28,270;INFO ; 128,0.0001840151146202736,0.10728129679708236 2022-11-29 07:41:28,281;INFO ; 129,0.00021571542878475242,0.06367632550662101 2022-11-29 07:41:28,293;INFO ; 130,0.00018985943266813758,0.06636547173812216 2022-11-29 07:41:28,305;INFO ; 131,0.00021788112771488425,0.14011439287767533 2022-11-29 07:41:28,315;INFO ; 132,0.0002445699130816712,0.16572292347542936 2022-11-29 07:41:28,330;INFO ; 133,0.00023728843527234271,0.14152522779517768 2022-11-29 07:41:28,343;INFO ; 134,0.00028433416151716934,0.24208703964507353 2022-11-29 07:41:28,354;INFO ; 135,0.0002564832002131297,0.21875373163438774 2022-11-29 07:41:28,364;INFO ; 136,0.00021381674053160446,0.1518002448016499 2022-11-29 07:41:28,375;INFO ; 137,0.00018842064782566276,0.15173039032339763 2022-11-29 07:41:28,386;INFO ; 138,0.0001476248942061017,0.04506788657652871 2022-11-29 07:41:28,397;INFO ; 139,0.00012036760563054937,0.051262980639953416 2022-11-29 07:41:28,408;INFO ; 140,9.498783554178682e-05,0.030590722457471548 2022-11-29 07:41:28,419;INFO ; 141,0.00012295600030812299,0.015930594871724376 2022-11-29 07:41:28,428;INFO ; 142,9.704521466970451e-05,0.010955265958510445 2022-11-29 07:41:28,438;INFO ; 143,0.00011706257615914803,0.026697987554557222 2022-11-29 07:41:28,450;INFO ; 144,8.808315579515083e-05,0.01700733899630292 2022-11-29 07:41:28,460;INFO ; 145,0.0001049779184019823,0.01548869925230354 2022-11-29 07:41:28,470;INFO ; 146,6.700323978078133e-05,0.008756792805294846 2022-11-29 07:41:28,480;INFO ; 147,6.483360665602376e-05,0.005339549108281833 2022-11-29 07:41:28,494;INFO ; 148,4.6167589877214125e-05,0.0018058409401943817 2022-11-29 07:41:28,504;INFO ; 149,4.746160820111484e-05,0.0015606667568251907 2022-11-29 07:41:28,515;INFO ; 150,3.694795332239094e-05,0.0022747636256892547 2022-11-29 07:41:28,526;INFO ; 151,4.39400811625762e-05,0.0015425386921904254 2022-11-29 07:41:28,536;INFO ; 152,3.612301972999362e-05,0.0019662780208025915 2022-11-29 07:41:28,547;INFO ; 153,3.824416594896884e-05,0.001810441955343464 2022-11-29 07:41:28,559;INFO ; 154,2.575288234417685e-05,0.0009559595473104685 2022-11-29 07:41:28,574;INFO ; 155,2.2774121003755873e-05,0.001539467791642984 2022-11-29 07:41:28,583;INFO ; 156,2.4912128856121738e-05,0.0013082529049237871 2022-11-29 07:41:28,593;INFO ; 157,2.4019322926414563e-05,0.0016631930613252722 2022-11-29 07:41:28,604;INFO ; 158,2.307854352596767e-05,0.000745363857887463 2022-11-29 07:41:28,614;INFO ; 159,1.4666848510148459e-05,0.0016601070131924108 2022-11-29 07:41:28,627;INFO ; 160,1.6153010041639665e-05,0.0011451011592832144 2022-11-29 07:41:28,637;INFO ; 161,1.380657146977359e-05,0.0010605881430335896 2022-11-29 07:41:28,649;INFO ; 162,1.3293010753254887e-05,0.00027019946123223285 2022-11-29 07:41:28,659;INFO ; 163,1.4429617266259028e-05,0.0015232508328878662 2022-11-29 07:41:28,670;INFO ; 164,1.8199375521551717e-05,0.0012223235061837661 2022-11-29 07:41:28,681;INFO ; 165,1.5557229364447733e-05,0.00201554054291045 2022-11-29 07:41:28,692;INFO ; 166,1.703968309615698e-05,0.001277620729043728 2022-11-29 07:41:28,703;INFO ; 167,1.692924890593869e-05,0.0022552887545046786 2022-11-29 07:41:28,715;INFO ; 168,1.4879862379374894e-05,0.002573596426879728 2022-11-29 07:41:28,726;INFO ; 169,1.7273548815192082e-05,0.0021099441178978875 2022-11-29 07:41:28,736;INFO ; 170,1.8817130043723948e-05,0.004698254843445689 2022-11-29 07:41:28,747;INFO ; 171,1.749311374732682e-05,0.002586886608621976 2022-11-29 07:41:28,757;INFO ; 172,2.0872959880483565e-05,0.005625049644015303 2022-11-29 07:41:28,768;INFO ; 173,3.155057534097086e-05,0.008472284692188577 2022-11-29 07:41:28,779;INFO ; 174,3.292927517477804e-05,0.010807202925122524 2022-11-29 07:41:28,789;INFO ; 175,3.202631575650911e-05,0.0057000467561613795 2022-11-29 07:41:28,799;INFO ; 176,3.052135343972057e-05,0.005401067396796621 2022-11-29 07:41:28,809;INFO ; 177,2.8395766101553125e-05,0.006031118368664424 2022-11-29 07:41:28,822;INFO ; 178,3.2038615373989356e-05,0.00633250198223844 2022-11-29 07:41:28,832;INFO ; 179,2.740994118036382e-05,0.0021867839760108055 2022-11-29 07:41:28,845;INFO ; 180,2.565585604847169e-05,0.004047582705161298 2022-11-29 07:41:28,855;INFO ; 181,3.891833939736058e-05,0.005152785726245997 2022-11-29 07:41:28,866;INFO ; 182,3.9226026660736946e-05,0.005981067736353421 2022-11-29 07:41:28,880;INFO ; 183,3.4393384022651075e-05,0.004345622255319477 2022-11-29 07:41:28,894;INFO ; 184,3.182957938525822e-05,0.003663761828389743 2022-11-29 07:41:28,904;INFO ; 185,2.990420190831444e-05,0.0020447456809312677 2022-11-29 07:41:28,915;INFO ; 186,2.979626467407261e-05,0.002690456754607123 2022-11-29 07:41:28,927;INFO ; 187,2.9020557118579995e-05,0.004935980381653287 2022-11-29 07:41:28,938;INFO ; 188,2.68766369150941e-05,0.005534244806695796 2022-11-29 07:41:28,949;INFO ; 189,3.1672775573643866e-05,0.004340274451879433 2022-11-29 07:41:28,959;INFO ; 190,2.3694674448533433e-05,0.0019760098065171277 2022-11-29 07:41:28,969;INFO ; 191,2.2741613790287633e-05,0.0027560451883080787 2022-11-29 07:41:28,979;INFO ; 192,2.4536630430294967e-05,0.002074466917889604 2022-11-29 07:41:28,988;INFO ; 193,2.6827217717785233e-05,0.0041174653088326425 2022-11-29 07:41:28,998;INFO ; 194,2.7267203834524453e-05,0.007816140040506948 2022-11-29 07:41:29,010;INFO ; 195,3.250060878857876e-05,0.007653443529135849 2022-11-29 07:41:29,019;INFO ; 196,3.009688752802309e-05,0.004711668363039726 2022-11-29 07:41:29,030;INFO ; 197,2.3786185734711505e-05,0.003836666154504752 2022-11-29 07:41:29,043;INFO ; 198,2.129371461954619e-05,0.0035278832133845174 2022-11-29 07:41:29,054;INFO ; 199,2.1507078153015078e-05,0.003174274858697042 2022-11-29 07:41:29,068;INFO ; 200,2.2757440693758835e-05,0.003927559143270781 2022-11-29 07:41:29,078;INFO ; 201,3.2630238032607125e-05,0.006144180140757262 2022-11-29 07:41:29,089;INFO ; 202,3.3940575383896206e-05,0.006997673402706073 2022-11-29 07:41:29,100;INFO ; 203,2.970260901747991e-05,0.0050962574498544435 2022-11-29 07:41:29,111;INFO ; 204,2.8011181889071648e-05,0.00399365666069393 2022-11-29 07:41:29,122;INFO ; 205,2.2711182934391366e-05,0.003922852046553955 2022-11-29 07:41:29,133;INFO ; 206,2.6051136296827965e-05,0.003800551050046274 2022-11-29 07:41:29,143;INFO ; 207,1.702715544676636e-05,0.0029712653551246596 2022-11-29 07:41:29,155;INFO ; 208,1.963388186770968e-05,0.0024128504285935433 2022-11-29 07:41:29,167;INFO ; 209,1.657865211258389e-05,0.0018822043714706788 2022-11-29 07:41:29,176;INFO ; 210,1.864774016101084e-05,0.0025563704241852265 2022-11-29 07:41:29,187;INFO ; 211,2.1466131156795298e-05,0.0032532715922329127 2022-11-29 07:41:29,197;INFO ; 212,2.4989553903315986e-05,0.003367612215612431 2022-11-29 07:41:29,207;INFO ; 213,2.1378305365136603e-05,0.004862832370926299 2022-11-29 07:41:29,217;INFO ; 214,2.4628105500102207e-05,0.002762003735684758 2022-11-29 07:41:29,227;INFO ; 215,2.0913840900184602e-05,0.004586192457298623 2022-11-29 07:41:29,240;INFO ; 216,2.2359205246886216e-05,0.0035397569011867127 2022-11-29 07:41:29,251;INFO ; 217,2.250481903128926e-05,0.007346239899070144 2022-11-29 07:41:29,262;INFO ; 218,2.8667673311828782e-05,0.0038814622455038313 2022-11-29 07:41:29,273;INFO ; 219,2.0929368253880903e-05,0.0030957728883807285 2022-11-29 07:41:29,286;INFO ; 220,1.9207133758563193e-05,0.0027844673546344855 2022-11-29 07:41:29,297;INFO ; 221,2.2023450491881492e-05,0.006068928493853041 2022-11-29 07:41:29,310;INFO ; 222,2.731361040371244e-05,0.008015357593072148 2022-11-29 07:41:29,321;INFO ; 223,2.5733546216132467e-05,0.0035046647560754863 2022-11-29 07:41:29,334;INFO ; 224,1.9350511542280017e-05,0.004296852682552948 2022-11-29 07:41:29,344;INFO ; 225,2.7455115718827282e-05,0.0036369256993766075 2022-11-29 07:41:29,355;INFO ; 226,1.6294010272226646e-05,0.0016191431053403946 2022-11-29 07:41:29,366;INFO ; 227,1.6077237920752936e-05,0.0015111840301342348 2022-11-29 07:41:29,377;INFO ; 228,1.6409825365756333e-05,0.004374443220268843 2022-11-29 07:41:29,386;INFO ; 229,2.3932822432532796e-05,0.0034885363764988473 2022-11-29 07:41:29,397;INFO ; 230,1.8594430242670553e-05,0.0032880461667760246 2022-11-29 07:41:29,417;INFO ; 231,1.5434620273542705e-05,0.005047880995789397 2022-11-29 07:41:29,427;INFO ; 232,2.0510442647168057e-05,0.004203165500007726 2022-11-29 07:41:29,439;INFO ; 233,2.2624917652185294e-05,0.004779988206168688 2022-11-29 07:41:29,449;INFO ; 234,1.6934708299395492e-05,0.0028128494111883074 2022-11-29 07:41:29,462;INFO ; 235,1.6798408205667308e-05,0.002399479126644229 2022-11-29 07:41:29,475;INFO ; 236,1.6841908872390963e-05,0.0014630474393014473 2022-11-29 07:41:29,488;INFO ; 237,1.5896537784079684e-05,0.0018399091579230297 2022-11-29 07:41:29,498;INFO ; 238,1.4071845398686542e-05,0.0010462617275863871 2022-11-29 07:41:29,509;INFO ; 239,1.2486811978127134e-05,0.0010453403447087811 2022-11-29 07:41:29,519;INFO ; 240,1.2824749595132711e-05,0.0010817421456321057 2022-11-29 07:41:29,532;INFO ; 241,1.3482230379540947e-05,0.0008880148308409236 2022-11-29 07:41:29,542;INFO ; 242,1.1632066216973314e-05,0.0007101506591106019 2022-11-29 07:41:29,554;INFO ; 243,1.3662623236015629e-05,0.0010471917114766075 2022-11-29 07:41:29,566;INFO ; 244,1.4321429467909652e-05,0.001026351324836033 2022-11-29 07:41:29,577;INFO ; 245,1.5396385938630378e-05,0.0009743830437313134 2022-11-29 07:41:29,588;INFO ; 246,1.0186215464835854e-05,0.0010841087545626308 2022-11-29 07:41:29,602;INFO ; 247,1.4136371992919065e-05,0.0010022734160444883 2022-11-29 07:41:29,614;INFO ; 248,9.78877244037103e-06,0.0007947582132790485 2022-11-29 07:41:29,614;INFO ; bfw Assignment finished. 248 iterations and 9.78877244037103e-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:41:29,777;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 7.814 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 `_