.. 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 Out: .. code-block:: none 2022-07-24 11:51:08,618;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations 2022-07-24 11:51:08,654;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations 2022-07-24 11:51:08,689;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations 2022-07-24 11:51:08,724;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations 2022-07-24 11:51:08,759;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations 2022-07-24 11:51:08,794;WARNING ; Field(s) name, lanes has(ve) at least one NaN value. Check your computations .. 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 Out: .. code-block:: none 2022-07-24 11:51:08,823;WARNING ; Cost field with wrong type. Converting to float64 .. 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 Out: .. code-block:: none 2022-07-24 11:51:09,004;WARNING ; Cost field with wrong type. Converting to float64 2022-07-24 11:51:09,005;INFO ; bfw Assignment STATS 2022-07-24 11:51:09,005;INFO ; Iteration, RelativeGap, stepsize 2022-07-24 11:51:09,011;INFO ; 1,inf,1.0 2022-07-24 11:51:09,018;INFO ; 2,0.8485503636986156,0.3649733931991619 2022-07-24 11:51:09,025;INFO ; 3,0.38139263975960314,0.22983569243524993 2022-07-24 11:51:09,032;INFO ; 4,0.19621280093105328,0.18591303407405754 2022-07-24 11:51:09,039;INFO ; 5,0.09069069564886302,0.709081525570193 2022-07-24 11:51:09,046;INFO ; 6,0.20600049841796414,0.12290139708465252 2022-07-24 11:51:09,055;INFO ; 7,0.0671057020569446,0.3863865464644097 2022-07-24 11:51:09,062;INFO ; 8,0.10307514522959232,0.10930550628245674 2022-07-24 11:51:09,072;INFO ; 9,0.042221488560558955,0.24878058909094228 2022-07-24 11:51:09,083;INFO ; 10,0.05926436280283587,0.15904812211073494 2022-07-24 11:51:09,097;INFO ; 11,0.034539501887818985,0.5180973982981508 2022-07-24 11:51:09,104;INFO ; 12,0.059426522740212366,0.101971242325629 2022-07-24 11:51:09,111;INFO ; 13,0.023239892828420625,0.1780595247621586 2022-07-24 11:51:09,119;INFO ; 14,0.01787378174233466,0.9787872892076548 2022-07-24 11:51:09,126;INFO ; 15,0.04966137112489825,0.08320656230754342 2022-07-24 11:51:09,133;INFO ; 16,0.021382882927382725,0.11517403372477297 2022-07-24 11:51:09,140;INFO ; 17,0.01314154305058098,0.1064036961470442 2022-07-24 11:51:09,147;INFO ; 18,0.009902228306191804,0.10710395852809111 2022-07-24 11:51:09,153;INFO ; 19,0.008834657124558089,0.252467895277828 2022-07-24 11:51:09,160;INFO ; 20,0.010371041656588888,0.6727839455896467 2022-07-24 11:51:09,188;INFO ; 21,0.011090096024277666,0.07468062458005388 2022-07-24 11:51:09,195;INFO ; 22,0.006512685864200749,0.12485018976276105 2022-07-24 11:51:09,203;INFO ; 23,0.00523888532832478,0.06316016036308214 2022-07-24 11:51:09,210;INFO ; 24,0.003949527733957799,0.09717892036982514 2022-07-24 11:51:09,216;INFO ; 25,0.003282221717998643,0.15775902884958926 2022-07-24 11:51:09,223;INFO ; 26,0.0057928324189390375,0.4524765555189632 2022-07-24 11:51:09,232;INFO ; 27,0.006682358714677215,0.7851865434128832 2022-07-24 11:51:09,239;INFO ; 28,0.00599261954468699,0.039098102583274626 2022-07-24 11:51:09,246;INFO ; 29,0.004031364721003652,0.04253017715977122 2022-07-24 11:51:09,254;INFO ; 30,0.00276965205224939,0.02251286694569934 2022-07-24 11:51:09,261;INFO ; 31,0.002484645375580033,0.045801689794576335 2022-07-24 11:51:09,268;INFO ; 32,0.0016385526291291498,0.034295834113305265 2022-07-24 11:51:09,283;INFO ; 33,0.0014956909894299761,0.035391999643557624 2022-07-24 11:51:09,291;INFO ; 34,0.0011355396506463338,0.053589857140533936 2022-07-24 11:51:09,298;INFO ; 35,0.0012151969842906466,0.04757129085244828 2022-07-24 11:51:09,304;INFO ; 36,0.0012393652042090905,0.06536474008117803 2022-07-24 11:51:09,311;INFO ; 37,0.0010684964499824193,0.1070395355360692 2022-07-24 11:51:09,318;INFO ; 38,0.0010899690746481111,0.09864062890245766 2022-07-24 11:51:09,327;INFO ; 39,0.0009886949061956609,0.06027624172548778 2022-07-24 11:51:09,327;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 Out: .. code-block:: none 2022-07-24 11:51:09,427;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 0d3180fe6e91455c9cf70675d28b9593 2022-07-24 11:51:08.855155 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 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 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") .. rst-class:: sphx-glr-script-out Out: .. code-block:: none /home/runner/work/aequilibrae/aequilibrae/aequilibrae/distribution/gravity_application.py:319: RuntimeWarning: divide by zero encountered in power self.output.matrix_view[i, :] = (np.power(self.impedance.matrix_view[i, :], -self.model.alpha) * p * a)[ /home/runner/work/aequilibrae/aequilibrae/aequilibrae/distribution/gravity_application.py:333: RuntimeWarning: invalid value encountered in multiply self.output.matrix_view[:, :] = self.output.matrix_view[:, :] * non_inf .. 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 Out: .. code-block:: none 2022-07-24 11:51:09,997;WARNING ; Matrix Record has been saved to the database 2022-07-24 11:51:10,132;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 0d3180fe6e91455c9cf70675d28b9593 2022-07-24 11:51:08.855155 Skimming for assignment procedure. Class car
5 demand_power_modeled demand_power_modeled.omx 1 Synthetic gravity trip distribution bba85312d93f4cf2abbe0125074e6017 2022-07-24 11:51:09.934294 Synthetic gravity trip distribution. POWER
6 demand_expo_modeled demand_expo_modeled.omx 1 Synthetic gravity trip distribution 68999294fd82422e90888e1a9d32bc4f 2022-07-24 11:51:10.068362 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 Out: .. code-block:: none 2022-07-24 11:51:10,218;WARNING ; Matrix Record has been saved to the database 2022-07-24 11:51:10,279;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 0d3180fe6e91455c9cf70675d28b9593 2022-07-24 11:51:08.855155 Skimming for assignment procedure. Class car
5 demand_power_modeled demand_power_modeled.omx 1 Synthetic gravity trip distribution bba85312d93f4cf2abbe0125074e6017 2022-07-24 11:51:09.934294 Synthetic gravity trip distribution. POWER
6 demand_expo_modeled demand_expo_modeled.omx 1 Synthetic gravity trip distribution 68999294fd82422e90888e1a9d32bc4f 2022-07-24 11:51:10.068362 Synthetic gravity trip distribution. EXPO
7 demand_ipfd demand_ipfd.aem 1 Iterative Proportional fitting 4390f78a30144f89abb86259a7ba297d 2022-07-24 11:51:10.186136 None
8 demand_ipfd_omx demand_ipfd.omx 1 Iterative Proportional fitting 4390f78a30144f89abb86259a7ba297d 2022-07-24 11:51:10.186136 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 Out: .. code-block:: none 2022-07-24 11:51:10,311;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 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 Out: .. code-block:: none 2022-07-24 11:51:10,484;WARNING ; Cost field with wrong type. Converting to float64 2022-07-24 11:51:10,484;INFO ; bfw Assignment STATS 2022-07-24 11:51:10,484;INFO ; Iteration, RelativeGap, stepsize 2022-07-24 11:51:10,491;INFO ; 1,inf,1.0 2022-07-24 11:51:10,499;INFO ; 2,0.8713509675574614,0.3358757435397074 2022-07-24 11:51:10,508;INFO ; 3,0.46575689154346217,0.21055950654838673 2022-07-24 11:51:10,519;INFO ; 4,0.24977200870407607,0.17323550683973052 2022-07-24 11:51:10,527;INFO ; 5,0.1402202549004915,0.38429768792587127 2022-07-24 11:51:10,536;INFO ; 6,0.1588412657277213,0.1906419394959899 2022-07-24 11:51:10,546;INFO ; 7,0.06339094351731554,0.7360090836496322 2022-07-24 11:51:10,558;INFO ; 8,0.16162717680382127,0.11255169646675317 2022-07-24 11:51:10,567;INFO ; 9,0.07200956266143285,0.15780171556591063 2022-07-24 11:51:10,593;INFO ; 10,0.04474452112794786,0.41349627068848044 2022-07-24 11:51:10,603;INFO ; 11,0.06325169510190023,0.08511928831978753 2022-07-24 11:51:10,612;INFO ; 12,0.031964066794302075,0.18773523961351385 2022-07-24 11:51:10,623;INFO ; 13,0.03355158403963904,0.7841304867160707 2022-07-24 11:51:10,634;INFO ; 14,0.0662311859297268,0.08382215359235459 2022-07-24 11:51:10,642;INFO ; 15,0.029289856770383555,0.130100457324655 2022-07-24 11:51:10,651;INFO ; 16,0.016931732240309243,0.29609940724355266 2022-07-24 11:51:10,661;INFO ; 17,0.0202998038182712,0.49157184163688733 2022-07-24 11:51:10,688;INFO ; 18,0.024376030176625332,0.06009398947749203 2022-07-24 11:51:10,696;INFO ; 19,0.012661784365378174,0.1087258203095128 2022-07-24 11:51:10,705;INFO ; 20,0.012757528121218732,0.15463008809285975 2022-07-24 11:51:10,716;INFO ; 21,0.010793119039580345,0.2830067301822983 2022-07-24 11:51:10,725;INFO ; 22,0.01212804950783415,0.6261663331707688 2022-07-24 11:51:10,733;INFO ; 23,0.013235720429543393,0.05237312510649104 2022-07-24 11:51:10,742;INFO ; 24,0.0085389139120617,0.10220906075498341 2022-07-24 11:51:10,751;INFO ; 25,0.007021587646013366,0.0924932000788927 2022-07-24 11:51:10,761;INFO ; 26,0.006761266520217503,0.2049442048829803 2022-07-24 11:51:10,768;INFO ; 27,0.0065540224155253065,0.3100684330724725 2022-07-24 11:51:10,776;INFO ; 28,0.006506426767929141,0.8387684807902663 2022-07-24 11:51:10,781;INFO ; 29,0.008076520841484488,0.0372023090042747 2022-07-24 11:51:10,788;INFO ; 30,0.004544126105451974,0.03881945459447333 2022-07-24 11:51:10,799;INFO ; 31,0.003406685651600249,0.03580293507911867 2022-07-24 11:51:10,808;INFO ; 32,0.003142951615100504,0.13699112519821102 2022-07-24 11:51:10,819;INFO ; 33,0.0037477786762432227,0.12688049324060285 2022-07-24 11:51:10,828;INFO ; 34,0.0027406326012179437,0.08756905845655981 2022-07-24 11:51:10,840;INFO ; 35,0.002382635922679247,0.08775133183477749 2022-07-24 11:51:10,848;INFO ; 36,0.0022444328273856576,0.13347377478104042 2022-07-24 11:51:10,857;INFO ; 37,0.002516460923558543,0.19550845097759162 2022-07-24 11:51:10,864;INFO ; 38,0.0027024665866827073,0.4019824434674727 2022-07-24 11:51:10,875;INFO ; 39,0.0031089472878496494,0.7336991200915718 2022-07-24 11:51:10,884;INFO ; 40,0.0027995871199726105,0.015908639218701847 2022-07-24 11:51:10,896;INFO ; 41,0.00191347776553452,0.017645959208039193 2022-07-24 11:51:10,905;INFO ; 42,0.001871478100692935,0.027851777902078274 2022-07-24 11:51:10,916;INFO ; 43,0.00187660200996751,0.0407406809588443 2022-07-24 11:51:10,926;INFO ; 44,0.0017588922666353334,0.051634810992730804 2022-07-24 11:51:10,935;INFO ; 45,0.0018914703462433648,0.06501983540712403 2022-07-24 11:51:10,944;INFO ; 46,0.002216815028134017,0.09122867334572636 2022-07-24 11:51:10,951;INFO ; 47,0.0016610524244807779,0.09974056964500544 2022-07-24 11:51:10,961;INFO ; 48,0.0015170563794298555,0.19189978237130523 2022-07-24 11:51:10,969;INFO ; 49,0.0017525275154088471,0.16470264550091648 2022-07-24 11:51:10,987;INFO ; 50,0.0017028877737507873,0.2814421905388624 2022-07-24 11:51:10,994;INFO ; 51,0.0017704483270625374,0.3815206243738768 2022-07-24 11:51:11,002;INFO ; 52,0.0016816825789500198,0.29582331400619605 2022-07-24 11:51:11,011;INFO ; 53,0.0011245155361840088,0.437467250243919 2022-07-24 11:51:11,020;INFO ; 54,0.0011352589190524516,0.36102783502862107 2022-07-24 11:51:11,028;INFO ; 55,0.0009665319022711074,0.5727504567780144 2022-07-24 11:51:11,039;INFO ; 56,0.0009530087136821809,0.008439597901621881 2022-07-24 11:51:11,048;INFO ; 57,0.0009856671397419853,0.008089368959235666 2022-07-24 11:51:11,056;INFO ; 58,0.0007543604747074603,0.010359402809152622 2022-07-24 11:51:11,066;INFO ; 59,0.000709183597695008,0.01899314607873829 2022-07-24 11:51:11,073;INFO ; 60,0.0007660080935625274,0.03241495574010416 2022-07-24 11:51:11,080;INFO ; 61,0.0007010568090579762,0.02681390211026228 2022-07-24 11:51:11,085;INFO ; 62,0.000588766326284642,0.023017638428367578 2022-07-24 11:51:11,096;INFO ; 63,0.0006343773810207421,0.024734649570036307 2022-07-24 11:51:11,104;INFO ; 64,0.0003884103547490104,0.01017907762157282 2022-07-24 11:51:11,110;INFO ; 65,0.0004315796434154266,0.02453606712877713 2022-07-24 11:51:11,120;INFO ; 66,0.0004852360718690647,0.03491022425604612 2022-07-24 11:51:11,129;INFO ; 67,0.00035102379046677787,0.013982563629064259 2022-07-24 11:51:11,138;INFO ; 68,0.00026266893035736024,0.004751564329302037 2022-07-24 11:51:11,147;INFO ; 69,0.00023908634472532604,0.006906558156033302 2022-07-24 11:51:11,156;INFO ; 70,0.00026785106757524016,0.005776671615021674 2022-07-24 11:51:11,165;INFO ; 71,0.0002397204944142932,0.006485325585483821 2022-07-24 11:51:11,192;INFO ; 72,0.00022022244313734378,0.007350929609073568 2022-07-24 11:51:11,201;INFO ; 73,0.00015845776849829425,0.005853463645348276 2022-07-24 11:51:11,210;INFO ; 74,0.00013546180637707196,0.004661409639515768 2022-07-24 11:51:11,220;INFO ; 75,0.0001580639776665809,0.009029224348624616 2022-07-24 11:51:11,229;INFO ; 76,0.0001283665770941313,0.0031751861696536314 2022-07-24 11:51:11,236;INFO ; 77,8.67402521104607e-05,0.005340557470867879 2022-07-24 11:51:11,242;INFO ; 78,0.00010904492828810695,0.004135182705767525 2022-07-24 11:51:11,252;INFO ; 79,0.00010339522560634934,0.005003214566191402 2022-07-24 11:51:11,262;INFO ; 80,8.724125132310276e-05,0.0032485846982710734 2022-07-24 11:51:11,270;INFO ; 81,9.140057632564178e-05,0.007188785576676435 2022-07-24 11:51:11,274;INFO ; 82,0.00011217051213138463,0.005482735421554177 2022-07-24 11:51:11,284;INFO ; 83,0.00011991114176489104,0.008654386255401051 2022-07-24 11:51:11,292;INFO ; 84,0.00013666855833886172,0.011772811690575669 2022-07-24 11:51:11,304;INFO ; 85,0.00013116624340373046,0.014114732434530007 2022-07-24 11:51:11,313;INFO ; 86,0.0001235358821210168,0.01241328529506722 2022-07-24 11:51:11,320;INFO ; 87,0.00014519503015259544,0.01711495778299769 2022-07-24 11:51:11,326;INFO ; 88,0.00014982422634443547,0.03571907087969763 2022-07-24 11:51:11,335;INFO ; 89,0.00012664217604426762,0.021583951143364193 2022-07-24 11:51:11,344;INFO ; 90,0.0001479759581480769,0.01312355605329975 2022-07-24 11:51:11,353;INFO ; 91,0.00016452208755013357,0.013811680454600498 2022-07-24 11:51:11,361;INFO ; 92,0.00014590372169164355,0.0166771960125271 2022-07-24 11:51:11,389;INFO ; 93,0.00016500274992904294,0.03266627753406412 2022-07-24 11:51:11,400;INFO ; 94,0.00018757009195573428,0.023635343977194207 2022-07-24 11:51:11,407;INFO ; 95,0.000261404184831196,0.05298675716102535 2022-07-24 11:51:11,416;INFO ; 96,0.0003290901465443329,0.06057978557366902 2022-07-24 11:51:11,423;INFO ; 97,0.00026623251720488865,0.11264825933414684 2022-07-24 11:51:11,432;INFO ; 98,0.0002903595975766577,0.05683183551176089 2022-07-24 11:51:11,438;INFO ; 99,0.0002455677078931601,0.11150170030614494 2022-07-24 11:51:11,446;INFO ; 100,0.0003176016781365876,0.29932031146058546 2022-07-24 11:51:11,455;INFO ; 101,0.0003664509308170111,0.399883324862691 2022-07-24 11:51:11,461;INFO ; 102,0.0003677628174172003,0.44923402695216375 2022-07-24 11:51:11,488;INFO ; 103,0.00037538616160752387,0.003743250535958238 2022-07-24 11:51:11,496;INFO ; 104,0.00028767262399038545,0.0038485507629521113 2022-07-24 11:51:11,506;INFO ; 105,0.00027950818424211395,0.0025540624664060945 2022-07-24 11:51:11,515;INFO ; 106,0.0002026742651619478,0.0028245667678849845 2022-07-24 11:51:11,524;INFO ; 107,0.00014699058317719168,0.0025002216454168575 2022-07-24 11:51:11,533;INFO ; 108,0.00014735009644609935,0.0037694713578718324 2022-07-24 11:51:11,541;INFO ; 109,0.0001238326268000154,0.002525900860709033 2022-07-24 11:51:11,552;INFO ; 110,0.00010303252490439783,0.0038598493983630733 2022-07-24 11:51:11,561;INFO ; 111,0.00011846563851699743,0.005112833186732594 2022-07-24 11:51:11,570;INFO ; 112,0.00011853763885747957,0.002749950238134859 2022-07-24 11:51:11,592;INFO ; 113,7.84338040730913e-05,0.0037609576684564526 2022-07-24 11:51:11,603;INFO ; 114,8.687971330939378e-05,0.004895056724644643 2022-07-24 11:51:11,613;INFO ; 115,7.95429858614907e-05,0.004848329079570975 2022-07-24 11:51:11,623;INFO ; 116,7.596927555910516e-05,0.002985602385758125 2022-07-24 11:51:11,646;INFO ; 117,6.983061491070485e-05,0.004413175862543675 2022-07-24 11:51:11,655;INFO ; 118,8.61832438666026e-05,0.004565559166307413 2022-07-24 11:51:11,665;INFO ; 119,7.310672105012594e-05,0.004480566667306388 2022-07-24 11:51:11,672;INFO ; 120,7.83253200571139e-05,0.005114796707337788 2022-07-24 11:51:11,692;INFO ; 121,7.37274761520572e-05,0.004092146530375717 2022-07-24 11:51:11,701;INFO ; 122,6.544057775752235e-05,0.003218415660650928 2022-07-24 11:51:11,711;INFO ; 123,5.6336220155429556e-05,0.0033208630399425717 2022-07-24 11:51:11,720;INFO ; 124,4.915508993510612e-05,0.00237384601428891 2022-07-24 11:51:11,727;INFO ; 125,3.433895399390693e-05,0.000981369801240951 2022-07-24 11:51:11,736;INFO ; 126,4.541668988708891e-05,0.003427709067537379 2022-07-24 11:51:11,745;INFO ; 127,4.134254934599688e-05,0.0016299703170431189 2022-07-24 11:51:11,754;INFO ; 128,4.4280349676691895e-05,0.0031748155886474837 2022-07-24 11:51:11,763;INFO ; 129,4.007104792546412e-05,0.004338036835327826 2022-07-24 11:51:11,774;INFO ; 130,4.2597571232431615e-05,0.0022980556213026697 2022-07-24 11:51:11,784;INFO ; 131,3.425477330327951e-05,0.0013878606166324063 2022-07-24 11:51:11,789;INFO ; 132,4.10047167690953e-05,0.0030153683836099026 2022-07-24 11:51:11,794;INFO ; 133,5.424801685422253e-05,0.0028623642719247206 2022-07-24 11:51:11,802;INFO ; 134,3.7533860994158275e-05,0.0022308020515013115 2022-07-24 11:51:11,811;INFO ; 135,2.97665612821463e-05,0.002029110829646872 2022-07-24 11:51:11,820;INFO ; 136,2.705752100572333e-05,0.0009905448271303322 2022-07-24 11:51:11,829;INFO ; 137,2.8817445818803202e-05,0.00273424973370967 2022-07-24 11:51:11,837;INFO ; 138,3.4792785811393496e-05,0.003106859165075915 2022-07-24 11:51:11,848;INFO ; 139,3.8711441058396093e-05,0.0031121765778068353 2022-07-24 11:51:11,857;INFO ; 140,2.637719729776009e-05,0.0016610684829227115 2022-07-24 11:51:11,865;INFO ; 141,2.522538265971387e-05,0.0014987738454576287 2022-07-24 11:51:11,888;INFO ; 142,1.9426258020210713e-05,0.0010660369030047088 2022-07-24 11:51:11,896;INFO ; 143,2.0553547920993958e-05,0.0010314024104926777 2022-07-24 11:51:11,905;INFO ; 144,1.883251928386461e-05,0.0017558695814757048 2022-07-24 11:51:11,915;INFO ; 145,1.9958080442710016e-05,0.002110697118736897 2022-07-24 11:51:11,921;INFO ; 146,1.770816863513865e-05,0.0016624615870954578 2022-07-24 11:51:11,932;INFO ; 147,1.991445952201011e-05,0.0018996012965719772 2022-07-24 11:51:11,941;INFO ; 148,1.706840997020854e-05,0.001456336399454671 2022-07-24 11:51:11,948;INFO ; 149,1.4590482207494667e-05,0.0010968691038560907 2022-07-24 11:51:11,956;INFO ; 150,1.3767575082776003e-05,0.0016252542183482531 2022-07-24 11:51:11,963;INFO ; 151,1.4125229466027417e-05,0.002907541579561978 2022-07-24 11:51:11,976;INFO ; 152,1.9051865420455765e-05,0.003773008260582763 2022-07-24 11:51:11,992;INFO ; 153,2.1662045624097992e-05,0.004863749417174604 2022-07-24 11:51:12,000;INFO ; 154,2.7179851525868218e-05,0.007503758912087853 2022-07-24 11:51:12,008;INFO ; 155,2.7416170048768072e-05,0.006811990509842912 2022-07-24 11:51:12,017;INFO ; 156,2.372441872656792e-05,0.00587491005236819 2022-07-24 11:51:12,026;INFO ; 157,2.5262065212203818e-05,0.00971219122205826 2022-07-24 11:51:12,035;INFO ; 158,3.913305082123144e-05,0.016133180354553654 2022-07-24 11:51:12,044;INFO ; 159,3.891995551550176e-05,0.015831211541128598 2022-07-24 11:51:12,053;INFO ; 160,3.573200348197358e-05,0.015047442822159206 2022-07-24 11:51:12,063;INFO ; 161,3.682229518171121e-05,0.02050725506375657 2022-07-24 11:51:12,074;INFO ; 162,4.517354193049645e-05,0.012878390656061394 2022-07-24 11:51:12,094;INFO ; 163,3.822158005786261e-05,0.015024739524085817 2022-07-24 11:51:12,103;INFO ; 164,5.0879463178146294e-05,0.012099810439944934 2022-07-24 11:51:12,112;INFO ; 165,3.600231900019293e-05,0.010819635003537541 2022-07-24 11:51:12,122;INFO ; 166,4.691181425878909e-05,0.015633055571306217 2022-07-24 11:51:12,132;INFO ; 167,3.894321146210978e-05,0.020171023653984606 2022-07-24 11:51:12,141;INFO ; 168,4.954192412305159e-05,0.009130649198162956 2022-07-24 11:51:12,150;INFO ; 169,4.324860465974839e-05,0.012240383714725939 2022-07-24 11:51:12,159;INFO ; 170,4.686870661703465e-05,0.023673703133263165 2022-07-24 11:51:12,187;INFO ; 171,3.851495251698333e-05,0.018908547056481862 2022-07-24 11:51:12,197;INFO ; 172,4.998490770602206e-05,0.021854779849020182 2022-07-24 11:51:12,207;INFO ; 173,4.4914520841539945e-05,0.04723985599718754 2022-07-24 11:51:12,215;INFO ; 174,5.213437818606532e-05,0.05247919069070059 2022-07-24 11:51:12,225;INFO ; 175,4.0948209261499325e-05,0.016402432693670182 2022-07-24 11:51:12,234;INFO ; 176,5.275372918971059e-05,0.022683342283082632 2022-07-24 11:51:12,243;INFO ; 177,5.151704935693328e-05,0.03834789433194787 2022-07-24 11:51:12,252;INFO ; 178,5.3432635849348854e-05,0.040653376975884954 2022-07-24 11:51:12,263;INFO ; 179,6.279500249642566e-05,0.07384950424829002 2022-07-24 11:51:12,285;INFO ; 180,7.474487636669693e-05,0.06851150296223131 2022-07-24 11:51:12,296;INFO ; 181,8.712938157133106e-05,0.19042480764342898 2022-07-24 11:51:12,306;INFO ; 182,8.481248220549155e-05,0.17545407087788722 2022-07-24 11:51:12,315;INFO ; 183,0.00011164958488746495,0.20512872377981392 2022-07-24 11:51:12,324;INFO ; 184,0.00010695238567053151,0.3540234706046404 2022-07-24 11:51:12,333;INFO ; 185,0.00011358401992997167,0.43207463757834913 2022-07-24 11:51:12,339;INFO ; 186,0.00010792354830557902,0.0005094346600599401 2022-07-24 11:51:12,351;INFO ; 187,7.421688325280352e-05,0.0010349292005082922 2022-07-24 11:51:12,361;INFO ; 188,5.7100642772090604e-05,0.0014034458899808747 2022-07-24 11:51:12,368;INFO ; 189,6.74638887319705e-05,0.0022702346655245247 2022-07-24 11:51:12,385;INFO ; 190,5.6927091463217234e-05,0.0008828624562021463 2022-07-24 11:51:12,398;INFO ; 191,5.007083754634334e-05,0.000979514555432412 2022-07-24 11:51:12,407;INFO ; 192,4.654076555663437e-05,0.0010329693037312356 2022-07-24 11:51:12,417;INFO ; 193,3.0254925408929234e-05,0.00043720477945430276 2022-07-24 11:51:12,427;INFO ; 194,3.436765325362148e-05,0.0009134535754153801 2022-07-24 11:51:12,437;INFO ; 195,2.9008849932845245e-05,0.001015378602318849 2022-07-24 11:51:12,447;INFO ; 196,2.9002810175183168e-05,0.0008816714197266042 2022-07-24 11:51:12,456;INFO ; 197,1.8405230513436055e-05,0.00035120590112300146 2022-07-24 11:51:12,464;INFO ; 198,1.0697460367110135e-05,0.000301647419201472 2022-07-24 11:51:12,473;INFO ; 199,1.1222771369917234e-05,0.00020414558860107687 2022-07-24 11:51:12,481;INFO ; 200,9.723542599737891e-06,0.0003576106178983242 2022-07-24 11:51:12,481;INFO ; bfw Assignment finished. 200 iterations and 9.723542599737891e-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 Out: .. code-block:: none 2022-07-24 11:51:12,558;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.583 seconds) .. _sphx_glr_download__auto_examples_plot_forecasting.py: .. only :: html .. container:: sphx-glr-footer :class: 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 `_