Evolving Readable Mobility Simulators from Aggregate Statistics Alone

Phone networks produce the best available record of how whole cities move. Privacy rules mean that record is almost always released only as aggregates: counts of people per grid cell per half hour, and flows between zones. Planners and epidemiologists still need generators, meaning models that produce plausible individual movements they can run forward under new conditions. Today that leaves two poor options. One is a hand-written parametric model with a few tuned knobs, which is readable but rigid. The other is a deep generative model trained on individual trajectories, which fits well but is a black box and needs exactly the individual data that privacy rules withhold. We propose a third option. A large language model writes a small, readable Python program that simulates people moving on the grid. We run that program, compare its aggregate output to the released aggregates, and hand the model the discrepancies as feedback. Over many rounds the program is rewritten and evolves toward one that reproduces the city's statistics.

The idea joins two lines of work that have not met. Iterative code refinement, where a model repeatedly edits a program using what happens when it runs, has so far been driven by compiler errors, unit tests, or runtime profiles. Mobility modeling has aggregate data but no way to search over model structure. Our bet is that the loop's only view of the data is a handful of aggregate queries. That gives three things together: an auditable model, compatibility with privacy-protected releases, and generators whose explicit behavioral rules transfer to conditions they were not fit on. The hard part is not getting the loop to run. It is stopping the loop from gaming the statistics it is shown. The proposal is built around measuring and controlling that.

Core Claim

We claim the following. A generator program evolved by a language model, with feedback taken only from aggregate statistics, will match held-out aggregate statistics, and a held-out emergency period, better than a fixed parametric mobility model tuned with the same evaluation budget. It will also come close to a trajectory-trained diffusion model in distribution while generalizing better under shift. Two ingredients carry the claim: statistical divergence as the execution signal, and search over program structure rather than over parameters. The ablations below isolate each one.

The closest prior work does something different. MobiVerse uses a language model to rewrite individual agents' daily schedules when a road closes, feeding congestion back from the SUMO traffic simulator. Its simulator code never changes, and its population comes from a fixed travel survey rather than phone data. LLMob has language-model "residents" generate activity sequences, critiqued by text-only self-consistency against check-in data. It writes no executable code and is not calibrated to aggregate flows. LASER turns driving requirements into scenario scripts for the CARLA driving simulator, but those scripts are corrected by hand (3.18% of characters edited) and describe vehicle maneuvers, not city-scale movement. GenOnet and Rezazadeh et al. do refine simulator code in a loop, but the code models radio-network protocols judged on throughput, not human movement judged against population data. None of these uses population-level distributional error as the signal that tells the code-writing model what to fix.

Research Program

The method comes from evolutionary program search. A2DEPT keeps candidate algorithms in a tree. It applies three kinds of language-model edits (small parameter tweaks, large rewrites, and crossover that merges two programs) and picks parents by simulated annealing. It also repairs missing imports before running anything, and it cut optimality gaps on hard routing and scheduling problems by 9.8% relative to earlier LLM heuristic-design methods. We reuse this search machinery with one key difference in the objective. A2DEPT's objective is exact and cheap to trust. Ours is a noisy statistical fit to data that is itself a biased sample, so the main danger is overfitting to the feedback rather than getting stuck.

Every candidate implements a fixed interface. Its input is the grid, the 85-dimensional per-cell point-of-interest vectors, and a random seed. Its output is a synthetic population's cell-by-half-hour visit sequences. Because the program is one small file behind a fixed interface, the "partial migration" failure that A2DEPT documents cannot arise. That failure is the model changing a data structure in one module and forgetting another. We also expect evolutionary branching to avoid the plateau after two to four rounds that Yan et al. report for linear compiler-feedback loops. The seed population comprises a random-walk program, a gravity-style program (trips weighted by attractiveness and decaying with distance), and an explore-or-return program (each person either visits a new place or goes back to one they visited before).

