Cutting a Scenario

Cutting a scenario#

Use a reduced scenario when your study covers part of a larger network. This tutorial keeps the roads in the study area, cuts routes that pass through it, and removes references to roads that were left out. Keep the original files so you can repeat the cut for a different area.

Cut the network#

Select roads in Netedit#

  1. Open the full network. If you want to cut its additional objects at the same time, load them with File > Additionals and Shapes > Load Additionals.
  2. Switch to selection mode and enable Auto-select junctions. Hold Shift and drag a rectangle around the roads you want to keep. Check the selection and include the junctions and connections needed by the retained routes.
  3. Click Reduce. Save the network as cut.net.xml. If you loaded additional objects, save the remaining ones to a separate file.

The Netedit reduction example explains how the junction selection affects the remaining connections.

Select roads with netconvert#

Use edge IDs for a repeatable cut. This example keeps two eastbound edges in the middle row of a three-by-three grid.

netgenerate --grid --grid.number 3 --grid.length 100 -o full.net.xml
netconvert --sumo-net-file full.net.xml --keep-edges.explicit A1B1,B1C1 -o cut.net.xml

For a larger list, use --keep-edges.input-file with one edge ID per line. To exclude a small list of roads from an otherwise complete network, use --remove-edges.explicit. For an area, use --keep-edges.in-boundary with Cartesian coordinates or --keep-edges.in-geo-boundary with longitude and latitude on a georeferenced network. Check the edges and junctions along the new boundary before cutting demand. netconvert edge removal options

Cut the routes#

Start with routed demand. If your full scenario contains origin-destination trips, route them in the full network first. Save the following example as full.rou.xml.

<routes>
    <vehicle id="through" depart="0">
        <route edges="A0A1 A1B1 B1C1 C1C2"/>
    </vehicle>
    <vehicle id="outside" depart="1">
        <route edges="A0B0 B0C0"/>
    </vehicle>
</routes>

Run cutRoutes.py from the directory with the scenario files. The script uses the original network to estimate when a vehicle reaches the study area. If the input route contains recorded edge exit times, it uses those times.

python "$SUMO_HOME/tools/route/cutRoutes.py" cut.net.xml full.rou.xml \
    --orig-net full.net.xml --routes-output cut.rou.xml

The through vehicle keeps the route A1B1 B1C1. The outside vehicle is omitted. If the same route leaves and later re-enters the area, choose whether to keep its separate sections with --disconnected-action. Review the script's counts of disconnected and broken routes.

Keep additional objects on the retained roads#

For detectors and other lane-based objects, either load the files before using Reduce or open the reduced network and load the original files. Netedit reports objects that reference removed roads or lanes and discards them on load. Review the messages and save the retained objects under new names. Check any detector that used several lanes or edges and confirm that its remaining references still represent the measurement you want.

To try stop filtering, save the following as full-stops.add.xml.

<additional>
    <busStop id="outsideStop" lane="A0A1_0" startPos="20" endPos="30"/>
    <busStop id="centreStop" lane="A1B1_0" startPos="20" endPos="30"/>
    <busStop id="eastStop" lane="B1C1_0" startPos="20" endPos="30"/>
</additional>

Pass the additional file to the route cutter. It can use the stop locations when trimming the demand and export the stops on the retained edges.

python "$SUMO_HOME/tools/route/cutRoutes.py" cut.net.xml full.rou.xml \
    --orig-net full.net.xml --routes-output cut.rou.xml \
    --additional-input full-stops.add.xml --stops-output cut-stops.add.xml

Cut public transport lines#

If you have a netconvert public transport line file, you can pass it and the stop file to netconvert during the network cut. Save the following example as full-lines.xml.

<ptLines>
    <ptLine id="route1" name="Bus 1" line="1" type="bus" period="120">
        <route edges="A0A1 A1B1 B1C1 C1C2"/>
        <busStop id="outsideStop"/>
        <busStop id="centreStop"/>
        <busStop id="eastStop"/>
    </ptLine>
</ptLines>

You can also post-process against an existing cut network. Use --ignore-errors when the input files refer to edges outside that network. Read the reported omissions before using the output.

netconvert --sumo-net-file cut.net.xml --ptstop-files full-stops.add.xml \
    --ptline-files full-lines.xml --ptstop-output converted-stops.add.xml \
    --ptline-output cut-lines.xml --ignore-errors -o checked.net.xml

The line keeps the two middle-row edges and their stops. If your public transport services are already stored as SUMO vehicle flows, use --pt-input and --pt-output on cutRoutes.py to trim the flows. Use one set of stop definitions when you run the scenario.

Run the reduced scenario#

sumo -n cut.net.xml -r cut.rou.xml -a cut-stops.add.xml --tripinfo-output trips.xml

The example produces one finished trip. Add cleaned detector files to --additional-files and open the same inputs in sumo-gui to check departures, arrivals, and stop locations at the boundary.