Skip to content

Commit e10e9ae

Browse files
Copilotdan-mccabe
andauthored
Update documentation to describe default route filtering behavior
- Add "Route filtering" subsection to prediction.md explaining trip-level vs block-level filtering, when each is used, and how to control it - Update code examples in prediction.md to reflect new defaults (deadhead is now opt-in, not default) - Add explanation in index.md quickstart about filtering modes with examples showing both trip-level and block-level usage Agent-Logs-Url: https://github.com/NatLabRockies/routee-transit/sessions/2ff76f0b-42a6-4a2d-89df-ecd5324791de Co-authored-by: dan-mccabe <25916826+dan-mccabe@users.noreply.github.com>
1 parent 94e71c6 commit e10e9ae

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

docs/index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ predictor.run(
3434
)
3535
```
3636

37+
By default, route filtering works at the **trip level**, so individual trips on the requested routes are always included even if their block also serves other routes. If you enable deadhead trip estimation, filtering automatically switches to **block level** to ensure complete blocks (see [](prediction) for details):
38+
39+
```python
40+
predictor.run(
41+
date="2023/08/02",
42+
routes=["806", "807"],
43+
add_mid_block_deadhead=True,
44+
add_depot_deadhead=True,
45+
)
46+
```
47+
3748
For a full example, see [](examples/Utah_Transit_Agency_example).
3849

3950
## Available Models

docs/prediction.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,25 @@ The full workflow proceeds in four stages:
1313

1414
RouteE-Transit reads a standard GTFS feed directory and loads trips along with their shape traces, stop locations, and stop times. Users can optionally filter to a specific service date and/or a subset of routes. The shape traces and scheduled stop times are used downstream to estimate average speed and distance at the road link level.
1515

16+
### Route filtering
17+
18+
By default, route filtering is **trip-level**: only trips whose `route_short_name` appears in the `routes` list are included, regardless of what other routes share the same GTFS block. This gives the most intuitive results, especially for agencies where interlining is common (e.g., a bus block might serve both route 5 and route 21).
19+
20+
When deadhead trips are requested (`add_mid_block_deadhead=True` or `add_depot_deadhead=True`), filtering automatically switches to **block-level** mode. In block-level mode, entire blocks are excluded if *any* trip in the block belongs to a route not in the requested set. This is necessary because deadhead estimation requires complete blocks. If block-level filtering removes all trips but trip-level filtering would have kept some, the error message will explain this and suggest alternatives (either disabling deadhead or adding the additional interlined routes to the `routes` list).
21+
22+
When using `filter_trips()` directly, you can control this behavior with the `use_block_filter` parameter:
23+
24+
```python
25+
predictor.load_gtfs_data()
26+
27+
# Trip-level filtering (default) — individual trips on route "5" are
28+
# always kept, even if their block also serves route "21"
29+
predictor.filter_trips(routes=["5"])
30+
31+
# Block-level filtering — only blocks that exclusively serve route "5"
32+
predictor.filter_trips(routes=["5"], use_block_filter=True)
33+
```
34+
1635
See [](data:gtfs-reqs) for the full list of required GTFS files and fields.
1736

1837
## 2) Deadhead Trip Inference
@@ -77,6 +96,15 @@ predictor = GTFSEnergyPredictor(
7796
)
7897

7998
# Option 1: Use the convenience method (recommended)
99+
# By default, only revenue trips are included (no deadhead).
100+
trip_results = predictor.run(
101+
date="2023/08/02",
102+
routes=["205"],
103+
)
104+
105+
# Option 2: Include deadhead trips and HVAC impacts
106+
# When deadhead is enabled with route filtering, block-level filtering
107+
# is used automatically to ensure complete blocks.
80108
trip_results = predictor.run(
81109
date="2023/08/02",
82110
routes=["205"],
@@ -85,7 +113,7 @@ trip_results = predictor.run(
85113
add_hvac=True,
86114
)
87115

88-
# Option 2: Step-by-step processing for more control
116+
# Option 3: Step-by-step processing for more control
89117
predictor.load_gtfs_data()
90118
predictor.filter_trips(date="2023/08/02", routes=["205"])
91119
predictor.add_mid_block_deadhead() # Between-trip deadhead

0 commit comments

Comments
 (0)