Candidates are run and scored against aggregates computed from the real data. We use a fixed set of shown statistics: the cell-by-time occupancy distribution, a zone-level origin-destination matrix, and the trip-distance histogram. We write the score as

$$ S(p) = \sum_{k \in \mathcal{K}_{\text{shown}}} w_k \, D_k\big(A_k(p), A_k^{\text{real}}\big), $$

where $p$ is a candidate program, $A_k(p)$ is the $k$-th aggregate statistic of its synthetic output, $A_k^{\text{real}}$ is the same statistic from the data, $D_k$ is a divergence (Jensen-Shannon distance for distributions, normalized error for matrices), and $w_k$ are fixed weights. The model receives the scalar score together with a compact diagnostic report, for example "morning inflow to commercial cells is 30% too low" or "trip-length tail is too heavy." This report plays the role a stack trace plays in ordinary code repair.

A second, disjoint set of statistics is never shown to the loop. It includes radius of gyration (how far each person typically ranges from their center of activity), the number of distinct cells visited per person per day, return-visit regularity, and occupancy at 1 km aggregation. We use it only to select the final program and to measure how much the search has gamed the shown statistics.

The data sets a limit on what we can claim. Nonrepresentativeness of Human Mobility Data found that phone-based travelers over-represent young adult men (59% aged 20–39 against 36% in the census), and that an epidemic model fed these data mis-estimated peak infections nearly threefold. Our generators will therefore reproduce the phone panel's city, not the census city. The benchmark data carries no demographics, so we do not claim to correct this bias. We only note that an explicit program makes the population weights visible and editable, which a diffusion model's weights are not.

A second strand follows from the fact that the loop touches data only through aggregate queries. It is naturally suited to privacy-protected release. Differentially Private Multivariate Time Series Forecasting found that noise injected during training preserves forecasting utility far better than noise added to raw inputs. It also found that private models degrade at anomalous peaks. Our setting differs: each round of the loop is an additional release that consumes part of the privacy budget. We therefore study how Gaussian noise on the shown statistics, with the budget split across rounds, changes which programs survive selection.

Baselines

The naive reference point is a marginal replay generator. It draws each synthetic person's cell at each half hour independently from the observed occupancy distribution for that time slot. It matches occupancy by construction and has no individual-level structure. Any evolved program must beat it on the held-out individual-level statistics, or the loop has learned nothing beyond copying marginals.

The strongest competitor on our specific question is a fixed-structure parametric model with tuned parameters. We take the best of the three seed programs and search its parameters with Bayesian optimization, a standard method that picks the next setting to try based on a model of previous results, which is how such models are calibrated in practice. For fairness it uses the identical objective $S$, the identical number of simulator runs (we plan 2,000), and the same held-out selection rule. Beating it means lower held-out divergence on at least three of the four held-out statistics and on the emergency-period test, averaged over five search seeds with non-overlapping confidence intervals. No reported result was found on Lacuna for any parametric mobility model on YJMob100K, so we run this baseline ourselves.

The strongest existing learned generator is DiffTraj, a diffusion model, meaning a generator trained to turn random noise step by step into realistic trajectories. It is trained directly on individual trajectories, which is strictly more data access than our loop receives. DiffTraj reports a density error of 0.0055 on Chengdu and 0.0126 on Xi'an, along with pattern scores of 0.823 and 0.764. We found no reported DiffTraj result on YJMob100K on Lacuna. We will therefore retrain it on YJMob100K's normal-period trajectories with its published architecture and a tuning budget comparable to our search compute. We will also reproduce its Chengdu setting to check our metric implementation against the reported 0.0055.

For the language-model generator, LLMob reports daily-activity divergence one half to one third that of DiffTraj and a trajectory-imitation baseline on Tokyo and Osaka check-ins. It gives no absolute value in our file, so it serves as a qualitative reference and not a numeric target.

