From d576f1d0424791ac80e609dab84a9013969c7bb4 Mon Sep 17 00:00:00 2001 From: poveda_g Date: Mon, 28 Oct 2024 14:46:28 +0100 Subject: [PATCH] raise exception when the rcpsp model is multimode but the model in single mode. --- discrete_optimization/rcpsp/solvers/toulbar.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/discrete_optimization/rcpsp/solvers/toulbar.py b/discrete_optimization/rcpsp/solvers/toulbar.py index d2abd0bf..0dd2dfa9 100644 --- a/discrete_optimization/rcpsp/solvers/toulbar.py +++ b/discrete_optimization/rcpsp/solvers/toulbar.py @@ -54,6 +54,14 @@ def retrieve_solution( ) def init_model(self, **kwargs: Any) -> None: + try: + assert not self.problem.is_rcpsp_multimode() + except AssertionError as exc: + logging.exception( + f"Your problem is multimode, and this toulbar model can't tackle it. " + f"Please go with ToulbarMultimodeRcpspSolver instead." + ) + raise exc model = pytoulbar2.CFN(ubinit=self.problem.horizon) n_jobs = self.problem.n_jobs horizon = self.problem.horizon