departure_model
agentevac.agents.departure_model
Departure decision rule for pre-evacuation agents.
An agent waits at its spawn edge until this module's should_depart_now function
returns True. The function implements a three-clause OR rule:
1. **Risk threshold** (``risk_threshold``):
The agent's estimated danger probability exceeds its personal threshold
``theta_r``. This is the primary, reactive trigger.
2. **Urgency decay** (``urgency_threshold``):
The urgency term ``gamma^elapsed_s * p_safe`` falls below ``theta_u``.
As time passes, the discount factor ``gamma`` (< 1) erodes the "stay safe"
signal so that an agent that has been waiting a long time will eventually
feel compelled to act — even if ``p_danger`` is still low. This captures
the real-world observation that people eventually evacuate out of a growing
general unease rather than a discrete danger trigger.
3. **Low-confidence precaution** (``low_confidence_precaution``):
If the agent is highly uncertain (``confidence < 0.15``) *and* the danger
probability has reached at least 60 % of ``theta_r``, it departs
pre-emptively. This prevents agents from staying frozen in high-entropy
situations where they should arguably err on the side of caution.
should_depart_now(agent_state, belief, psychology, sim_t_s, neighborhood_observation=None)
Evaluate whether an agent should depart from its spawn edge at the current tick.
Applies three departure clauses in priority order (first match wins):
1. risk_threshold : p_danger > theta_r
2. urgency_threshold : gamma^elapsed_s * p_safe < theta_u
3. low_confidence_precaution: confidence < 0.15 and
p_danger >= max(0.20, theta_r * 0.6)
4. neighbor_departure_activity: recent nearby departures raise social
departure pressure above the agent's trigger threshold while danger is
already non-trivial.
If none of the clauses fire, returns (False, "wait").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_state
|
AgentRuntimeState
|
The agent's runtime state (supplies profile parameters and creation time). |
required |
belief
|
Dict[str, Any]
|
Current Bayesian belief dict with keys "p_danger", "p_safe", etc. |
required |
psychology
|
Dict[str, Any]
|
Current psychology dict with key "confidence". |
required |
sim_t_s
|
float
|
Current simulation time in seconds. |
required |
neighborhood_observation
|
Optional[Dict[str, Any]]
|
Optional system-authored local departure observation. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
A |
str
|
"risk_threshold", "urgency_threshold", "low_confidence_precaution", |
Tuple[bool, str]
|
"neighbor_departure_activity", or "wait". |
Source code in agentevac/agents/departure_model.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |