I need to minimize a function using the scipy implementation of differential evolution. I'd like to exploit parallelism to speed up the computation and I tried setting workers=-1.
I get an error and searching I found that the problem is that the function that I'm trying to minimize is not pickable. I need help to understand how to make it pickable.
The function to minimize works in the following way:
- A class object has an attribute vector, the observed data.
- One method of the class takes some parameters and compute an estimate of the vector.
- The function to minimize compute the mean square error between the vector and the computed estimate.
The pseudocode of the function could be something like that:
def function_to_minimize(self, parameters):
true_vector = self.true_vector
estimated_vector = self.estimate_vector(parameters)
return mse(true_vector, estimated_vector)