ProgramDiversityDescriptor

Models & Types · AiDotNet.Evolution.Programs

Measures how far a candidate program sits from a fixed reference set of programs.

Implements: IRebasableProgramDescriptor

For Beginners

This descriptor answers “how unusual is this program compared with a fixed set of examples?”. You give it a handful of reference programs when you create it — typically the seed programs of the run — and it reports the average distance from the candidate to those references. Using it as an archive axis keeps genuinely different approaches alive instead of letting the search fill up with variations on one idea. The reference set never changes during a run, which is what makes the numbers comparable from start to finish.

How It Works

The distance between two programs is the reference implementation’s fast approximation — the absolute difference in character length weighted 0.1, the absolute difference in line count weighted 10, and the size of the symmetric difference of their character sets weighted 0.5 — and the descriptor value is the mean distance to every reference program. What differs is where the reference set comes from. OpenEvolve rebuilds it from the live database with a greedy selection seeded by the global random module, so the same candidate can be assigned different diversity values in two runs of the same configuration, and the value drifts as the database grows. Here the reference set is supplied once at construction, deduplicated and sorted ordinally, so the descriptor is a pure function of the genome and survives a checkpoint resume unchanged.

Reference sources are normalized the same way genomes are, so a reference that differs only in line endings contributes the same distance as one that does not. A reference identical to the candidate is skipped, and an empty reference set yields zero.

Constructors

Constructor Summary
ProgramDiversityDescriptor(IEnumerable<ProgramGenome> referenceGenomes, string name) Initializes a diversity descriptor against a fixed set of reference genomes.
ProgramDiversityDescriptor(IEnumerable<string> referenceSources, string name) Initializes a diversity descriptor against a fixed set of reference genomes.

Properties

Property Summary
IReadOnlyList<string> ReferenceSources { get; } Gets the normalized, deduplicated, ordinally sorted reference programs.
string Name { get; }
string VersionHash { get; }

Methods

Method Summary
IRebasableProgramDescriptor Rebase(IReadOnlyList<ProgramGenome> references)
double Compute(ProgramGenome genome)
double ComputeDistance(string first, string second) Computes the fast structural distance between two program sources.

Fields

Field Summary
string DefaultName The descriptor name used when none is supplied.