galapagos
DocsHubLeaderboardPlaygroundNews
galapagos

six blocks · any task ·
better solutions emerge.

Platform

  • Hub
  • Leaderboard
  • Playground

Resources

  • Docs
  • API reference
  • Card spec

Community

  • GitHub
  • Contribute

Updates

  • News
  • Releases

© 2026 Galapagos. Licensed under Apache-2.0.

Build your own scaffold.

Hub/Scaffolds/default/Top-K

default/topk

Top-K

Always expand the single best program, with the next K as context. Pure greedy elitism.

Test-time searchApache-2.0
Scaffold cardFiles and versions
topk/population.py
24 lines · 1.2 KBpythonDownload
"""Top-K Population component — an uncapped keep-all leaderboard sorted by combined_score.

One file per component (see scaffold.py). Faithful port of SkyDiscover's ``TopKDatabase`` store,
which keeps every program ever generated (``# NOTE: no enforcement on population size at all``) and
ranks them by ``combined_score`` on every sample.
"""
from __future__ import annotations

from ...components.population import InMemoryPopulation


class TopKPopulation(InMemoryPopulation):
    """SkyDiscover ``TopKDatabase`` store: keep-all, fitness-sorted, no real population cap.

    :class:`~galapagos.components.population.InMemoryPopulation` already maintains a fitness-sorted
    leaderboard answering ``query({"top": k})``; Top-K simply runs it effectively uncapped (the
    reference enforces no size limit), so the parent (rank 1) and context (ranks 2..K+1) are always
    drawn from the full history.
    """

    def __init__(self, capacity: int | None = None):
        # None = uncapped (SkyDiscover enforces no population cap); drop_invalid mirrors the controller
        # dropping errored children (`if result.error: continue`) so they never pollute the leaderboard.
        super().__init__(capacity=capacity, drop_invalid=True)