https://github.com/ec-kity/dnc
A Deep Neural Crossover Plugin for ECKity
https://github.com/ec-kity/dnc
Last synced: 4 months ago
JSON representation
A Deep Neural Crossover Plugin for ECKity
- Host: GitHub
- URL: https://github.com/ec-kity/dnc
- Owner: EC-KitY
- Created: 2024-04-10T13:04:45.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-21T13:30:09.000Z (about 1 year ago)
- Last Synced: 2025-10-08T16:40:23.298Z (8 months ago)
- Language: Python
- Size: 309 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Deep Neural Crossover (DNC)
This repository implements the **Deep Neural Crossover (DNC)** operator as described in the paper:
**"Deep Neural Crossover: A Multi-Parent Operator That Leverages Gene Correlations"**
[ACM Link](https://dl.acm.org/doi/abs/10.1145/3638529.3654020)

---
## 🚀 Quick Start
To run a full example using the DNC operator on the **Bin Packing Problem**, execute:
```bash
python dnc_runner_eckity.py
```
This example uses:
- Integer vector representation of solutions.
- A domain-specific fitness evaluator for bin packing.
- Tournament selection, and n-point mutation.
---
## 📁 File Structure
- `dnc_runner_eckity.py` - Main script running the evolutionary algorithm with the DNC operator.
- `datasets/hard_parsed.json` - A JSON file containing bin packing datasets used in the paper.
- Custom components:
- `BinPackingEvaluator` - Evaluates fitness based on bin packing constraints.
---
## Customization Guide
To use this code for a different problem domain, **only a few parts need to be modified**:
### 1. Define a Custom Evaluator
Replace `BinPackingEvaluator` with a custom class that inherits from `SimpleIndividualEvaluator`:
```python
class YourEvaluator(SimpleIndividualEvaluator):
def evaluate_individual(self, individual):
# return a float indicating fitness
return your_fitness_function(individual.vector)
```
### 2. Update the Creator (if needed)
If you need special initialization, adjust `GAIntegerStringVectorCreator`.
### 3. Configure DNC
The DNC operator requires setting the correct number of embedding dimensions, which should correspond to the **number of distinct values each gene can take** (i.e., the number of bins, colors, etc.).
```python
DeepNeuralCrossoverConfig(
gene_value_dim=MAX_GENE_VALUE + 1,
embedding_dim=EMBED_DIM, # e.g., 64
...
)
```
---
## ⚙️ Evolutionary Parameters
You can easily adjust standard evolutionary settings:
```python
population_size = 100
crossover_rate = 0.5
mutation_rate = 0.1
num_generations = 6000
```
These are passed to the `Subpopulation` and `SimpleEvolution` constructors.
---