Repository navigation
Close the XOR gap with the NEAT paper: tuned survival threshold and weight sigma, mate-only and mate selection options (ref #108) - #125
Merged
Conversation
…ions, ref #108 Measured on bench A (xor_bench 50 500 init reset=1) over seeds 1/101/201/301 and validated on 401/501/601/701 (200 runs each, all solved): - survival_threshold default 0.5 -> 0.2 (Stanley's NEAT survival_thresh) - weight_mutate_power default 1.0 -> 2.0 Medians 52/53/53/51 -> 30/31/31/30 (validation 53/54/54/53 -> 30/29/28/31); by the paper criterion (every output on the right side of 0.5) mean 18.2 -> 14.7 generations (validation 18.6 -> 14.0). Champion robustness to the pattern order unchanged (reversed_no_reset 160 -> 157 of 200, validation 157 -> 162). The lunar lander keeps the fittest half (LANDER_SURVIVAL_THRESHOLD = 0.5) and its own sigma. - MutationConfig::mate_only_probability (default 0, NEAT mate_only_prob): a crossover child is left unmutated with this probability (#38 point 3). - MutationConfig::mate_selection / MateSelection::{Uniform (default), FitnessProportional}: how the crossover mate is chosen (#98). Neither helped on the bench, so both are opt-in; with them at their defaults the random sequence is unchanged. - xor_bench: keys mateonly, matesel and round=1 (solved by the NEAT paper criterion instead of a fitness target). The long_run_identity digest changes because the defaults change on purpose; the test now also checks that with the old two values the old digest (0xb085_f2fe_3578_d4a4) is reproduced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 25, 2026
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
survival_threshold0.5 → 0.2 andweight_mutate_power1.0 → 2.0.MutationConfig::mate_only_probability(NEATmate_only_prob, Some algorithm considerations #38 point 3) andMutationConfig::mate_selection/MateSelection::{Uniform, FitnessProportional}(Selection inside a species ignores negative fitness #98). Both default to the old behaviour and draw no extra random numbers.mateonly,mateselandround=1. Withround=1a run counts as solved by the NEAT paper criterion (every output on the right side of 0.5).LANDER_SURVIVAL_THRESHOLD) and its own σ, so its config is unchanged.long_run_identity_testsdigest is re-recorded (0xb085f2fe3578d4a4 → 0xacac1eb362c6aa78). The test also checks that the two old values reproduce the old digest.How it was verified
cargo fmt -- --checkOK;cargo clippy --release --all-targets -- -D warningsOK; with--all-featuresand with--features telemetry(pyo3 stub) OK;cargo build --release --examplesOK;cargo check --release --features openai --examplesOK;cargo test --release --no-fail-fast: 245 passed, 0 failed (including the README doc-tests).function_approximationandsimple_samplestill run.#108 results: XOR gap with the NEAT paper
Method. Bench A:
xor_bench 50 500 init reset=1 seed=S [keys], with S = 1/101/201/301 (runs S..S+49, so 200 runs per config). Each config was measured under three success criteria, each in its own run:round=1. A run is solved when every output is on the right side of 0.5 (out < 0.5 for 0, ≥ 0.5 for 1), which is the check in Stanley's code.The last column is the champion check
still_solved_reversed_no_reset: the champion still scores above 15.5 with the patterns in reverse order and no state reset. It measures how much a CTRNN's answer depends on the patterns it saw before. I tracked it so that no default would buy speed with less robust champions.Each key is set on top of the develop defaults (
mutp=0.4 surv=0.5 champ=2 tspec=10 wpow=1 wgene=0.5 addc=0.05 addn=0.03 tau=0.01 step=0.1 xavg=0.4). In total: 54 configs on the main seeds, 6 on the validation seeds 401/501/601/701, and 8 on other XOR variants. Every one of them solved 200/200.Key finding: most of the gap is the success criterion
With the develop defaults, judged by the paper's own criterion (rounding), XOR is solved in mean 18.2 generations (medians 17/18/20/16; validation seeds mean 18.6). The paper reports 32. The 52–54 generation medians come from our much stricter target of 15.5. Even the audit's target 13 gives a mean of 33.6, which is about the paper's number.
Chosen change (defaults)
survival_threshold0.5 → 0.2 (thesurvival_threshin Stanley's NEAT code).weight_mutate_power(gaussian σ) 1.0 → 2.0.reset=0), target 15.5 medians, main / validationall_orders_reset_eachmain / validationinlo=-1 splitlo=-1), target 15.5 mediansRejected after measuring
addc=0.3(the paper's rate for large populations):surv=0.2 wpow=2 addc=0.3 mutp=0.25reaches medians 27 and a rounding mean of 11.0–11.3. But they cutreversed_no_resetfrom 160 to about 120 of 200 on both seed sets, and with no-reset training they cutall_ordersfrom 182 to about 163. More connections give more recurrent and self loops, so the answer depends more on earlier patterns.mutp=0.25on top of the chosen pair measured 30/30/30/30 vs 30/31/31/30 (validation 29/28/27/30 vs 30/29/28/31), with equal rounding means. That is within the noise, somutation_probabilitystays 0.4.wgene=1on top of the pair is faster at target 15.5 (26.75) but slower by the paper criterion (mean 16.2 vs 14.7).Other examples
LANDER_SURVIVAL_THRESHOLD = 0.5because the new library default was measured on XOR only.function_approximationstill runs. Neither the old nor the new defaults reach its 96 target within 600 generations (24 seeds). The average best fitness was 69.2 with the old defaults and 71.2 with the new.simple_samplestill runs and finishes.Hash. Because the defaults change, the digest in
long_run_identity_testschanges too (0xb085f2fe3578d4a4 → 0xacac1eb362c6aa78). The test also checks that setting the two old values back gives the old digest, which proves the new options change nothing by default. The README doc-tests pass unchanged.New opt-in options (#38 point 3, #98)
MutationConfig::mate_only_probability(NEATmate_only_prob): the probability that a crossover child is not mutated. A crossover of an organism with itself is always mutated. Default 0, which means every crossover child is mutated, as before.MutationConfig::mate_selection:MateSelection::Uniform(default, as before) orFitnessProportional(roulette, like the first parent).mateonly,mateselandround.Neither option helped (tables below), so both stay off by default.
Full tables
Baseline (develop b0cc678), seeds 1/101/201/301
reversed_no_resetsurv=0.5 wpow=1)Single candidates, seeds 1/101/201/301
reversed_no_resetmutp=0.25mutp=0.6mutp=0.8mateonly=0.2mateonly=0.5mutp=0 mateonly=0.75mutp=0matesel=1surv=0.2surv=0.3surv=0.7champ=1champ=6champ=inftspec=5tspec=15tspec=20tspec=0 thr=3wpow=0.5wpow=2wgene=0.2wgene=1addc=0.1addc=0.3addn=0.01addn=0.06taurate=0.1tau=0.1step=0.05xavg=0surv=0.1wpow=1.5wpow=3addc=0.5Combinations, seeds 1/101/201/301
reversed_no_resetsurv=0.2 wpow=1.5surv=0.2 wpow=2surv=0.2 wgene=1surv=0.2 addc=0.3surv=0.2 wpow=2 addc=0.3surv=0.2 wpow=1.5 addc=0.3surv=0.2 wpow=2 wgene=1surv=0.2 wpow=2 addc=0.3 mutp=0.25surv=0.2 wpow=2 addc=0.3 matesel=1surv=0.2 wpow=2 addc=0.3 mateonly=0.2surv=0.1 wpow=2 addc=0.3surv=0.1 wpow=2 addc=0.3 mutp=0.25surv=0.2 wpow=2.5 addc=0.3 mutp=0.25surv=0.2 wpow=2 addc=0.3 mutp=0.25 matesel=1surv=0.2 wpow=2 addc=0.3 mutp=0.25 tspec=15surv=0.2 wpow=2 addc=0.3 mutp=0.25 champ=6surv=0.2 wpow=2 mutp=0.25surv=0.2 wpow=2 wgene=1 mutp=0.25surv=0.2 wpow=2 addc=0.1surv=0.2 wpow=2 wgene=1 addc=0.1Validation on other seeds 401/501/601/701
reversed_no_resetsurv=0.2 wpow=2 addc=0.3 mutp=0.25surv=0.2 wpow=2 addc=0.3surv=0.1 wpow=2 addc=0.3 mutp=0.25surv=0.2 wpow=2surv=0.2 wpow=2 mutp=0.25reset=0reset=0 surv=0.2 wpow=2Other XOR variants, seeds 1/101/201/301 (no-regression check)
reversed_no_resetreset=0reset=0 surv=0.2 wpow=2 addc=0.3 mutp=0.25inlo=-1 splitlo=-1inlo=-1 splitlo=-1 surv=0.2 wpow=2 addc=0.3 mutp=0.25reset=0 surv=0.2 wpow=2 mutp=0.25inlo=-1 splitlo=-1 surv=0.2 wpow=2 mutp=0.25reset=0 surv=0.2 wpow=2inlo=-1 splitlo=-1 surv=0.2 wpow=2champ=1gives results identical tochamp=2because no species gets exactly one offspring there.Reproduce any row:
cargo run --release --example xor_bench -- 50 500 init reset=1 seed=S <keys> [target=13 | round=1].ref #108
Part of epic #55. Also relates to #38 (points 3, 5, 6 measured; see the comment there).
🤖 Generated with Claude Code