Measuring Population Diversity by Compressing Behavior in LLM-Driven Program Search

When a large language model (LLM) is used to evolve heuristics for problems like bin packing or the traveling salesman problem, the search often stalls. The population fills up with programs that look different on the page but make the same decisions when run. This proposal measures diversity a different way. We record what each candidate program actually does on a fixed set of probe instances, and we ask how many extra bits an ordinary lossless compressor needs to encode that behavior once it has already seen the behavior of the rest of the population. A program whose decisions are cheap to describe given its peers adds nothing new, however different its source code looks. We use this "behavioral surprise" score in two places: to choose survivors, and to decide when the population has collapsed and should be reset.

The motivation is a gap that appears from both sides. Kolmogorov complexity, the length of the shortest program that outputs a string, is the principled way to say how much new information one object carries given another. It is uncomputable, because deciding whether a short candidate program ever halts runs into the halting problem. Practical work therefore replaces it with real compressors. Separately, the premature-convergence literature for LLM program search keeps finding that greedy selection traps the search. It also finds that current diversity measures, such as abstract-syntax-tree (AST) distance and novelty thresholds, track syntax rather than function. Our claim is that a time-bounded, compressor-based estimate of conditional information, computed on execution behavior rather than source code, is a usable and cheaper diversity signal. We claim it delays functional collapse and improves the final quality of evolved heuristics at a fixed query budget.

Core Claim and What Is New

Define a probe set $P$ of small problem instances. For a heuristic $h$, let $b(h)$ be the serialized sequence of decisions it makes on $P$, such as the bin chosen for each item or the next city chosen at each step. Each run is cut off at a fixed step budget, and a timeout is written as a special symbol. For an archive $A$ of current population members' behavior strings, concatenated in a canonical order, we score

$$N(h \mid A) = \frac{C(A \cdot b(h)) - C(A)}{C(b(h))},$$

where $C(\cdot)$ is the compressed length under a fixed lossless compressor and $A \cdot b(h)$ is concatenation. This is the compressor analogue of conditional complexity $K(b(h) \mid A)$ divided by $K(b(h))$. It is near 0 when $h$ repeats existing behavior and near 1 when its behavior is unpredictable from the archive. The time cutoff is how we sidestep incomputability. We do not search over programs at all. We only run the candidate, which we hold, for a bounded number of steps and compress its output. A population-level redundancy score, $R = 1 - C(\text{all } b_i)/\sum_i C(b_i)$, measures how much the archive compresses jointly compared with its members compressed separately. $R$ serves as the trigger for resetting the population.

Two things are new. First, information distances have been computed on behavior rather than syntax inside an evolutionary loop, and conditional compression is used for survivor selection. Second, the trigger for the restart mechanism is grounded in information rather than a stagnation counter.

Relation to Prior Work

Three papers motivate the problem. Understanding the Importance of Evolutionary Search in Automated Heuristic Design with Large Language Models builds the llm-eps benchmark. It shows that a greedy single-solution LLM mutator, called (1+1)-EPS, falls into a "greedy trap" and that population mechanisms such as FunSearch's islands are needed. Its islands are partitioned ad hoc, with no measure of what the islands contain. Multi-Objective Evolution of Heuristic Using Large Language Model (MEoH) prunes Pareto-front candidates by AST dissimilarity. That captures static structure, not runtime behavior; we keep its Pareto selection and replace the dissimilarity term. CALM wipes the population back to seed plus best when progress stalls. Its triggers and crossover novelty rest on heuristic thresholds and AST tokens; we reuse its reset operation but trigger it on $R$.

Two papers constrain the design. Neural Normalized Compression Distance and the Disconnect Between Compression and Classification builds compression distances from LLMs plus arithmetic coding. It finds that a better compression rate does not reliably mean better similarity judgments: on AGNews, RWKV 169M compresses to 0.248 against gzip's 0.785, yet loses to gzip on DBpedia. We therefore do not assume a stronger compressor is better. We treat the compressor as a variable to be tested. The same paper's $O(n^2)$ cost warning is also why we score each candidate once against the archive rather than computing all pairwise distances.

Properties of Algorithmic Information Distance proves that the ideal information distance is not Euclidean. That warns against treating compression scores as coordinates for crowding or clustering. Our method only ranks candidates by a scalar, so it does not depend on Euclidean geometry.

Generalized Compression Dictionary Distance supplies a cheaper method: it computes similarity from the compressor's internal dictionary statistics rather than from full bitstreams. We test it as a fast variant.

One paper motivates the use of behavior over representation. Discovering alternative solutions beyond the simplicity bias in recurrent neural networks shows that repeated training keeps converging to the same simple solution. Its fix penalizes only linear predictability from earlier models, and the authors note that nonlinear similarity goes unpenalized. Conditional compression is a nonlinear predictability test. Here we apply it to discrete program behavior, where it is cheapest to compute.

