This project implements a simple genetic algorithm with the following features:
- Binary and real encoding for individuals
- Configurable hyperparameters (population size, generations, etc.)
- Multiple selection methods: elitist, roulette, ranking (v1/v2), tournament, steady-state, crowding factor
- Multiple crossover methods: uniform, arithmetic, flat, BLX-α, PMX (for permutations)
- Multiple mutation methods: random, uniform, non-uniform, swap
- Fitness function for n alleles
- Generation results table (Individual, Mapping, DNA, Fitness)
- Visualization: best and average fitness per generation
- Configure parameters in
main.py. - Run the project:
python main.py - View results and evolution graphs.
src/individual.py: Individual representationsrc/population.py: Population managementsrc/selection.py: Selection methodssrc/crossover.py: Crossover methodssrc/mutation.py: Mutation methodssrc/fitness.py: Fitness functionsrc/visualization.py: Plotting resultssrc/main.py: Main script
- Python 3.8+
- matplotlib
- numpy
Install dependencies:
pip install matplotlib numpy