evokit.tools.lineage package
Module contents
- class evokit.tools.lineage.VarySignature[source]
Bases:
Protocol,Generic[D]Signature of
Variator.vary().:meta private
- __init__(*args, **kwargs)
- evokit.tools.lineage.TrackParents(var: Variator[D], max_parents: int = 5) Variator[D][source]
Decorator that lets a variator track the lineage of an offspring.
In particular, each call to
var.varysets theIndividual.parentsof all offspring to its inputs.Warning
To save cost, the
Individual.parentsis reset toNoneafter an individual ever becomes themax_parentsth parent of another individual.If an individual is preserved for several generations, its
Individual.parentsmay be expunged.
- evokit.tools.lineage.register_parents(child_parent_links: dict[str, tuple[str, float, set[str]]], ind: Individual, identifier: Callable[[Individual], str])[source]
- evokit.tools.lineage.uid(x: Individual) str[source]
- evokit.tools.lineage.graph_lineage(individuals: ~typing.Sequence[~evokit.core.population.Individual], identifier: ~typing.Callable[[~evokit.core.population.Individual], str] = <function uid>, compact: bool = False, use_colour: bool = True, vertical_spacing: int = 1, save_as: ~pathlib.Path | str | None = None) Digraph[source]
Graph the lineage of an individual. This information can be accessed as
Individual.parents.Linage tracking is off by default.
TrackParents()enables lineage tracking in a variator.- Parameters:
individuals – Individuals to plot.
identifier – A function to convert an individual to a unique identifier. The default
id()is efficient but might not work with individual that have moved out of memory (for example, ones that have beenIndividual.load()ed)compact – If
True, then (a) render each node as a dot and (b) render the content of that node as a tooltip. Tooltips are only rendered in SVG filesuse_colour – If
True, then render each node with a colour that indicates its fitness. Green means good; red means bad.vertical_spacing – Multiplier for vertical spacing between nodes.
save_as – Path to save the output as. If name is given, file will be saved as name.svg. For safety, can only write to current and child directories.