Learn how evolution inspires algorithms β from natural selection to optimization with Python.
Welcome to the Genetic Algorithms Workshop β a hands-on coding series where youβll build, visualize, and understand evolutionary algorithms step by step using Python and the DEAP framework.
This repository contains:
- π§© Interactive exercises (
.ipynb) with guided### TODOsections. - β Full solutions for each problem.
- πΌοΈ The PDF presentation used during the workshop.
- π Links to open each notebook directly in Google Colab.
π Read the full accompanying article here: π Hands-On Genetic Algorithms with Python
-
The intuition behind Genetic Algorithms (GAs) β inspired by Darwinβs theory of evolution.
-
How to represent, mutate, and evolve digital organisms.
-
Step-by-step GA workflow:
- Population initialization
- Fitness evaluation
- Selection, crossover, mutation
- Statistics and visualization
-
Applying GAs to solve problems like:
- π― OneMax Problem β evolve the perfect binary string.
- π Knapsack Problem β maximize value under constraints.
- π©ββοΈ Nurse Scheduling Problem β handle hard and soft constraints.
Genetic-Algorithms-Workshop/
β
βββ π README.md β You are here
βββ π§Ύ slides.pdf β Full presentation
β
βββ notebooks/
β βββ 01_one_max_exercise.ipynb
β βββ 01_one_max_solution.ipynb
β βββ 02_knapsack_exercise.ipynb
β βββ 02_knapsack_solution.ipynb
β βββ 03_nurse_scheduling_exercise.ipynb
β βββ 03_nurse_scheduling_solution.ipynb
You can open each exercise directly in Colab β no installation required!
| Notebook | Exercise | Solution |
|---|---|---|
| π§© OneMax | Open in Colab | View Solution |
| π Knapsack | Open in Colab | View Solution |
| π©ββοΈ Nurse Scheduling | Open in Colab | View Solution |
To run locally:
pip install deap matplotlib seaborn numpy jupyterThen launch Jupyter Notebook:
jupyter notebook notebooks/Start with:
01_one_max_exercise.ipynb
π Download the PDF slides: β‘οΈ slides.pdf
The slides cover:
- The story of Darwin and the finches π¦
- How evolution translates into computation
- Key GA components (population, fitness, mutation)
- Demo visuals and diagrams
| Part | Topic | Description |
|---|---|---|
| π§© 1 | OneMax Problem | Introduction to genetic representation and basic operators. |
| π 2 | Knapsack Problem | Combining value optimization with constraints. |
| π©ββοΈ 3 | Nurse Scheduling | Handling hard and soft constraints using GA. |
Article: Hands-On Genetic Algorithms with Python Learn the theory behind this workshop β how natureβs principles can guide machine intelligence.
Contributions and improvements are welcome! Feel free to open an issue or submit a pull request.
MadBrain Labs is building brain-inspired AI for humanoid robots β merging neuroscience, robotics, and machine learning. Learn more at madbrain.ai
