agent_urban_planning.AgentResult¶
- class AgentResult(agent_id, weight, demographics, preferences, zone_utilities, zone_choice, equilibrium_price, commute_minutes, realized_utility, utility_vs_baseline=None, residence_zone='', workplace_zone='')[source]¶
Bases:
objectPer-agent record summarizing an agent’s outcome in one run.
Captures the agent’s demographics, declared preferences, the zone-by-zone utilities seen at equilibrium, the realized choice and utility, the commute time, and (when a baseline is provided) the welfare difference relative to that baseline. Both the legacy
zone_choicefield and the explicitresidence_zone/workplace_zonepair are populated; the legacy field equalsresidence_zone.- Variables:
agent_id – Stable agent identifier.
weight – Population share assigned to this type.
demographics – Flattened demographic snapshot (income, household size, etc.).
preferences – Dict with keys
alpha,beta,gamma,deltareflecting the agent’s recorded preference weights.zone_utilities – Per-zone utility evaluations.
zone_choice – Residence zone (legacy alias for
residence_zone).equilibrium_price – Price paid at the chosen residence zone.
commute_minutes – Realized commute time between residence and workplace.
realized_utility – Utility at the chosen pair.
utility_vs_baseline – Realized utility minus a baseline run’s utility, when a baseline is supplied.
Noneotherwise.residence_zone – Residence zone (matches
zone_choice).workplace_zone – Workplace zone. For Singapore scenarios equals
demographics['job_location']; for Berlin scenarios this is the engine’s joint-choice output.
- Parameters:
Examples
>>> import agent_urban_planning as aup >>> # Returned in SimulationResults.agent_results; see SimulationEngine.run().
- classmethod from_agent(agent, zone_utilities, zone_choice, equilibrium_price, commute_minutes, realized_utility, utility_vs_baseline=None, workplace_zone=None)[source]¶
Build an
AgentResultfrom anAgentplus market output.Convenience constructor that flattens the agent’s demographics and preferences into JSON-friendly dicts and fills in the residence/workplace fields from
zone_choiceand either an explicitworkplace_zoneoragent.job_location.- Parameters:
agent (
Agent) – SourceAgentwhose demographics are snapshotted.zone_utilities (
dict[str,float]) – Per-zone utility evaluations as seen by the agent at the equilibrium prices.zone_choice (
str) – The agent’s chosen residence zone.equilibrium_price (
float) – Equilibrium price at the chosen zone.commute_minutes (
float) – Realized commute time.realized_utility (
float) – Utility at the chosen residence and workplace.utility_vs_baseline (
Optional[float]) – Optional difference vs. a baseline run.workplace_zone (
Optional[str]) – Optional workplace zone override; defaults toagent.job_location.
- Return type:
- Returns:
A new
AgentResultpopulated from the inputs.
Examples
>>> import agent_urban_planning as aup >>> # Used internally by SimulationEngine.run() — see that method.