Skip to content

Fix: fail when optimiser returns no feasible solution#165

Open
Her0n24 wants to merge 1 commit into52North:mainfrom
Her0n24:fix/genetic-no-feasible-solution
Open

Fix: fail when optimiser returns no feasible solution#165
Her0n24 wants to merge 1 commit into52North:mainfrom
Her0n24:fix/genetic-no-feasible-solution

Conversation

@Her0n24
Copy link
Copy Markdown

@Her0n24 Her0n24 commented Mar 8, 2026

Related Issue / Discussion:

This PR addresses https://github.com/52North/WeatherRoutingTool/issues/164
Relates to #29 (closed)
Fixes Issue #164

Changes:

Please list the central functionalities that have been changed:

  • Modified: Guard Genetic.terminate() against empty/ None optimisation results and raise a descriptive error that is causing the crash
  • New: test_genetic_termination.py is a regression test that asserts Genetic.terminate() fails fast with a clear RuntimeError when the result is empty

Summary:

Under certain condition/ constraints (e.g. water_depth), the genetic optimiser can end up with no feasible solution. In that case, the result res.F/ res.X are empty or None.

Behavior before
Genetic.terminate() unconditionally called res.F.argmin(), which could crash with AttributeError as res.F/ res.X were None. This hides the real cause of the error.

Behavior after
Genetic.terminate() detects None in res.F/ res.X and raises a clear RuntimeError explaining no feasible route found and suggesting to relax constraints.

Dependencies:

No new runtime dependencies.

PR Checklist:

In the context of this PR, I:

@kdemmich kdemmich added the enhancement New feature or request label Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants