title: How to make a function pickable so that it can be minimized through the parallel version of scipy.optimize.differential_evolution
body: <p>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.</p>
  <p>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.</p>
  <p>The function to minimize works in the following way:</p>
  <ul>
  <li>A class object has an attribute vector, the observed data.</li>
  <li>One method of the class takes some parameters and compute an estimate of the vector.</li>
  <li>The function to minimize compute the mean square error between the vector and the computed estimate.</li>
  </ul>
  <p>The pseudocode of the function could be something like that:</p>
  <pre><code>def function_to_minimize(self, parameters):
      true_vector = self.true_vector
      estimated_vector = self.estimate_vector(parameters)
      return mse(true_vector, estimated_vector)
  </code></pre>