Binning and Destination Filtering
1. Overview
After BAMBAM builds a shortest-path search tree outward from a grid cell origin, raw tree branches must be translated into meaningful transportation accessibility metrics. The bambam output plugin (type = "bambam") governs how reached network locations are filtered, deduplicated, and binned before downstream plugins compute isochrones and opportunity counts.
Aggregate vs. Disaggregate Output Formats
format = "aggregate"(standard): Partitions reached destinations into cumulative intervals (bins) along a chosen state variable—most commonly travel time (trip_timeat 10, 20, 30, and 40 minutes), travel distance (trip_distance), energy consumption, or a custom state variable.format = "disaggregate": Skips binning and outputs reachable opportunities across the entire unbinned search tree.
Global vs. Modal Configuration (GlobalOrModal)
In the bambam output plugin, binning, destination_filter, isochrone_point_model, and isochrone_algorithm can each be specified as either:
type = "global": Applies the same setting to all travel modes (value = { ... }).type = "modal": Applies different settings per travel mode (values = { walk = ..., drive = ... }, with an optionalfallback). For example, you might bin walking trips at[5, 10, 15, 20]minutes while binning driving and transit trips at[10, 20, 30, 40]minutes, or use distance bins for walking and time bins for driving.
Destination Filtering (destination_filter)
Not every link or vertex traversed during a multimodal trip is a valid place to end the trip. For example, in a shared micromobility (gbfs) trip, a rider may be allowed to ride through a geofenced zone (ride_through_allowed = true) where parking is prohibited (ride_end_allowed = false). Similarly, custom traversal models may set a boolean state variable indicating whether the traveler is currently in a valid alighting state. Configuring a destination_filter ensures that only search tree branches satisfying those boolean predicates are counted as reachable destinations.
2. Setup
Configuring bambam Binning and Filtering in bambam.toml
In bambam.toml, the bambam output plugin must appear before the isochrone and opportunity output plugins so it can scaffold the bin ranges and destination filters on each result row:
[[plugin.output_plugins]]
type = "bambam"
format = "aggregate"
isochrone_format = "wkb"
opportunity_orientation = "destination_vertex_oriented"
# Global time binning: 10, 20, 30, and 40 minutes
binning.type = "global"
binning.value = { type = "time", feature = "trip_time", values = [10, 20, 30, 40], unit = "minutes" }
isochrone_point_model.type = "global"
isochrone_point_model.value = { type = "linestring_stride", stride = 100.0, distance_unit = "meters" }
isochrone_algorithm.type = "global"
isochrone_algorithm.value = { type = "concave_hull", concavity = 1.2, length_threshold = 0.0025, simplify_epsilon_latlon = 0.0003 }
Alternative Binning Configurations
-
Distance Binning (
type = "distance"): Group reached destinations by network travel distance (e.g., 1, 2, 5, and 10 miles):[plugin.output_plugins.binning] type = "global" value = { type = "distance", feature = "trip_distance", values = [1, 2, 5, 10], unit = "miles" } -
Energy Binning (
type = "energy"): When paired with a RouteE Compass powertrain traversal model, bin by energy expended (trip_energy):[plugin.output_plugins.binning] type = "global" value = { type = "energy", feature = "trip_energy", values = [1, 2, 3, 5], unit = "kilowatt_hours" } -
Modal Binning (
type = "modal"): Use finer time or distance bins for active modes and wider bins for motorized modes:[plugin.output_plugins.binning] type = "modal" values.walk = { type = "time", feature = "trip_time", values = [5, 10, 15, 20], unit = "minutes" } values.bike = { type = "time", feature = "trip_time", values = [10, 20, 30, 40], unit = "minutes" } values.drive = { type = "time", feature = "trip_time", values = [10, 20, 30, 40], unit = "minutes" } fallback = { type = "time", feature = "trip_time", values = [10, 20, 30, 40], unit = "minutes" }
Adding a Destination Filter (destination_filter)
To restrict destination collection to branches where a boolean state feature is true (or false when negate = true):
[plugin.output_plugins.destination_filter]
type = "global"
value = [
{ type = "boolean", feature = "valid_destination", negate = false }
]
Running BAMBAM
cd denver_buf
../rust/target/release/bambam \
--config-file bambam.toml \
--query-file ../query/denver_extent.json
3. What Happens
- Row Scaffolding (
bambamOutput Plugin):- For each completed search row, the
bambamoutput plugin inspectsrequest.trip_mode, resolves the activebinning,destination_filter, and isochrone settings for that mode, and writes them to the row’sinfometadata for downstream plugins (isochroneandopportunity).
- For each completed search row, the
- Destination Filtering & Multimodal Vertex Deduplication:
- When collecting destinations from the search tree, BAMBAM first discards the origin root node and any tree branch that fails a
destination_filterpredicate. - In a multimodal search (
multimodal_label = true), a single network vertex \(v\) may be reached by multiple mode sequences (for example,["walk"]arriving at 14 minutes and["walk", "bike"]arriving at 8 minutes). BAMBAM deduplicates destinations by vertex ID, keeping only the branch with the lowest accumulatedtotal_costat each vertex so opportunities at vertex \(v\) are never double-counted.
- When collecting destinations from the search tree, BAMBAM first discards the origin root node and any tree branch that fails a
- Cumulative Bin Assignment:
- From the configured bin upper bounds (e.g.,
values = [10, 20, 30, 40]), BAMBAM constructs cumulative intervals starting from zero: \([0, 10)\), \([0, 20)\), \([0, 30)\), and \([0, 40)\). - Each deduplicated destination branch is placed into every bin whose upper bound exceeds its state value (
trip_time,trip_distance, etc.), and stored underaggregate_opportunities.<bin_key>(e.g.,aggregate_opportunities.10,aggregate_opportunities.20, etc.).
- From the configured bin upper bounds (e.g.,