Scipy's differential evolution implementation (https://docs.scipy.org/doc/scipy-0.17.0/reference/generated/scipy.optimize.differential_evolution.html) uses either a Latin hypercube or a random method for population initialization. Latin hypercube sampling tries to maximize coverage of the available parameter space. ‘random’ initializes the population randomly. I am wondering if it would be possible to specify starting values for each parameter, instead of relying on these default algorithms.
For complex models (particularly those that are mathematically intractable and thus need to be simulated), I have observed that 2 independent runs of scipy's differential evolution likely give different results after X iterations of the algorithm (I usually set X = 100 to avoid running the agorithm during several days). I think it is because (1) population initialization is not identical between 2 independent runs (because of the stochastic nature of the population initialization methods 'random' and 'hypercube') and (2) there's noise in model prediction. I am thus thinking of running ~10 independent runs of DE with 100 iterations, pick-up the best-fitting parameter set across the 10 runs and use this set as the starting values for a final run with more iterations (say 200). The problem is that I see no way to manually enter these starting values within scipy's DE implementation. I would be very grateful if somebody in the community could help me.
This has indeed been possible since version 1.1 of SciPy (note that you're referring to the dated 0.17.0 documentation). In particular, the recent versions lets you specify any array, instead of just 'hypercube'
or 'random'
. From the documentation, a possible value of init
is:
array specifying the initial population. The array should have shape
(M, len(x))
, wherelen(x)
is the number of parameters.init
is clipped to bounds before use.
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.differential_evolution.html
If, for some reason, you're forced to use the old version, it's still possible to obtain what you want by just using the underlying DifferentialEvolutionSolver
instead. There, you can either monkey patch one of the initializing functions, or just run them and manually override the population
attribute post-initialization.