ProgramNoveltyPolicy
Models & Types · AiDotNet.Evolution.Programs.Novelty
The three-rung novelty gate: a free structural check, then an optional embedding check, then a judge.
For Beginners
Evolutionary search wastes most of its budget re-testing candidates that are almost the same as ones it already tested. This checks a new candidate against the ones you have, using a free text comparison first and only paying for a smarter comparison when the free one cannot tell. Construct it with no arguments and it is free to run; add an embedding client and a judge when you want it to be cleverer.
How It Works
The policy answers one question — is this candidate different enough from what we already have to be worth
evaluating? — and answers it as cheaply as the configuration allows. Rung one computes a structural distance
against every known genome; a candidate whose nearest neighbour is at least
StructuralNoveltyThreshold away is novel there and then, having made no
request of any kind. Only a structural near-duplicate descends: rung two embeds it together with its nearest
neighbours in one batched request and compares cosine similarity against
EmbeddingSimilarityThreshold, and rung three asks an
IProgramNoveltyJudge about the single closest incumbent.
Both optional rungs are genuinely optional. With no embedding client and no judge the policy is a pure
structural gate that never touches the network — which is the shipped default, and the difference between this
and the reference implementation, whose gate begins by embedding every single candidate and is therefore
unusable without a provider and a key. When a provider is supplied, wrapping it in a
CachingEmbeddingClient means a re-proposed candidate costs nothing on
the second encounter as well.
Failure handling is explicit rather than accidental. An unreachable provider or an unusable judgement resolves
through FailOpenOnEmbeddingFailure and
FailOpenOnJudgeFailure, and the returned
ProgramNoveltyDecision records which rung answered and what it spent. Nothing here executes program
text, and no program text reaches a reason string or a log.
This is a policy, not an engine change: it is a service a task, an evaluator, or a caller consults, and the caller supplies the set of known genomes. It cannot see the engine’s archive on its own.
Constructors
| Constructor | Summary |
|---|---|
ProgramNoveltyPolicy(EmbeddingNoveltyOptions options, IGenomeDistance<ProgramGenome> structuralDistance, IEmbeddingClient embeddingClient, IProgramNoveltyJudge judge) |
Initializes a novelty policy. |
Properties
| Property | Summary |
|---|---|
EmbeddingNoveltyOptions Options { get; } |
Gets the thresholds this policy applies. |
IGenomeDistance<ProgramGenome> StructuralDistance { get; } |
Gets the free structural metric rung one uses. |
bool HasEmbeddingStage { get; } |
Gets whether an embedding provider was supplied, enabling rung two. |
bool HasJudgeStage { get; } |
Gets whether a judge was supplied, enabling rung three. |
long Decisions { get; } |
Gets how many decisions this policy has produced. |
long EmbeddingRequests { get; } |
Gets how many embedding requests this policy has issued in total. |
long FreeDecisions { get; } |
Gets how many decisions reached neither a provider nor a model. |
long JudgeRequests { get; } |
Gets how many judging requests this policy has issued in total. |
long StructuralComparisons { get; } |
Gets how many structural distances this policy has computed in total. |
string VersionHash { get; } |
Gets a stable version string covering the thresholds and every configured rung. |
Methods
| Method | Summary |
|---|---|
ValueTask<ProgramNoveltyDecision> EvaluateAsync(ProgramGenome candidate, IReadOnlyList<ProgramGenome> known, CancellationToken cancellationToken) |
Decides whether a candidate is novel against a set of known genomes. |