fix sbx crossover and nsga2 initial population bounds checks - #630
Open
jschueller wants to merge 2 commits into
Open
fix sbx crossover and nsga2 initial population bounds checks#630jschueller wants to merge 2 commits into
jschueller wants to merge 2 commits into
Conversation
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
The new initial-population bounds check still accepts NaN, because both NaN < lower and NaN > upper are false. Reject non-finite genes explicitly before the range comparison and add a NaN/Inf population regression so invalid decision variables cannot enter NSGA-II.
clamp non-finite crossover results to bounds. When parent genes violate problem bounds, sbx_betaq can produce NaN via std::pow with a negative base, which then propagates into children. Use std::clamp guarded by std::isfinite to ensure c1/c2 are always valid.
in evolve reject initial population with out-of-bounds individuals. Previously NSGA-II would proceed with invalid genes, allowing NaN to be generated during crossover. Now it throws std::invalid_argument.
Contributor
Author
|
@sylvesterkaczmarek done |
sylvesterkaczmarek
approved these changes
Sep 6, 2026
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
The initial population check now rejects non-finite genes explicitly before the range comparison, and the tests cover NaN and infinities in addition to ordinary out-of-bounds values. This resolves my review finding.
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.
see #567