Skip to content

Fix genetic crash#183

Open
shreyadesai20042009 wants to merge 2 commits into52North:mainfrom
shreyadesai20042009:fix-genetic-crash
Open

Fix genetic crash#183
shreyadesai20042009 wants to merge 2 commits into52North:mainfrom
shreyadesai20042009:fix-genetic-crash

Conversation

@shreyadesai20042009
Copy link
Copy Markdown

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:

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.

1 participant