Skip to content

Commit

Permalink
Joblib Parallelization (anyoptimization#382)
Browse files Browse the repository at this point in the history
* added Joblib Parallelization

* updated JoblibParallelization
  • Loading branch information
JSchmie authored Apr 3, 2023
1 parent a984a0a commit c6c7fac
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pymoo/core/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ def __getstate__(self):
return state


class JoblibParallelization:

def __init__(self, aJoblibParallel, aJoblibDelayed, *args, **kwargs) -> None:
super().__init__()
self.parallel = aJoblibParallel
self.delayed = aJoblibDelayed

def __call__(self, f, X):
return self.parallel(self.delayed(f)(x) for x in X)

def __getstate__(self):
state = self.__dict__.copy()
state.pop("parallel", None)
state.pop("delayed", None)
return state


class Problem:
def __init__(self,
n_var=-1,
Expand Down

0 comments on commit c6c7fac

Please sign in to comment.