Random Search
Uniformly sample a parent and context from the full candidate history.
"""Random-search Population component — an uncapped keep-all leaderboard.
One module per component (see :mod:`scaffold`). Random search keeps every evaluated candidate so the
uniform-random policy can draw a parent and its context from the *entire* history rather than a
truncated elite — that full pool is what makes the baseline an exploration comparison point instead of
a hill climb.
"""
from __future__ import annotations
from ...components.population import InMemoryPopulation
class RandomPopulation(InMemoryPopulation):
"""Keep-all store: every valid candidate is retained, none evicted.
:class:`~galapagos.components.population.InMemoryPopulation` already maintains the candidate store
and answers ``all()``; Random search simply runs it uncapped (``capacity=None`` by default) so a
uniform draw ranges over the complete history. ``drop_invalid=True`` keeps errored children out of
the pool so a random parent is never a candidate that failed to evaluate.
"""
def __init__(self, capacity: int | None = None):
super().__init__(capacity=capacity, drop_invalid=True)