a-b-street/abstreet · error
impossible to start from a non-sane situation.
Error message
impossible to start from a non-sane situation.
What it means
The pandemic model's start() initializes each person's state by pattern-matching on an expected initial variant; only the sane initial state (with its event/time) can begin the simulation. Any other variant at startup — meaning the model was seeded with an impossible or uninitialized person state — bails with this fixed message. It is an internal invariant check on the SIR-state machine's starting conditions.
Solutions
- Ensure all persons are initialized to the sane initial state (event plus sampled time) before calling start.
- Check initialization code that constructs the initial person states for gaps/uninitialized variants.
- If a new initial state was added, extend the match in start() to handle it.
- Try a different RNG seed to confirm whether the failure is seed-specific or structural.
Example fix
// before: person starts in an exotic variant let init = Self::Infected; // not handled // after let init = Self::Sane((initial_event, now));
Defensive patterns
Strategy: try-catch
Type guard
fn starts_sane(s: &PersonState) -> bool {
matches!(s, PersonState::Sane(_))
} Try / catch
match sim.start(now, &mut rng) {
Err(e) if e.to_string().contains("non-sane situation") => {
// re-initialize all persons to Sane((event, time)) and retry
}
other => other?,
} Prevention
- Always seed every person with the sane initial state before start().
- Extend start()'s match when adding new initial-state variants.
- Cover initialization across several RNG seeds in tests to catch uncovered branches.
When it happens
Trigger: Calling Simulator::start (sim/src/pandemic/mod.rs:327, invoked by initialize) when a person's initial state is anything other than the expected Sane((event, time)) variant — e.g. the RNG/seed produced a state outside the handled match arms, or initialization constructed persons incorrectly.
Common situations: Custom initial-condition modifications to the pandemic model, mismatched state enum after refactoring, or seeded RNG paths not covered by the initialization logic.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Bad TimeInterval ..
- Bad DistanceInterval
- Can't spawn at ; it isn't that long
- Can't start at ; it's the edge of a border already
- A trip just walking from
AI-assisted analysis of a-b-street/abstreet@0964f29315 (2026-09-13).
Data as JSON: /api/errors/1bc9654d6b2f9469.
Report an issue: GitHub.
Appendix: source
Thrown at sim/src/pandemic/mod.rs:327
}
}
Self::Recovered(t) => Some(Self::Recovered(t)),
Self::Dead(t) => Some(Self::Dead(t)),
}
}
// TODO: not sure if we want an option here... I guess here we want because we could have
pub fn start(self, now: AnyTime, overlap: Duration, rng: &mut XorShiftRng) -> Result<Self> {
// rewrite this part with it
match self {
Self::Sane((ev, t)) => {
if overlap >= Self::get_time_exp(State::R_0 / State::T_INF, rng) {
Ok(ev.next(now, rng))
} else {
Ok(Self::Sane((ev, t)))
}
}
_ => bail!("impossible to start from a non-sane situation.",),
}
}
}
View on GitHub (pinned to 0964f29315)