a-b-street/abstreet · error
TODO: handle working and living in the same building
Error message
TODO: handle working and living in the same building
What it means
create_prole (used by proletariat_robot) builds a synthetic person from a home and work endpoint, but the case where a person's home and work are the same building is not yet implemented, so it deliberately fails with a TODO error. The code even suggests such a person would likely just stay near home.
Solutions
- Resample the work (or home) building when it equals the home building
- Skip or merge such individuals during population generation before calling create_prole
- Implement the TODO: treat the person as staying home / no commute trip
Example fix
// before
let person = create_prole(map, rng, home, work, ...)?;
// after
let work = if work == home { sample_other_building(map, rng, &home) } else { work };
let person = create_prole(map, rng, home, work, ...)?; Defensive patterns
Strategy: validation
Validate before calling
if home == work {
work = sample_distinct_building(map, rng, &home);
} Try / catch
match create_prole(map, rng, home, work, ...) {
Ok(p) => Some(p),
Err(e) if e.to_string().contains("same building") => None, // skip
Err(e) => return Err(e),
} Prevention
- Sample home and work from disjoint building sets
- Resample or skip individuals whose workplace equals their residence
- Handle the same-building case in your generator before calling create_prole
When it happens
Trigger: Generating a synthetic population where a sampled job and residence resolve to the identical building, e.g. dense mixed-use OSM areas or a small map where everyone works where they live.
Common situations: Small test maps with few buildings, OSM imports where shops with residences produce home==work matches, population generators that sample home and work independently without exclusion.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Some trip has negative departure time
- no path found
- Person ( ) has no trips at all
- Person ( ) starts two trips in the wrong order: then
- Person ( ) warps from to during adjacent trips
AI-assisted analysis of a-b-street/abstreet@0964f29315 (2026-09-13).
Data as JSON: /api/errors/282f39714707ffe4.
Report an issue: GitHub.
Appendix: source
Thrown at synthpop/src/make/activity_model.rs:212
prettyprint_usize(num_trips_passthru),
prettyprint_usize(num_trips - s.people.len()),
prettyprint_usize(residents.len()),
prettyprint_usize(workers.len()),
);
s
}
}
fn create_prole(
home: TripEndpoint,
work: TripEndpoint,
map: &Map,
rng: &mut XorShiftRng,
) -> Result<PersonSpec> {
if home == work {
// TODO: handle edge-case of working and living in the same building... maybe more likely
// to go for a walk later in the day or something
bail!("TODO: handle working and living in the same building");
}
let mode = match (&home, &work) {
// commuting entirely within map
(TripEndpoint::Building(home_bldg), TripEndpoint::Building(work_bldg)) => {
// Decide mode based on walking distance. If the buildings aren't connected,
// probably a bug in importing; just skip this person.
let dist = if let Some(path) = PathRequest::between_buildings(
map,
*home_bldg,
*work_bldg,
PathConstraints::Pedestrian,
)
.and_then(|req| map.pathfind(req).ok())
{
path.total_length()
} else {
bail!("no path found");View on GitHub (pinned to 0964f29315)