Skip to content

Fix LexicaseSelection IndexError on empty candidate pools - #411

Merged
alcides merged 1 commit into
mainfrom
fix/lexicase-empty-candidates
Sep 16, 2026
Merged

alcides merged 1 commit into
mainfrom
fix/lexicase-empty-candidates

Conversation

@alcides

@alcides alcides commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Guard LexicaseSelection (and weighted/priority variants) against empty candidate pools that previously crashed with IndexError at winner selection.
  • Rule 1: if the evaluator yields no remaining candidates, refill from the original population and assign problem.get_invalid_fitness().
  • Rule 2: if filtering on a case would empty the pool (e.g. all-NaN fitness), keep the pre-filter set.
  • Add regression tests covering dropped evaluations, pool depletion before target_size, and NaN case filters.

Seen in Aeon CBGP runs with aggressive UMAD mutation: many offspring raise InvalidFitnessException, SequentialEvaluator drops them, and lexicase then tries to select ~90% of the population without replacement from a much smaller valid pool.

Test plan

  • pytest tests/gp/lexicase_empty_candidates_test.py tests/gp/unknown_objectives_test.py
  • CI green on this PR

When the evaluator drops invalid individuals or a case filter yields no
survivors (e.g. all-NaN fitness), refill from the original population with
invalid fitness and keep the pre-filter set so selection can continue.

Co-authored-by: Cursor <cursoragent@cursor.com>
@alcides
alcides merged commit b678fb8 into main Sep 16, 2026
8 checks passed
@alcides
alcides deleted the fix/lexicase-empty-candidates branch September 16, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant