Population¶
The Population container manages a collection of
evolutionary agents. It collects per-agent metrics into a
PopulationMetrics snapshot each evolution step and
formats them into MetricsReport objects consumed by
loggers.
Metrics Snapshots¶
- class agilerl.population.PopulationMetrics(fitnesses: list[float | int] | list[dict[str, float]], scores: list[float | int] | list[dict[str, float]], steps: list[int], steps_per_second: list[float], mutations: list[str | None], indices: list[int], additional_metrics: list[dict[str, float]], hyperparameters: list[dict[str, float]], nonscalar_additional_metrics: list[dict[str, ~numpy.ndarray[tuple[int, ...], ~numpy.dtype[~numpy._typing._array_like._ScalarType_co]] | None]] = <factory>, subpopulations: list[int | None] = <factory>)¶
Immutable snapshot of per-agent population metrics.
Stores raw per-agent data and exposes computed properties for population-level aggregates.
- class agilerl.population.MetricsReport(metrics: PopulationMetrics)¶
Formats population metrics into a tabular report.
Constructed by
Population.report_metrics()and consumed byLoggerimplementations.- Parameters:
metrics (PopulationMetrics) – Aggregated population metrics snapshot.
- eval_rows() list[ScalarMetricRow | NestedMetricRow]¶
Return the evaluation metric rows.
- Returns:
List of evaluation metric rows.
- Return type:
list[ScalarMetricRow | NestedMetricRow]
- render() str¶
Render a MetricsReport snapshot of collected training metrics into a Rich-formatted table string.
- Returns:
The report rendered by Rich as ANSI-styled text.
- Return type:
Population Container¶
- class agilerl.population.Population(agents: list[AgentT], min_evo_steps: int = 100, accelerator: Accelerator | None = None, loggers: list[Logger] | None = None)¶
Population wrapper for evolutionary agent management.
Owns the logger pipeline and provides a single
report_metrics()entry-point that gathers per-agent data, builds aMetricsReport, and dispatches it to all configured loggers.- Parameters:
- is_nested_scores() bool¶
Check if the scores are nested per-sub-agent i.e. a nested list.
- Returns:
True if the scores are nested per-sub-agent, False otherwise.
- Return type:
- property last_scalar_fitnesses: list[float]¶
Most recent fitnesses as scalars (single-agent / summed loops).
- report_metrics(clear: bool = True) MetricsReport¶
Gather, format, and log population metrics.
- Parameters:
clear (bool) – Whether to clear the metrics after reporting.
- Returns:
The metrics report.
- Return type: