From b8c419aa3ca070c2016496091d0ce4bd7757a2a9 Mon Sep 17 00:00:00 2001 From: Rodion Kolovanov Date: Tue, 5 Dec 2023 14:23:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=81=D0=BB=D1=83=D1=87=D0=B0=D0=B5=D0=B2=20?= =?UTF-8?q?=D0=BD=D0=B5=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B8=20=D0=B2=D1=8B=D1=87=D0=B8=D1=81=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D1=86=D0=B5=D0=BB=D0=B5=D0=B2=D0=BE=D0=B9?= =?UTF-8?q?=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- optimization_methods/common/function.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/optimization_methods/common/function.py b/optimization_methods/common/function.py index 86e0623..1ab7b88 100644 --- a/optimization_methods/common/function.py +++ b/optimization_methods/common/function.py @@ -21,4 +21,7 @@ def __call__(self, x: np.array) -> float: args = {} for i in range(0, len(x)): args[f"x{i+1}"] = x[i] - return float(self.function.subs(args)) + try: + return float(self.function.subs(args)) + except Exception as error: + raise RuntimeError(f"Невозможно вычислить вещественное значение целевой функции в точке {x}. {error}.")