Candidate selector
candidate_selector ¶
Protocol definition for candidate selection strategies.
| ATTRIBUTE | DESCRIPTION |
|---|---|
CandidateSelectorProtocol | Async protocol for candidate selection strategies.
|
Examples:
Implement a simple random selector:
import random
from gepa_adk.ports.candidate_selector import CandidateSelectorProtocol
from gepa_adk.domain.state import ParetoState
class RandomSelector:
async def select_candidate(self, state: ParetoState) -> int:
frontier = state.pareto_frontier
return random.choice(frontier) if frontier else 0
selector = RandomSelector()
assert isinstance(selector, CandidateSelectorProtocol)
See Also
ParetoState: Evolution state consumed by candidate selectors.
CandidateSelectorProtocol ¶
Bases: Protocol
flowchart TD
gepa_adk.ports.candidate_selector.CandidateSelectorProtocol[CandidateSelectorProtocol]
click gepa_adk.ports.candidate_selector.CandidateSelectorProtocol href "" "gepa_adk.ports.candidate_selector.CandidateSelectorProtocol"
Async protocol for candidate selection strategies.
Note
Adapters implementing this protocol provide strategies for selecting candidates from the Pareto frontier for mutation.
Examples:
Source code in src/gepa_adk/ports/candidate_selector.py
select_candidate async ¶
select_candidate(state: ParetoState) -> int
Select a candidate index for mutation.
| PARAMETER | DESCRIPTION |
|---|---|
state | Current evolution state with Pareto frontier tracking. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
int | Index of selected candidate. |
| RAISES | DESCRIPTION |
|---|---|
NoCandidateAvailableError | If state has no candidates. |
Note
Outputs a candidate index from the frontier for mutation, enabling Pareto-aware selection strategies.
Examples: