Cooperative Co-evolutionary Differential Evolution algorithms in Python.
Project description
decc: Cooperative Co-evolutionary Differential Evolution
Cooperative Co-evolutionary Differential Evolution algorithms in Python with NumPy.
This repository provides simple implementations for some CC-based DE algorithms. All the implementations are from scratch using NumPy, they might slightly differ from the original papers.
Quick Start
The decc library works with two entities:
Problemrepresents a minimization problem (objective function, dimensionality and bounds).- The objective function must receives a matrix as input (each row represents a solution) and produce a matrix as output (each row is the objective value for the respective solution).
Optimizerrepresents a DE algorithm for solving a minimization problem.- Maximization of a real function
gis equivalent to minimize-g.
- Maximization of a real function
In order to use an optimizer, you must first define a problem. Currently, there are two optimizer available: (i) DECC (also known as CCDE), with the variants DECC-O and DECC-H; and (ii) DECC-G. A basic example is found below:
import numpy as np
from decc import Problem
from decc.optimizers.decc import DECCOptimizer
from decc.optimizers.decc_g import DECCGOptimizer
def objective(x: np.ndarray) -> np.ndarray:
# The Sphere function is a common
# benchmark for optimizers
return np.sum(x ** 2, axis=-1)
# First, we must define the problem
problem = Problem(objective,
dims=100,
lower_bound=-100.0,
upper_bound=100.0)
# Then, we can instantiate the optimizers
F = 0.5
CR = 0.8
seed = 42
max_fn = int(1e5)
pop_size = 50
decc_h = DECCOptimizer(problem,
seed,
pop_size,
grouping='halve',
F=F,
CR=CR,
max_fn=max_fn)
decc_o = DECCOptimizer(problem,
seed,
pop_size,
grouping='dims',
F=F,
CR=CR,
max_fn=max_fn)
decc_g = DECCGOptimizer(problem,
seed,
pop_size,
n_subproblems=max(1, problem.dims // 4),
sansde_evaluations=max_fn // 3,
de_evaluations=max_fn // 5,
F=F,
CR=CR,
max_fn=max_fn)
# Lastly, we can optimize the objective and
# retrieve the results.
for optimizer in [decc_o, decc_h, decc_g]:
result = optimizer.optimize()
print(f'{optimizer}: {result["best_fitness"]}')
# DECC-O: 1.638248431845568e-05
# DECC-H: 0.0006988301174715161
# DECC-G: 1.5340782547163752e-10
Roadmap
- Add support for
DECC-DG; - Add support for
DECC-gDG; - Improve documentation;
- Add unit tests;
- Add validation benchmark functions from the original papers;
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file decc-0.2.3.tar.gz.
File metadata
- Download URL: decc-0.2.3.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aad7c3f378effa31358ba53e15501f0e42f6b47e61c4e69a7aa7f483fc92fdac
|
|
| MD5 |
9970b6ed297686aad493cecd807b6157
|
|
| BLAKE2b-256 |
c055d224a0209771a859a38268106002cea11552c6fed7874c17871b3b08657c
|
File details
Details for the file decc-0.2.3-py3-none-any.whl.
File metadata
- Download URL: decc-0.2.3-py3-none-any.whl
- Upload date:
- Size: 19.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f557ec12bb613070e13fe1de475564593215d31513bb4d926615d085afe43002
|
|
| MD5 |
9608253dfb86c6cc800071757dc60203
|
|
| BLAKE2b-256 |
bbf221904824414a5415658dbd2834af81af6bac16f27bbcfa54c14227f6039e
|