Genome¶
Base genome class and behavior descriptors.
Genome¶
Bases: ABC, Generic[T]
Abstract base class for evolvable genomes.
Implementations must define: - random(): Create a random genome - mutate(): Create a mutated copy - crossover(): Combine with another genome - to_stimulus(): Convert to the Stimulus a Target executes - behavior(): Extract behavior descriptor for QD
Source code in src/rotalabs_redqueen/core/genome.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
random(rng: Rng | None = None) -> T
abstractmethod
classmethod
¶
Create a random genome instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng
|
Rng | None
|
Random number generator for reproducibility |
None
|
Returns:
| Type | Description |
|---|---|
T
|
New random genome |
mutate(rng: Rng | None = None) -> T
abstractmethod
¶
Create a mutated copy of this genome.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng
|
Rng | None
|
Random number generator for reproducibility |
None
|
Returns:
| Type | Description |
|---|---|
T
|
New mutated genome (original unchanged) |
Source code in src/rotalabs_redqueen/core/genome.py
crossover(other: T, rng: Rng | None = None) -> T
abstractmethod
¶
Create offspring by combining with another genome.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
T
|
Another genome to combine with |
required |
rng
|
Rng | None
|
Random number generator for reproducibility |
None
|
Returns:
| Type | Description |
|---|---|
T
|
New offspring genome |
Source code in src/rotalabs_redqueen/core/genome.py
to_stimulus() -> Stimulus
abstractmethod
¶
Convert genome to the Stimulus a Target executes.
May be a single prompt, a multi-turn conversation, or an agentic
action plan (see :mod:rotalabs_redqueen.core.stimulus).
Returns:
| Type | Description |
|---|---|
Stimulus
|
The Stimulus phenotype for evaluation. |
Source code in src/rotalabs_redqueen/core/genome.py
behavior() -> BehaviorDescriptor
abstractmethod
¶
Extract behavior descriptor for quality-diversity.
Returns:
| Type | Description |
|---|---|
BehaviorDescriptor
|
Behavior descriptor characterizing this genome |
to_dict() -> dict
abstractmethod
¶
Serialize the genome to a JSON-compatible dict.
Must round-trip via :meth:from_dict. This is how archives persist
genomes for cross-run continuity.
from_dict(data: dict) -> T
abstractmethod
classmethod
¶
distance(other: T) -> float
¶
Genetic distance to another genome.
Default implementation uses behavior distance. Override for custom distance metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
T
|
Another genome |
required |
Returns:
| Type | Description |
|---|---|
float
|
Distance value (higher = more different) |
Source code in src/rotalabs_redqueen/core/genome.py
BehaviorDescriptor¶
Characterizes behavior for quality-diversity algorithms.
The behavior descriptor places an individual in a multi-dimensional behavior space, enabling MAP-Elites and novelty search.
Source code in src/rotalabs_redqueen/core/genome.py
distance(other: BehaviorDescriptor) -> float
¶
Euclidean distance between behavior descriptors.