NoveltyGatingProgramFitnessEvaluator

Models & Types · AiDotNet.Evolution.Programs.Novelty

Consults a novelty policy before an inner evaluator is allowed to spend anything on a candidate.

Implements: IProgramFitnessEvaluator

For Beginners

Wrap your scoring evaluator in this and near-duplicate candidates stop costing you anything: they are turned away before your tests ever run. It keeps a list of the candidates it has let through and compares each new one against that list. RejectedCount tells you how many evaluations it saved.

How It Works

This is how a novelty gate reaches a run without any change to the evolution engine or the archive: it is an IProgramFitnessEvaluator that wraps the real one. A candidate the policy rejects is returned as Rejected with a bounded diagnostic and the inner evaluator is never called, so the saving is the whole cost of an evaluation — a sandboxed run, a test suite, a judging call — rather than merely an archive slot.

That ordering is the substantive difference from the reference implementation, which gates on insertion: there, a candidate is proposed, evaluated in full, and only then compared for novelty and dropped, so a rejected duplicate has already consumed its evaluation. It is also why the check must be cheap, which is exactly what the policy’s structural rung is.

The gate remembers the genomes it has accepted, newest last, up to MaxTrackedGenomes, then discards the oldest. That memory is its own: it is not the engine’s archive and cannot see elites this evaluator did not admit, migrants, or anything restored from a checkpoint. An engine-side gate consulting the live archive would compare against strictly more, and would need the engine to call the policy itself.

Constructors

Constructor Summary
NoveltyGatingProgramFitnessEvaluator(IProgramFitnessEvaluator inner, ProgramNoveltyPolicy policy, string id) Initializes a gating evaluator.

Properties

Property Summary
IProgramFitnessEvaluator Inner { get; } Gets the evaluator that scores candidates the policy admits.
ProgramNoveltyPolicy Policy { get; } Gets the policy consulted before every evaluation.
int TrackedCount { get; } Gets how many accepted genomes are currently remembered.
long AcceptedCount { get; } Gets how many candidates were admitted and forwarded to the inner evaluator.
long RejectedCount { get; } Gets how many candidates were turned away without any inner evaluation.
string Id { get; }
string VersionHash { get; }

Methods

Method Summary
ProgramNoveltyDecision GetLastDecision() Returns the most recent novelty decision, or null before the first evaluation.
ValueTask<EvolutionTaskResult> EvaluateAsync(ProgramGenome candidate, EvolutionEvaluationContext context, CancellationToken cancellationToken)
void Remember(ProgramGenome genome) Adds a genome to the remembered set without evaluating it.

Fields

Field Summary
string RejectionCode The diagnostic code reported for a candidate the policy turned away.