Open
Conversation
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.
Related Issue / Discussion:
Fixes Issue #164
Relates to discussion #164
Changes:
Please list the central functionalities that have been changed:
Modified WeatherRoutingTool/algorithms/genetic/init.py to add proper guards in Genetic.terminate() for cases when no feasible solution exists.
Further Details:
Summary:
This pull request addresses a crash in the genetic algorithm when no feasible solution is found.
Before this PR:
When the genetic algorithm returned no feasible solutions (e.g., due to water_depth constraints), res.F and res.X were None.
Genetic.terminate() attempted to access res.F.argmin(), causing an AttributeError and crashing the program.
After this PR:
Added checks in Genetic.terminate() to verify res, res.F, and res.X are not None or empty.
If no feasible solution exists, a descriptive exception is raised:
No feasible solution found, all candidates violated constraints. Please rerun.
This ensures the algorithm fails gracefully and provides clear feedback to the user.
Dependencies:
No new dependencies are required.
PR Checklist:
In the context of this PR, I: