ProgramGenomeCodec
Models & Types · AiDotNet.Evolution.Programs
Serializes ProgramGenome instances for portable evolution checkpoints.
Implements: IEvolutionGenomeCodec<ProgramGenome>
For Beginners
A long evolution run needs to be able to stop and start again, which means writing every candidate program to disk and reading it back. This class is the save-file format for one program: it turns a genome into a small line of JSON and turns that JSON back into an identical genome. You only need it when you give the engine a checkpoint store; runs that never pause do not use it at all.
How It Works
The payload is a compact JSON object with a fixed property order — v, language, source,
then description when one is present — written with the invariant culture, so serializing the same
genome twice produces byte-identical text. That determinism is a contract requirement:
EvolutionEngine<TGenome> compares checkpointed seed payloads with ordinal string equality when
resuming, and a codec that reordered properties would make every resume look incompatible.
VersionHash is folded into the engine’s compatibility hash. Change it whenever the payload shape
changes so older checkpoints are refused outright rather than being misread, and keep Id stable
for the lifetime of the format. Malformed or truncated payloads raise InvalidDataException as the
interface requires, never a JSON-library exception.
Constructors
| Constructor | Summary |
|---|---|
ProgramGenomeCodec() |
Properties
| Property | Summary |
|---|---|
string Id { get; } |
|
string VersionHash { get; } |
Methods
| Method | Summary |
|---|---|
ProgramGenome Deserialize(string payload) |
|
string Serialize(ProgramGenome genome) |
Fields
| Field | Summary |
|---|---|
int PayloadVersion |
The payload schema version written into every serialized genome. |