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. SciPy is declared here because EC-KitY 0.4.2 imports it without declaring it as a dependency.
Usage
Import the public API from eckity_dnc:
from eckity.creators import GAIntVectorCreator
from eckity_dnc import (
DNCFitnessEvaluator,
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),
)
fitness_evaluator = DNCFitnessEvaluator(your_eckity_evaluator)
dnc_config = DeepNeuralCrossoverConfig(
embedding_dim=64,
sequence_length=individual_length,
num_embeddings=number_of_gene_values,
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=fitness_evaluator,
vector_creator=individual_creator,
)
Add dnc_operator to the EC-KitY subpopulation's operators_sequence, and use the same fitness_evaluator instance as the subpopulation's evaluator. The wrapped evaluator must inherit from EC-KitY's SimpleIndividualEvaluator and evaluate vectors created by individual_creator. Sharing the adapter lets EC-KitY reuse fitness values that DNC computed while training instead of evaluating unchanged crossover children twice.
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.2)
- 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 (required by EC-KitY 0.4.2)
Development
Install the package and development tools, then run the tests:
python -m pip install -e ".[dev]"
python -m pytest
License
This project is licensed under the GNU General Public License v3.0. See LICENSE.
Metadata
Release files for eckity-dnc 0.2.0
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.2.0.tar.gz | 16.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| eckity_dnc-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.1 kB
Release files / eckity_dnc-0.2.0.tar.gz
| Download URL | eckity_dnc-0.2.0.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
374dd5145c06ac17759361f6301aead1362de7ba3b263ec6c157d9e0997fc027
|
|
BLAKE2b-256 checksum How to use checksums |
cf75f6fd80adbb533365c326bd9aaf1c762d088f4c0eba0afdef9897cc4d75c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.20
|
Release files / eckity_dnc-0.2.0-py3-none-any.whl
| Download URL | eckity_dnc-0.2.0-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
167e8d1f60860f1885eacec3cbce9a346c0c69cad68bc45b71b9399c7f3a6d44
|
|
BLAKE2b-256 checksum How to use checksums |
adc188bb5fa003aa80febab4fb489d2aee166580e6c0e90fa5a7da2680321342
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.20
|