Skip to content

mfouesneau/DE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Differential evolution (DE)

This implements only a single class: DiffEvolOptimizer that follows the differential evolution optimization method by Storn & Price (Storn, R., Price, K., Journal of Global Optimization 11: 341--359, 1997, DE original paper)

Main assuption: the heuristic suppose a continuous parameter space.

Full documentation at: http://mfouesneau.github.io/docs/de/

Example

def rosenbrock_fn(x):
    """ Rosenbrock function
        global minimum at x = [1, ..., 1], f(x) = 0
    """
    _x = np.array(x)
    return sum(100.0 * (_x[1:] - _x[:-1] ** 2) ** 2. + (1 - _x[:-1]) ** 2.)

from de import DiffEvolOptimizer

# setup the optimization
ngen, npop, ndim = 100, 100, 2
limits = [[-5, 5]] * ndim
de = DiffEvolOptimizer(rosenbrock_fn, limits, npop)

# store all the values during iterations for plotting.
pop = np.zeros([ngen, npop, ndim])
loc = np.zeros([ngen, ndim])
for i, res in enumerate(de(ngen)):
    pop[i,:,:] = de.population.copy()
    loc[i,:] = de.location.copy()

# plot all explored points
ax.scatter(pop[:, :, 0].ravel(), pop[:, :, 1].ravel(),
           c=np.log10(vals + 1e-20), alpha=0.2, edgecolor='None')
# plot the final positions
plt.plot(loc[:, 0], loc[:, 1], 'k.-')

plt.show()

Testing multiple common functions (code included in test.py)

http://mfouesneau.github.io/docs/de/_images/example.png

Relevants links/images

About

Differential Evolution Optimizer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages