Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Differential Evolution in Python

Project Description

Global optimization using differential evolution in Python [Storn97].


git clone
cd PyDE
python install [--user]

Basic usage

Import the class from the package

from import DiffEvol

Create a DiffEvol instance

de = DiffEvol(minfun, bounds, npop)

where minfun is the function to be optimized, bounds is an initialization array, and npop is the size of the parameter vector population.

Now, you can run the optimizer ngen generations:

res = de.optimize(ngen=100)

or run the optimizer as a generator:

for res in de(ngen=100):
    do something

Usage with emcee

The PyDE parameter vector population can be used to initialize the affine-invariant MCMC sampler emcee when a simple point estimate of the function minimum (or maximum) is not sufficient:

de = DiffEvol(lnpost, bounds, npop, maximize=True)

sampler = emcee.EnsembleSampler(npop, ndim, lnpost)
sampler.run_mcmc(de.population, 1000)


[Storn97]Storn, R., Price, K., Journal of Global Optimization 11: 341–359, 1997

API (minfun, bounds, npop, F=0.5, C=0.5, seed=0, maximize=False)


minfun:Function to be minimized.
bounds:Parameter space bounds as [npar,2] array.
npop:Size of the parameter vector population.
F:Difference amplification factor. Values between 0.5-0.8 are good in most cases.
C:Cross-over probability. Use 0.9 to test for fast convergence, and smaller values (~0.1) for a more elaborate search.
seed:Random seed.
maximize:An optional switch telling whether we want maximize or minimize the function. Defaults to minimization.
Release History

Release History

This version
History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
PyDE-1.0.1.tar.gz (2.6 kB) Copy SHA256 Checksum SHA256 Source Nov 30, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting