Stopper
stopper ¶
Stopper state model for evolution stop condition decisions.
This module defines the immutable state snapshot passed to stoppers when checking if evolution should terminate.
| ATTRIBUTE | DESCRIPTION |
|---|---|
StopperState | Immutable snapshot of evolution state for stopper decisions. TYPE: |
Examples:
Creating a stopper state:
from gepa_adk.domain.stopper import StopperState
state = StopperState(
iteration=5,
best_score=0.85,
stagnation_counter=2,
total_evaluations=50,
candidates_count=3,
elapsed_seconds=120.5,
)
Note
This StopperState snapshot is intentionally minimal. Add fields as needed for specific stopper implementations. The frozen dataclass ensures stoppers cannot accidentally mutate evolution state.
StopperState dataclass ¶
Immutable snapshot of evolution state for stopper decisions.
Provides stoppers with read-only access to evolution metrics without exposing internal engine state.
| ATTRIBUTE | DESCRIPTION |
|---|---|
iteration | Current iteration number (0-indexed). TYPE: |
best_score | Best score achieved so far. TYPE: |
stagnation_counter | Number of iterations without improvement. TYPE: |
total_evaluations | Count of all evaluate() calls made. TYPE: |
candidates_count | Number of candidates in the frontier. TYPE: |
elapsed_seconds | Wall-clock time since evolution started. TYPE: |
Examples:
Creating a state snapshot:
from gepa_adk.domain.stopper import StopperState
state = StopperState(
iteration=10,
best_score=0.92,
stagnation_counter=3,
total_evaluations=100,
candidates_count=5,
elapsed_seconds=300.0,
)
print(state.best_score) # 0.92
print(state.stagnation_counter) # 3
Attempting to modify raises an error:
Note
A frozen dataclass, all fields are immutable after creation. Using slots=True for memory efficiency.