Skip to content

Fix SpeciatedFitnessEliminator observer to receive pre-division fitness values#152

Merged
HyperCodec merged 5 commits intodevfrom
copilot/fix-fitness-observer-values
Mar 11, 2026
Merged

Fix SpeciatedFitnessEliminator observer to receive pre-division fitness values#152
HyperCodec merged 5 commits intodevfrom
copilot/fix-fitness-observer-values

Conversation

Copy link
Contributor

Copilot AI commented Mar 11, 2026

  • Explore codebase and understand the issue
  • Modify SpeciatedFitnessEliminator to pass pre-division fitness values to the observer
  • Extract private calculate_fitnesses helper with #[cfg]-gated rayon/non-rayon variants
  • Rayon variant: species clustering is sequential; fitness function calls run in parallel via par_iter()
  • Fix cargo fmt formatting issues
  • Add test observer_receives_pre_division_fitness verifying the observer sees raw values (1.0 and 0.5) and does NOT see the divided value (0.25)
  • All tests pass with and without the rayon feature
Original prompt

This section details on the original issue you should resolve

<issue_title>FitnessObserver on SpeciatedFitnessEliminator should be passed pre-division values.</issue_title>
<issue_description>In order to maintain balanced species, the speciated eliminator divides by the total number of genomes in the species. However, due to the way it is set up currently, the observer function only sees the values after they have been divided. For better graphs and such, it would be beneficial to provide the actual fitness to observers.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…tness values

Co-authored-by: HyperCodec <72839119+HyperCodec@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix FitnessObserver on SpeciatedFitnessEliminator to pass pre-division values Fix SpeciatedFitnessEliminator observer to receive pre-division fitness values Mar 11, 2026
@HyperCodec HyperCodec marked this pull request as ready for review March 11, 2026 13:11
Copy link
Owner

@HyperCodec HyperCodec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably split this up into helper functions (or replace calculate_and_sort) for cleanliness. Also cargo fmt check is failing in the CI, so make sure your code is formatted nicely.

Co-authored-by: HyperCodec <72839119+HyperCodec@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 11, 2026

Probably split this up into helper functions (or replace calculate_and_sort) for cleanliness. Also cargo fmt check is failing in the CI, so make sure your code is formatted nicely.

Done in 4be3589. Extracted a private calculate_fitnesses helper that computes both raw and divided fitness vectors in one pass — calculate_and_sort and eliminate now both delegate to it, removing all the duplication. The cargo fmt issue is also fixed.

Copy link
Owner

@HyperCodec HyperCodec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you removed rayon feature support, which means it's going to be horribly slow. the fitness functions must be run in parallel whenever the rayon feature is enabled, as these fitness functions often make up the majority of CPU time.

Co-authored-by: HyperCodec <72839119+HyperCodec@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 11, 2026

you removed rayon feature support, which means it's going to be horribly slow. the fitness functions must be run in parallel whenever the rayon feature is enabled, as these fitness functions often m...

Fixed in 8909fc2. calculate_fitnesses now has #[cfg]-gated variants: the non-rayon version uses sequential loops as before; the rayon version does the species clustering sequentially (greedy pass), then evaluates all fitness functions in parallel via par_iter().zip(). I also extracted fitness_fn as a local reference before the parallel section to avoid capturing self.ctx (which may not be Sync) in the closure.

@HyperCodec HyperCodec merged commit 7e0c670 into dev Mar 11, 2026
4 checks passed
@HyperCodec HyperCodec deleted the copilot/fix-fitness-observer-values branch March 11, 2026 16:09
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.

2 participants