Comparing Model Ouputs

Comparing Model Ouputs#

In this example we show how to compare outputs across iterations or across models. Here we illustrate using two iterations from the same project, but thanks to the use of standardised KPIs, results can be compared across model years or even across cities.

sphinx_gallery_thumbnail_path = ‘../../examples/result_analysis/pax_in_network.png’

from pathlib import Path

from polaris.analyze.kpi_comparator import KpiComparator
from polaris.analyze.result_kpis import ResultKPIs
from polaris.runs.convergence.convergence_iteration import ConvergenceIteration
from polaris.runs.scenario_compression import ScenarioCompression
from polaris.utils.database.migration_manager import MigrationManager
from polaris.utils.database.standard_database import DatabaseType
project_dir = Path("/tmp/Bloomington")

iteration_3 = ConvergenceIteration.from_dir(project_dir / "Bloomington_iteration_3")
iteration_4 = ConvergenceIteration.from_dir(project_dir / "Bloomington_iteration_4")

# This is generally not needed unless you are analysing results from an older model
MigrationManager.upgrade(
    ScenarioCompression.maybe_extract(iteration_3.files.demand_db), DatabaseType.Demand, redo_triggers=False
)
MigrationManager.upgrade(
    ScenarioCompression.maybe_extract(iteration_4.files.demand_db), DatabaseType.Demand, redo_triggers=False
)

c = KpiComparator()
c.add_run(ResultKPIs.from_iteration(iteration_3), "A label (it3)")
c.add_run(ResultKPIs.from_iteration(iteration_4), "A diff label [it4]")
c.plot_everything()
  • plot compare iterations
  • Activity Start distribution
  • Trip Distance Calibration
  • Activity Generation Calibration, By Activity Type, By Person Type
  • Mode Share Calibration, Home-Based Work, Home-Based Other, Non Home-Based, Total
  • Timing Choice Calibration, HOME, RELIGIOUS, PERSONAL, SHOP_MAJOR, PICKUP, SHOP_OTHER, SERVICE, WORK_HOME, SCHOOL, LEISURE, SOCIAL, WORK_PART, ERRANDS, HEALTHCARE, EAT_OUT, WORK, TOTAL
  • Congestion Pricing Revenue
  • Runtime and Memory usage
  • plot compare iterations
  • Total, HBO, HBW, NHB
  • Gap (abs), Gap, Gap (abs), Gap
  • plot compare iterations
  • plot compare iterations
  • Skim change over time (min/max dashed, avg solid)
  • Demand, Wait time, IVTT
  • Boardings, Alightings
  • Trip length distribution
  • Proportion of Connected Vehicles within Fleet
  • VMT (millions), Speed (mi/h), Number of trips
  • plot compare iterations

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

Gallery generated by Sphinx-Gallery