Skip to content

Fix SpeciatedFitnessEliminator to sort FitnessObserver inputs by raw fitness#155

Merged
HyperCodec merged 4 commits intomainfrom
copilot/fix-fitnessobserver-sorting
Mar 11, 2026
Merged

Fix SpeciatedFitnessEliminator to sort FitnessObserver inputs by raw fitness#155
HyperCodec merged 4 commits intomainfrom
copilot/fix-fitnessobserver-sorting

Conversation

Copy link
Contributor

Copilot AI commented Mar 11, 2026

  • Update SpeciatedFitnessEliminator::eliminate (non-rayon + rayon) to sort observer inputs by raw fitness before calling observer
  • Add doc comment to FitnessObserver::observe noting inputs are sorted descending by fitness
  • Add test observer_receives_fitness_sorted_by_raw_descending verifying observer receives raw-fitness-descending order
  • Fix test: construct genomes with the low-fitness genome first so the input is deliberately unsorted, making the test fail if sorting is absent
Original prompt

This section details on the original issue you should resolve

<issue_title>New FitnessObserver fix still doesn't quite sort exactly as previously</issue_title>
<issue_description>The new FitnessObserver fix does use the correct fitness, but it is still sorted by the species-balanced versions. However, I think it should be implied that FitnessObserver inputs should always be sorted by fitness. Might incur extra performance cost though.

Probably should also add a doc comment about it being sorted before passed in.</issue_description>

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


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…tnessEliminator

Co-authored-by: HyperCodec <72839119+HyperCodec@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix sorting issue in FitnessObserver input Fix SpeciatedFitnessEliminator to sort FitnessObserver inputs by raw fitness Mar 11, 2026
@HyperCodec HyperCodec marked this pull request as ready for review March 11, 2026 17:55
Copilot AI review requested due to automatic review settings March 11, 2026 17:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes SpeciatedFitnessEliminator so FitnessObserver::observe receives fitness values sorted by raw (pre-division) fitness, aligning the ordering with the values being observed while preserving speciation-aware elimination behavior (which still uses divided fitness).

Changes:

  • Sort observer inputs by raw fitness (rayon + non-rayon), then re-sort by divided fitness for truncation/selection.
  • Document FitnessObserver::observe input ordering contract (descending by fitness).
  • Add an integration test validating raw-fitness ordering for observer inputs under speciation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
genetic-rs-common/src/builtin/eliminator.rs Adjusts SpeciatedFitnessEliminator::eliminate to sort observer inputs by raw fitness and adds a doc note about descending order.
genetic-rs/tests/speciation.rs Adds a new test ensuring the speciated eliminator’s observer sees raw fitness values in descending order.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: HyperCodec <72839119+HyperCodec@users.noreply.github.com>
@HyperCodec HyperCodec merged commit c93dd6b into main Mar 11, 2026
4 checks passed
@HyperCodec HyperCodec deleted the copilot/fix-fitnessobserver-sorting branch March 11, 2026 18:12
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.

New FitnessObserver fix still doesn't quite sort exactly as previously

3 participants