fix: use child_counts for novelty-weighted parent selection#37
Conversation
select_next_parent computes child_counts but never uses it — the function selects parents uniformly at random, ignoring the novelty signal that under-explored branches should be preferentially picked. Replace random.choice with numpy.random.choice using weights inversely proportional to (1 + child_count). This is the standard mechanism used by FunSearch, MAP-Elites, and AlphaEvolve to prevent mode collapse during open-ended search. Adds 5 tests: - test_under_explored_parents_preferred: verifies fewer children → more selections - test_single_candidate_always_selected: single candidate always wins - test_equal_children_have_similar_counts: equal weights → roughly uniform - test_no_valid_candidates_raises: ValueError on empty archive - test_dead_code_eliminated: static check that child_counts is used Fixes facebookresearch#29
|
Hi @xbrxr03! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Summary
select_next_parentbuilds achild_countsdictionary tracking the number of descendants each candidate parent has spawned, then immediately discards it and selects a parent uniformly at random viarandom.choice. The computation is dead code, and the selection is not novelty-weighted — contradicting what a reader would reasonably expect from a method namedselect_next_parentin an open-ended exploration framework.Fixes #29.
What changed
select_next_parent.pyrandom.choice(list(candidates.keys()))withnp.random.choiceusing weights inversely proportional to(1 + child_counts[genid])child_countsis now actually used instead of being computed and thrown awaytest_select_next_parent.py(new)Testing
Design choice
I went with Option A from the issue — novelty-weighted selection — because:
Happy to sign the CLA if needed.