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

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.1.tar.gz (10.2 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.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: eckity_dnc-0.1.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.20

File hashes

Hashes for eckity_dnc-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7b067445a9b854f02741ae5316643cd8cb30347d44fd1fe5a4365fa2eff53fb5
MD5 907b5ea92b00c9119f37bbe7c76f056b
BLAKE2b-256 79ad07442ceabd4cceeb3881882f94fcb26a2b4eb3f4a3f69069575de7c7406a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: eckity_dnc-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.20

File hashes

Hashes for eckity_dnc-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c32b39232dd2c3d7040dbe8221b1ee039b1ffb6ca5e9d534415a0786cc7f5f05
MD5 31faf1c7e4559e82ac83d9826dd51ab6
BLAKE2b-256 7647b56463789e3498df1b13867f8cfb3797bb67c123bcf7c6a929c71b8642dd

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