Skip to content

Commit

Permalink
small modification to parallel
Browse files Browse the repository at this point in the history
(cherry picked from commit 1b1cd18)
  • Loading branch information
FilippoAiraldi committed Nov 15, 2024
1 parent 05e8c4b commit 447eb42
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/csnlp/multistart/multistart_nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def __init__(
) -> None:
super().__init__(*args, starts=starts, **kwargs)
self._parallel_kwargs = parallel_kwargs if parallel_kwargs is not None else {}
self.initialize_parallel()
self._parallel: Optional[Parallel] = None

def initialize_parallel(self) -> None:
"""Initializes the parallel backend."""
Expand All @@ -410,6 +410,8 @@ def solve_multi(
) -> Union[Solution[SymType], list[Solution[SymType]]]:
if self._solver is None:
raise RuntimeError("Solver uninitialized.")
if self._parallel is None:
self.initialize_parallel()
shared_kwargs = {
"lbx": self._lbx.data,
"ubx": self._ubx.data,
Expand Down Expand Up @@ -447,7 +449,7 @@ def __getstate__(self, fullstate: bool = False) -> dict[str, Any]:
def __setstate__(self, state: Optional[dict[str, Any]]) -> None:
if state is not None:
self.__dict__.update(state)
self.initialize_parallel()
self._parallel = None


class MappedMultistartNlp(MultistartNlp[SymType], Generic[SymType]):
Expand Down

0 comments on commit 447eb42

Please sign in to comment.