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;
Metadata
Release files for decc 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| decc-0.2.3.tar.gz | 14.4 kB | Without provenance | Details for decc-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| decc-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for decc-0.2.3-py3-none-any.whl |
Total release size: 33.8 kB
Release files / decc-0.2.3.tar.gz
| Download URL | decc-0.2.3.tar.gz |
|---|---|
| Size | 14.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aad7c3f378effa31358ba53e15501f0e42f6b47e61c4e69a7aa7f483fc92fdac
|
|
BLAKE2b-256 checksum How to use checksums |
c055d224a0209771a859a38268106002cea11552c6fed7874c17871b3b08657c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.18
|
Release files / decc-0.2.3-py3-none-any.whl
| Download URL | decc-0.2.3-py3-none-any.whl |
|---|---|
| Size | 19.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f557ec12bb613070e13fe1de475564593215d31513bb4d926615d085afe43002
|
|
BLAKE2b-256 checksum How to use checksums |
bbf221904824414a5415658dbd2834af81af6bac16f27bbcfa54c14227f6039e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.18
|
Security for decc 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.