Research Program

The first step is a diagnosis that does not depend on our method. We rerun FunSearch, EoH, and MEoH populations from llm-eps on Online Bin Packing, TSP, and the Admissible Set problem. We then measure how many population members are functional duplicates, meaning their decisions agree exactly on a held-out probe set. If AST-diverse populations turn out to be functionally diverse, the premise fails and we stop here.

Second, we build the selection rule. Survivors are the Pareto front over fitness and $N(h \mid A)$. The population is reset CALM-style when $R$ crosses a threshold calibrated on a separate validation task.

Third, we vary the compressor: gzip, LZMA, a dictionary-statistics variant, and a small neural compressor. The aim is to test directly whether the compression-versus-utility disconnect reported for text carries over to behavior strings.

Fourth, we vary the size of the probe set and the step budget. This tells us the cost of the signal relative to a full fitness evaluation. That matters because llm-eps runs can take days.

Baselines

The naive reference point is standalone LLM sampling and (1+1)-EPS, both run on the same open-weight model and query budget. They anchor how much any population mechanism helps. For reference, llm-eps reports TSP gaps of 9.64% for standalone sampling and 3.87% for (1+1)-EPS, and Admissible Set gaps of about 10% for standalone GPT-3.5 and 7.5% for (1+1)-EPS. We will rerun these rather than copy them, because our model differs.

The strongest existing population methods are EoH and FunSearch islands, together with MEoH's AST-dissimilarity selection. The best reported TSP figure in the file is EoH with Claude 3 Opus at a 0.12% gap, from Understanding the Importance of Evolutionary Search. For Online Bin Packing, CALM reports a 0.00% gap on the 1k_500 scale. Because these are near the floor, beating them is defined at matched model, matched evaluation budget, and matched seeds. It means either reaching the same gap with clearly fewer LLM queries (we target 30% fewer, measured over at least five seeds), or a lower final gap on the Admissible Set and on larger TSP instances, where headroom remains.

CALM's stagnation-triggered reset is run as its own baseline, with the trigger as the only difference. That isolates whether the $R$ trigger helps.

Three ablations isolate the key ingredient. The first applies the same compressor to source code instead of behavior; this tests whether behavior is what matters. The second uses unconditional behavioral distinctness, $C(b(h))$ alone without the archive; this tests whether conditioning matters. The third uses Euclidean novelty on per-instance score vectors; this tests whether compression adds anything over plain behavioral distance. All methods share the same LLM, prompts, probe and test instances, query budget, and an equal hyperparameter-tuning budget of a fixed number of validation runs each.

Why not just…?

Why not just use Euclidean distance between per-instance fitness vectors, as standard novelty search does? This is the real threat. Score vectors are cheap and already behavioral. Their weakness is that two different strategies can earn similar scores, and the same strategy can earn different scores under noise. Decision traces avoid both problems, and conditional compression also catches redundancy that is not a simple distance, such as one heuristic being a deterministic recoding of another's choices. Whether this matters in practice is unknown. The score-vector ablation decides it. If it matches our method, the honest conclusion is that behavior matters and compression does not, and we will report it that way.

Why not just compute NCD on the source code? This is the obvious way to bring compression into the search, but code strings are still syntax. Gzip will call renamed or reordered but identical programs different. Our first diagnostic quantifies how often that happens, and the code-NCD ablation measures its cost directly.

Why not just use more islands, a larger population, or more frequent random restarts? These spend more of the evaluation budget without targeting redundancy. Our comparison holds total queries fixed. If tuned restarts with the same budget close the gap, the $R$ trigger is unnecessary. The CALM-reset baseline with a tuned counter tests this.

Why not embed code with the LLM and use cosine distance? Embeddings of source text share the syntax problem. The finding of Neural NCD that latent-distance quality varies drastically from model to model suggests embeddings would be an unstable selection signal. We include one embedding variant as a secondary check.

Proposed Experiments

The benchmarks are the llm-eps tasks (Online Bin Packing on Weibull instances, TSP at 100 to 1,000 nodes and on TSPLIB, and the Admissible Set problem), plus CVRP from CALM for a generalization check. Primary metrics are final optimality gap, gap against number of LLM queries, and queries needed to reach a fixed gap. To keep the diversity evaluation from being circular, we never measure diversity with the selection score. We count functionally distinct behavior classes on a held-out probe set, using exact decision agreement.

The decisive checks are three. First, AST-diverse baselines must contain many functional duplicates; this is the premise. Second, our method must keep more distinct behavior classes alive late in the search and convert them into better query efficiency or a lower gap than both MEoH and score-vector novelty. Third, the code-NCD and unconditional ablations must perform worse, which is what would show that conditioning on the archive and measuring behavior both carry the effect.

A secondary result follows from the compressor sweep. If the neural compressor helps less than LZMA despite compressing better, that extends the compression-versus-utility disconnect from text classification to search.