Four ablations isolate the proposal's ingredients. A single-shot ablation takes the best of 2,000 independently sampled programs, testing whether iteration matters at all. An execution-only loop repairs crashes and interface violations but never sees $S$. This separates statistical feedback from ordinary code repair of the kind OpenCodeInterpreter uses, where execution feedback raised HumanEval pass@1 from 79.3 to 82.9. A parameter-only loop restricts the model to editing numeric constants, separating structure search from language-model-driven tuning. A no-holdout variant selects on shown statistics alone, to measure how much gaming held-out selection prevents.

Why not just…?

Why not just tune a gravity or explore-and-return model and skip code generation? This is the real threat, and we treat it as the primary comparison rather than a straw man. The argument for structure search is indirect. A Bimodal Model to Estimate Dynamic Metropolitan Population found that the relation between phone counts and true population follows two regimes, and that modeling both cut error by 30% against a single power law. This is exactly the kind of functional-form change that parameter tuning inside a fixed model cannot find. MobiVerse also describes classical activity models as rigid under shocks. Neither is direct evidence for our setting. If the budget-matched Bayesian-optimization baseline ties the evolved programs, we will report that plainly. We would then narrow the contribution to using the language model as a proposer of a few candidate structures, each calibrated conventionally.

Why not just train DiffTraj on the trajectories? Where individual trajectories are available and only in-distribution fit matters, DiffTraj may well win, and we expect it might on normal days. Our case rests on three conditions under which it cannot be used or struggles. First, it needs individual trajectories, which aggregate-only releases do not provide. Second, it offers no readable rules; its authors describe it as a black box. Third, according to LLMob's analysis, deep coordinate models do not adapt to regime shifts without retraining. The emergency-period test in YJMob100K measures that third point directly.

Why not just ask a strong model for a mobility simulator once? The single-shot ablation answers this at matched sample count. Prior evidence points the same way. A2DEPT reports that free-form algorithm code without a repair loop crashes unpredictably, and LearnAct, whose agents rewrite their own action functions after failures, reached 72.2% on AlfWorld against 54.7% for a reflection-based agent. What those papers do not show is that statistical feedback, and not just crash repair, is what helps. That is why we include the execution-only loop.

Why not just reweight the phone data to census demographics first? Reweighting is the right fix for the bias problem, but it needs demographic labels that YJMob100K does not have. It is also complementary rather than competing: reweighted aggregates would simply become the target $A^{\text{real}}$.

Proposed Experiments

The main benchmark is YJMob100K. It contains 100,000 anonymized people over 75 normal days and 25,000 over 15 emergency days, on 500 m cells and 30-minute bins, with point-of-interest vectors, and its occupancy correlates with census population at 0.781 at 1 km resolution. We evolve on the first 60 normal days, select on held-out statistics from days 61–75, and test on the emergency period. At test time each method may make one cheap adaptation. For the evolved program and the parametric model this is re-tuning of numeric constants only, with 50 runs. For DiffTraj it is fine-tuning at equal wall-clock time.

The first decisive check is the gap between shown and held-out scores. If the evolved programs improve shown divergence while held-out divergence stalls or worsens relative to the parametric baseline, the loop is gaming the statistics. That would falsify the core claim. The second check is the emergency test. The claim predicts that explicit behavioral rules degrade less than DiffTraj under shift.

Cross-dataset validation uses the Chengdu trajectories aggregated to a grid, so that we can compare our density error against DiffTraj's reported 0.0055 under identical metric code.

The privacy experiment adds calibrated Gaussian noise to the shown statistics for a fixed total budget. We compare two ways of spending it: many noisy rounds versus few precise rounds, each with re-evaluated survivors. We measure held-out divergence of the selected program and how often selection picks a program whose true score is worse than its parent's.

Finally, three domain readers will independently inspect the top programs to judge whether the discovered rules are sensible, for example whether commute behavior depends on point-of-interest type. Readability is part of what the method claims to deliver, so it should be checked rather than assumed.