ProgramLengthDescriptor

Models & Types · AiDotNet.Evolution.Programs

Measures a candidate program by the character length of its normalized source.

Implements: IProgramDescriptor

For Beginners

Quality-diversity search sorts candidates into pigeonholes so it keeps a variety of good answers. This descriptor supplies one common pigeonhole axis: how long the program is. Short and long solutions then compete only against others of similar size, which stops one very long solution from crowding out an elegant short one. Pair it with an EvolutionDescriptorDefinition whose bounds cover the program sizes you expect.

How It Works

The reference OpenEvolve implementation uses len(program.code) as its built-in complexity axis, which makes the coordinate move when a model reformats a file: adding CRLF line endings inflates it by one character per line, and trailing spaces inflate it further, so the same program can occupy two different archive cells. This descriptor measures NormalizedSource instead, which has already had its line endings unified and its trailing white space removed, so cosmetic edits cannot move a candidate between cells.

Constructors

Constructor Summary
ProgramLengthDescriptor(string name) Initializes a length descriptor.

Properties

Property Summary
string Name { get; }

Methods

Method Summary
double Compute(ProgramGenome genome)

Fields

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