Repository navigation
Species: select parents on shifted fitness (ref #98) - #115
Merged
Merged
Conversation
Roulette selection inside a species now uses the same shift as the offspring shares between species (#66): if any adjusted fitness is negative, every weight is its distance to the worst, so the fittest is favoured whatever the sign. Before, all-negative fitness made selection uniform and, with mixed signs, every negative organism got weight 0. Non-negative fitness is used unchanged (bit-identical XOR bench). The roulette is extracted into Specie::select_parents and tested with a fixed seed: fitness in [-100, -90], mixed signs, and plain proportions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
shift_to_non_negativefrom the between-species share (Fitness negativo, NaN, élite sin evaluar y campeón histórico #66, nowpub(crate)): if any value is negative, each weight is its distance to the worst organism (the worst gets 0); non-negative fitness is used as is; non-finite fitness gets 0 (as before).Specie::select_parents(count, rng)(same RNG draws, same order) so it can be tested directly.Verification
src/specie.rs(ChaCha8 seed 1), red on develop before the fix:selection_favours_the_fittest_when_all_fitness_is_negative: fitness −90…−100, 6000 draws. Develop:[997, 1052, 992, 995, 991, 973](uniform). Now: fittest > worst, fittest > 1/4 of draws, worst = 0.selection_ranks_negative_fitness_with_mixed_signs:[5, -1, -5]. Develop:[6000, 0, 0]. Now strictly ordered.selection_keeps_proportions_of_non_negative_fitness:[3, 1, 0]keeps the 3:1 ratio and 0 for the zero.cargo fmt -- --checkOK;cargo clippy --release --all-targets56 warnings (same as develop);cargo build --release --examplesOK;cargo test --release --no-fail-fastall green.Closing criterion
Met: in a species with fitness in [−100, −90], the fittest is selected more often than the worst over 6000 draws with a fixed seed (worst is never selected).
Banco A (
xor_bench 50 500 init reset=1 seed=S), seeds 1/101/201/301: 50/50 solved each, medians 52/53/53/51, same as develop 0d78b05. XOR fitness is non-negative, so the output is bit-identical: all 200RunResultlines (sorted,secsstripped) match develop exactly.ref #98
Part of epic #55
🤖 Generated with Claude Code