Repository navigation
Deprecate legacy methods that bypass the population's RNG, config or registry (ref #103) - #120
Merged
Merged
Conversation
…registry, ref #103 Every public method that draws from rand::thread_rng, uses the default MutationConfig instead of the population's, or numbers new neurons without the InnovationRegistry is now #[deprecated] with a note naming the variant the population uses, and documents what it bypasses. Behaviour is unchanged: each deprecated method calls the same code as before. - Genome: new_initialized, mutate, mutate_with_config, mutate_with_config_and_rng, mate, mate_with_rng, mate_equal_with_rng, is_same_specie, is_same_specie_with_threshold, compatibility_distance. - Organism: mutate, mutate_with_config, mutate_with_config_and_rng, mate, mate_with_rng. New Organism::with_config(genome, &config) (used by the population); Organism::new documented as with_config(default). - Specie: match_genome, match_genome_with_threshold, generate_offspring, generate_offspring_with_config, generate_offspring_with_config_and_rng, parents, choose_new_representative. - Gene: generate_weight, generate_weight_in_range, new_connection (the genome now looks genes up with a draw-free internal key). - MutationConfig::new() (returns a builder) deprecated in favour of the new MutationConfig::builder(). - Genome::add_gene kept as a construction primitive; its re-enabling of an existing connection is documented and tested. Crate code, examples, README and tests use the non-deprecated variants; tests/legacy_api_tests.rs checks each deprecated method against the variant it points to. Banco A (seeds 1/101/201/301) is bit-identical and the long-run identity hash is unchanged. 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
Every public method that bypasses the population's random generator,
MutationConfigorInnovationRegistryis now#[deprecated]with a note naming the variantPopulationuses, and its rustdoc says what it bypasses. No behaviour changes: each deprecated method runs the same code as before.new_initialized,mutate,mutate_with_config,mutate_with_config_and_rng,mate,mate_with_rng,mate_equal_with_rng,is_same_specie,is_same_specie_with_threshold,compatibility_distance.mutate,mutate_with_config,mutate_with_config_and_rng,mate,mate_with_rng. NewOrganism::with_config(genome, &config)(the population uses it for its initial organisms);Organism::newis documented aswith_configwith the default config.match_genome,match_genome_with_threshold,generate_offspring,generate_offspring_with_config,generate_offspring_with_config_and_rng,parents,choose_new_representative.generate_weight,generate_weight_in_range,new_connection. The genome usednew_connectionas a binary-search key (onethread_rngdraw per lookup in the add-connection path); it now uses a draw-free internal key.new()(returns a builder) is deprecated in favour of the newMutationConfig::builder().Internally,
Specie::create_childand the deprecated wrappers callpub(crate)mutate_with_registryhelpers, so no crate code uses deprecated items. Examples, README and tests moved to the non-deprecated variants. The full inventory table is in the comment on #103.Verification
tests/legacy_api_tests.rs(12 tests) was red first (noMutationConfig::builder, noOrganism::with_config). It checks each deprecated method against the variant it points to, using the same seed: identical genomes, distances and species decisions. It also checksOrganism::new==with_config(default)andadd_genere-enabling.cargo fmt -- --check: OKcargo clippy --release --all-targets -- -D warnings: 0 warnings (also--features telemetryand--all-featureswith the pyo3 stub)cargo build --release --examples: OK;cargo check --release --features openai --examples: OKcargo test --release --no-fail-fast: all green (133 unit, all integration binaries, 5 doc-tests), includinglong_run_identity_tests(hash unchanged)Closing criterion
Each legacy method is either deprecated pointing to the correct variant, or kept and documented (
add_gene,Organism::new,impl Default for Gene). All are documented in rustdoc, and tests cover the chosen behaviour.Results unchanged. Banco A (
xor_bench 50 500 init reset=1 seed=S), develop 0bb2e78 vs this branch, SUMMARY lines identical excepttotal_secs:seeds 1/101/201/301 → 50/50 solved each, medians 52/53/53/51, means 52.6/53.6/52.0/50.4.
ref #103
Part of epic #55
🤖 Generated with Claude Code