diff --git a/moptipy/api/_process_base.py b/moptipy/api/_process_base.py index 034c2245b..d4ba02983 100644 --- a/moptipy/api/_process_base.py +++ b/moptipy/api/_process_base.py @@ -535,8 +535,15 @@ def _validate_best_f(self) -> None: f"{self._current_best_f}!") # noqa if not isfinite(ff): raise ValueError( # noqa - f"Reproduced the objective value {ff} of the best " - "solution, but it is not finite?") # noqa + f"The objective value {ff} of " # noqa + "the best solution is not finite?") + lb: Final[int | float] = self.__objective.lower_bound() + ub: Final[int | float] = self.__objective.upper_bound() + if not (lb <= ff <= ub): + raise ValueError( # noqa + f"The objective value {ff} of " # noqa + "the best solution is not within the lower and " + f"upper bound, i.e., [{lb}, {ub}]?") # noqa def has_log(self) -> bool: """ diff --git a/moptipy/version.py b/moptipy/version.py index 5db237574..73d8ac008 100644 --- a/moptipy/version.py +++ b/moptipy/version.py @@ -2,4 +2,4 @@ from typing import Final #: the version string of `moptipy` -__version__: Final[str] = "0.9.127" +__version__: Final[str] = "0.9.128"