Project Scenarios#

In this example, we show how to use AequilibraE’s scenario system to manage multiple model variants within a single project, using different example networks to demonstrate scenario isolation and management.

# Imports
from uuid import uuid4
from tempfile import gettempdir
from pathlib import Path

from aequilibrae.utils.create_example import create_example
from aequilibrae import TrafficAssignment, TrafficClass
# We create the example project inside our temp folder.
fldr = Path(gettempdir()) / uuid4().hex
project = create_example(fldr, "sioux_falls")
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path

Working with scenarios#

Let’s first see what scenarios exist in our project

Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
scenario_name description
0 root The default, and root, scenario for an Aequilb...


The root scenario is always present and represents the base model. Let’s examine the current scenario’s network

print(f"Current scenario network has {len(project.network.links.data)} links")
print(f"Current scenario network has {len(project.network.nodes.data)} nodes")
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Current scenario network has 76 links
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Current scenario network has 24 nodes

Creating new scenarios#

We can create empty scenarios or clone existing ones

# Create an empty scenario to manually populate with a future/different network
project.create_empty_scenario("test_modifications", "Scenario for testing network modifications")

# Clone the root scenario to preserve the original network
project.clone_scenario("limited_capacity", "Testing different assignment parameters")
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path

Let’s see our updated scenario list

Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
scenario_name description
0 root The default, and root, scenario for an Aequilb...
1 test_modifications Scenario for testing network modifications
2 limited_capacity Testing different assignment parameters


Switching between scenarios#

Each scenario operates independently with its own data

# Switch to the cloned scenario
project.use_scenario("limited_capacity")
print(f"This scenario has {len(project.network.links.data)} links")

# Modify the network
with project.db_connection as conn:
    conn.execute("UPDATE links SET capacity_ab=capacity_ab/2, capacity_ba=capacity_ba/2 WHERE link_id > 20 AND link_id < 50")
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
This scenario has 76 links
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path

Let’s perform a traffic assignment in this scenario with lowered capacity

# Build the network graph
project.network.build_graphs(fields=["distance", "capacity_ab", "capacity_ba"], modes=["c"])
graph = project.network.graphs["c"]
graph.set_graph("distance")
graph.set_blocked_centroid_flows(False)

# Get the demand matrix
mat = project.matrices.get_matrix("demand_omx")
mat.computational_view()

# Create traffic assignment with alternative parameters
assigclass = TrafficClass("car", graph, mat)
assignment = TrafficAssignment(project)
assignment.add_class(assigclass)
assignment.set_vdf("BPR")

assignment.set_vdf_parameters({"alpha": 0.15, "beta": 4.0})
assignment.set_capacity_field("capacity")
assignment.set_time_field("distance")
assignment.max_iter = 10
assignment.set_algorithm("msa")

assignment.execute()

# Save results specific to this scenario
assignment.save_results("alternative_assignment")

print(f"Assignment completed. Total flow: {assigclass.results.total_link_loads.sum():.2f}")
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
/home/runner/work/aequilibrae/aequilibrae/aequilibrae/paths/graph.py:218: ChainedAssignmentError: A value is being set on a copy of a DataFrame or Series through chained assignment.
Such chained assignment never works to update the original DataFrame or Series, because the intermediate object on which we are setting values always behaves as a copy (due to Copy-on-Write).

Try using '.loc[row_indexer, col_indexer] = value' instead, to perform the assignment in a single step.

See the documentation for a more detailed explanation: https://pandas.pydata.org/pandas-docs/stable/user_guide/copy_on_write.html#chained-assignment
  build_compressed_graph(self, remove_dead_ends)

car                                               :   0%|          | 0/24 [00:00<?, ?it/s]
Equilibrium Assignment                            :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car               :  10%|█         | 1/10 [00:00<00:00, 38130.04it/s]
All-or-Nothing - Traffic Class: car               :  10%|█         | 1/10 [00:00<00:00, 9341.43it/s]
All-or-Nothing - Traffic Class: car               :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 0/24 :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 10/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 20/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 24/24:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment - Iteration: 1/10 - RGap: inf:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment                            :  20%|██        | 2/10 [00:00<00:00, 87.85it/s]
All-or-Nothing - Traffic Class: car               :  20%|██        | 2/10 [00:00<00:00, 87.50it/s]
All-or-Nothing - Traffic Class: car               :  20%|██        | 2/10 [00:00<00:00, 87.20it/s]
All-or-Nothing - Traffic Class: car               :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 0/24 :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 10/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 20/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 24/24:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment - Iteration: 2/10 - RGap: 0.717655:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment                            :  30%|███       | 3/10 [00:00<00:00, 105.99it/s]
All-or-Nothing - Traffic Class: car               :  30%|███       | 3/10 [00:00<00:00, 105.58it/s]
All-or-Nothing - Traffic Class: car               :  30%|███       | 3/10 [00:00<00:00, 105.28it/s]
All-or-Nothing - Traffic Class: car               :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 0/24 :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 10/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 20/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 24/24:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment - Iteration: 3/10 - RGap: 0.943093:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment                            :  40%|████      | 4/10 [00:00<00:00, 110.75it/s]
All-or-Nothing - Traffic Class: car               :  40%|████      | 4/10 [00:00<00:00, 110.49it/s]
All-or-Nothing - Traffic Class: car               :  40%|████      | 4/10 [00:00<00:00, 110.27it/s]
All-or-Nothing - Traffic Class: car               :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 0/24 :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 10/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 20/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 24/24:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment - Iteration: 4/10 - RGap: 0.750474:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment                            :  50%|█████     | 5/10 [00:00<00:00, 275.76it/s]
All-or-Nothing - Traffic Class: car               :  50%|█████     | 5/10 [00:00<00:00, 274.54it/s]
All-or-Nothing - Traffic Class: car               :  50%|█████     | 5/10 [00:00<00:00, 273.40it/s]
All-or-Nothing - Traffic Class: car               :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 0/24 :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 10/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 20/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 24/24:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment - Iteration: 5/10 - RGap: 0.688544:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment                            :  60%|██████    | 6/10 [00:00<00:00, 561.74it/s]
All-or-Nothing - Traffic Class: car               :  60%|██████    | 6/10 [00:00<00:00, 557.64it/s]
All-or-Nothing - Traffic Class: car               :  60%|██████    | 6/10 [00:00<00:00, 553.83it/s]
All-or-Nothing - Traffic Class: car               :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 0/24 :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 10/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 20/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 24/24:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment - Iteration: 6/10 - RGap: 0.556378:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment                            :  70%|███████   | 7/10 [00:00<00:00, 443.35it/s]
All-or-Nothing - Traffic Class: car               :  70%|███████   | 7/10 [00:00<00:00, 441.12it/s]
All-or-Nothing - Traffic Class: car               :  70%|███████   | 7/10 [00:00<00:00, 439.10it/s]
All-or-Nothing - Traffic Class: car               :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 0/24 :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 10/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 20/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 24/24:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment - Iteration: 7/10 - RGap: 0.418738:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment                            :  80%|████████  | 8/10 [00:00<00:00, 457.58it/s]
All-or-Nothing - Traffic Class: car               :  80%|████████  | 8/10 [00:00<00:00, 455.53it/s]
All-or-Nothing - Traffic Class: car               :  80%|████████  | 8/10 [00:00<00:00, 453.62it/s]
All-or-Nothing - Traffic Class: car               :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 0/24 :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 10/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 20/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 24/24:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment - Iteration: 8/10 - RGap: 0.262796:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment                            :  90%|█████████ | 9/10 [00:00<00:00, 498.72it/s]
All-or-Nothing - Traffic Class: car               :  90%|█████████ | 9/10 [00:00<00:00, 496.52it/s]
All-or-Nothing - Traffic Class: car               :  90%|█████████ | 9/10 [00:00<00:00, 494.54it/s]
All-or-Nothing - Traffic Class: car               :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 0/24 :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 10/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 20/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 24/24:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment - Iteration: 9/10 - RGap: 0.199138:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment                            : 100%|██████████| 10/10 [00:00<00:00, 376.79it/s]
All-or-Nothing - Traffic Class: car               : 100%|██████████| 10/10 [00:00<00:00, 375.71it/s]
All-or-Nothing - Traffic Class: car               : 100%|██████████| 10/10 [00:00<00:00, 374.67it/s]
All-or-Nothing - Traffic Class: car               :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 0/24 :   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 10/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 20/24:   0%|          | 0/10 [00:00<?, ?it/s]
All-or-Nothing - Traffic Class: car - Zones: 24/24:   0%|          | 0/10 [00:00<?, ?it/s]
Equilibrium Assignment - Iteration: 10/10 - RGap: 0.174405:   0%|          | 0/10 [00:00<?, ?it/s]

Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Assignment completed. Total flow: 1136690.00

Switch to empty scenario for modifications

project.use_scenario("test_modifications")
print(f"Empty scenario has {len(project.network.links.data)} links")

# This scenario starts with an empty network, suitable for building from scratch
# or testing specific network configurations
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Empty scenario has 0 links

Scenario isolation demonstration#

Let’s switch back to root and show that scenarios are isolated

project.use_scenario("root")
print(f"Back to root scenario with {len(project.network.links.data)} links")

# Check results - only root scenario results should be visible
root_results = project.results.list()
print(f"Root scenario has {len(root_results)} result tables")

# Switch to alternative scenario and check its results
project.use_scenario("limited_capacity")
alt_results = project.results.list()
print(f"Alternative scenario has {len(alt_results)} result tables")

# Each scenario maintains its own results database
alternative_assignment_exists = "alternative_assignment" in alt_results["table_name"].values
print(f"Alternative assignment result exists in this scenario: {alternative_assignment_exists}")
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Back to root scenario with 76 links
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Root scenario has 0 result tables
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Alternative scenario has 1 result tables
Alternative assignment result exists in this scenario: True

Best practices for scenario management#

# Always return to root when doing project-wide operations
project.use_scenario("root")

# List scenarios for reference
final_scenarios = project.list_scenarios()
print("\nFinal scenario summary:")
for _, scenario in final_scenarios.iterrows():
    project.use_scenario(scenario['scenario_name'])
    link_count = len(project.network.links.data)
    result_count = len(project.results.list())
    print(f"  {scenario['scenario_name']}: {link_count} links, {result_count} results")
    print(f"    Description: {scenario['description']}")
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path

Final scenario summary:
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
  root: 76 links, 0 results
    Description: The default, and root, scenario for an AequilbraE project. The name "root" is treat as special case.
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
  test_modifications: 0 links, 0 results
    Description: Scenario for testing network modifications
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
  limited_capacity: 76 links, 1 results
    Description: Testing different assignment parameters

Clean up

project.use_scenario("root")  # Always end on root scenario
mat.close()
project.close()
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path
Environment variable 'AEQ_SPATIALITE_DIR' was provided (C:\path\to\existing\download), but mod_spatialite could not be loaded from this directory. Trying system path

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

Gallery generated by Sphinx-Gallery