Skip to main content

Deep Neural Crossover operator for EC-KitY

Project description

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, and NumPy dependencies.

Usage

Import the public API from eckity_dnc:

from eckity_dnc import (
    DeepNeuralCrossover,
    DeepNeuralCrossoverConfig,
    GAIntegerStringVectorCreator,
)

Create the vector creator and DNC operator:

population_size = 100
individual_length = 160
number_of_gene_values = 161

individual_creator = GAIntegerStringVectorCreator(
    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.9 or newer
  • EC-KitY 0.4.x (tested with 0.4.1)
  • PyTorch 2.7.x (tested with 2.7.1)
  • NumPy 1.26.x

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.

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

eckity_dnc-0.1.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eckity_dnc-0.1.0-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file eckity_dnc-0.1.0.tar.gz.

File metadata

  • Download URL: eckity_dnc-0.1.0.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.7

File hashes

Hashes for eckity_dnc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e04f0916d602acbd1ab967a864a4ff4ab21cd04d63318d21142f5224e8e2a51e
MD5 aea26270f7b8f1c7b0921685628874f6
BLAKE2b-256 f75678bc3b0ad0331790599664d6472177cfa8d47ca594fbcbe75ae915b12e7e

See more details on using hashes here.

File details

Details for the file eckity_dnc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: eckity_dnc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.7

File hashes

Hashes for eckity_dnc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c7da49a1502a803eb036eb36530143a83f7ec002a208a0d0f0e9d7cbe481df9
MD5 42e29853c58f79391eb57af8903e7257
BLAKE2b-256 74a845ab548c09ba020315b110c5ec10255e5b1e8bc1133d287b0f38a5940328

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page