Deep Neural Crossover for EC-KitY
eckity-dnc provides the Deep Neural Crossover (DNC) genetic operator for EC-KitY.
DNC is described in “Deep Neural Crossover: A Multi-Parent Operator That Leverages Gene Correlations” (paper).
Installation
pip install eckity-dnc
Installing eckity-dnc also installs its EC-KitY, PyTorch, NumPy, and SciPy dependencies.
Usage
Import the public API from eckity_dnc:
from eckity.creators import GAIntVectorCreator
from eckity_dnc import (
DeepNeuralCrossover,
DeepNeuralCrossoverConfig,
)
Create the vector creator and DNC operator:
population_size = 100
individual_length = 160
number_of_gene_values = 161
individual_creator = GAIntVectorCreator(
length=individual_length,
bounds=(0, number_of_gene_values - 1),
)
dnc_config = DeepNeuralCrossoverConfig(
embedding_dim=64,
sequence_length=individual_length,
num_embeddings=number_of_gene_values,
running_mean_decay=0.95,
batch_size=1024,
learning_rate=1e-4,
use_device="cpu",
n_parents=2,
epsilon_greedy=0.3,
)
dnc_operator = DeepNeuralCrossover(
probability=0.8,
population_size=population_size,
dnc_config=dnc_config,
individual_evaluator=your_eckity_evaluator,
vector_creator=individual_creator,
)
Add dnc_operator to the EC-KitY subpopulation's operators_sequence. The supplied evaluator must inherit from EC-KitY's SimpleIndividualEvaluator and evaluate vectors created by individual_creator.
See dnc_runner_eckity.py for a complete bin-packing example using tournament selection and mutation.
Compatibility
- Python 3.10 or newer
- EC-KitY 0.4.x (tested with 0.4.1)
- PyTorch 2.7.1 or newer (tested with 2.7.1)
- NumPy 2.0.2 or newer (tested with 2.0.2)
- SciPy 1.13.0 or newer (tested with 1.13.0)
Development
Install the package and development tools, then run the tests:
python -m pip install -e ".[dev]"
python -m pytest
Release preparation and manual TestPyPI/PyPI commands are documented in RELEASING.md.
License
This project is licensed under the GNU General Public License v3.0. See LICENSE.
Metadata
Release files for eckity-dnc 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| eckity_dnc-0.1.2.tar.gz | 11.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| eckity_dnc-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.0 kB
Release files / eckity_dnc-0.1.2.tar.gz
| Download URL | eckity_dnc-0.1.2.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
406a7fda7060e72b2802f7358d9df2d0587820e8ca0730966e3c8d8812fe5196
|
|
BLAKE2b-256 checksum How to use checksums |
8a7c52733583b7b1bcb16e59e2cc84bb2a72ffa53afb15dbb8dbfc47476412a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.20
|
Release files / eckity_dnc-0.1.2-py3-none-any.whl
| Download URL | eckity_dnc-0.1.2-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d079cbd3fb61a36c9642e43ec79bb8810f861a15b76c3389bd7907b52c9c78e8
|
|
BLAKE2b-256 checksum How to use checksums |
5264ff6b66bdace2b0827d943f22c6f9c0d0ccc35aeb71cb408b71b948658e68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.20
|