agent_urban_planning.compute_metrics¶
- compute_metrics(population, environment, allocations, prices, long_commute_threshold=60.0, affordability_threshold=0.3, market_converged=True, market_convergence_metric=0.0, wages=None)[source]¶
Compute aggregate welfare metrics from per-agent allocations.
Walks the population, looks up each agent’s chosen zone and route, and aggregates weighted means, the Gini coefficient, Rawlsian extremes, commute statistics, affordability share, facility utilization, and per-zone population/employment/wage tables.
- Parameters:
population (
AgentPopulation) – The simulatedAgentPopulation.environment (
Environment) – TheEnvironmentused by the simulation.allocations (
dict[int,ZoneChoice]) – Dict mappingagent_idto theZoneChoiceproduced by the market clearer.prices (
dict[str,float]) – Mappingzone -> equilibrium price.long_commute_threshold (
float) – Minutes threshold for thelong_commute_shareindicator. Defaults to60.0.affordability_threshold (
float) – Price/income ratio above which an agent’s housing counts as unaffordable. Defaults to0.30.market_converged (
bool) – Whether the upstream market clearer reached convergence. Recorded in the result.market_convergence_metric (
float) – Final residual to record.wages (
Optional[dict[str,float]]) – Optionalzone -> wagemapping (Ahlfeldt scenarios).
- Return type:
- Returns:
A
WelfareMetricsdescribing the run’s welfare outcome.
Examples
>>> import agent_urban_planning as aup >>> # metrics = aup.compute_metrics(population, env, allocations, prices) >>> # metrics.gini_coefficient