Skip to content
Tutorials Center
My learning

Topics

Genetic and Evolutionary Algorithms Tutorial

Learn Genetic and Evolutionary Algorithms step by step: 36 lessons in 9 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Are Genetic Algorithms? Learn what a genetic algorithm is, why evolution makes a good search method, and when to use one, with runnable Python that compares random search to evolution.
  2. 2 Evolutionary Computation and Its Vocabulary Learn the vocabulary of genetic algorithms (gene, chromosome, population, fitness, generation) and meet the evolutionary computation family: GA, ES, EP, GP and DE.
  3. 3 Your First Genetic Algorithm in Python Build a complete genetic algorithm from scratch in Python: initialization, fitness, selection, crossover, mutation and elitism, tested on OneMax and a target string.
  4. 4 The GA Loop, Parameters and Fitness Landscapes Learn how a genetic algorithm is structured, how to choose population size, mutation and crossover rates, when to stop, and why fitness landscapes trap searches.

Representation and Fitness

  1. 5 Binary and Gray Encoding Learn how to encode numbers and choices as bit strings for a genetic algorithm, decode them, and why Gray code fixes the Hamming cliff of plain binary encoding.
  2. 6 Real-Valued Encoding for Genetic Algorithms Encode continuous parameters directly as floating-point genes, handle bounds and mixed gene types, and optimize classic test functions with a real-coded GA in Python.
  3. 7 Permutation Encoding for Ordering Problems Represent tours, schedules and orderings as permutations in a genetic algorithm, evaluate them on a traveling salesman problem, and see why bit-string operators break them.
  4. 8 Designing Fitness Functions Learn how to design fitness functions that guide a genetic algorithm: minimization versus maximization, scaling, noise, shaping partial credit, and avoiding loopholes.
  5. 9 Population Initialization and Diversity Learn how to create the first generation of a genetic algorithm, measure population diversity with Hamming and Euclidean distance, and detect premature convergence.

Selection

  1. 10 Roulette Wheel and Stochastic Universal Sampling Implement fitness-proportionate (roulette wheel) selection and stochastic universal sampling in Python, see how it behaves, and learn its weaknesses with negative or skewed fitness.
  2. 11 Tournament Selection Learn tournament selection, the most popular selection method in genetic algorithms: how tournament size sets selection pressure, with probabilistic and deterministic variants.
  3. 12 Rank, Truncation and Boltzmann Selection Learn rank-based, truncation and Boltzmann selection, plus fitness scaling (windowing, sigma scaling), to control selection pressure independent of raw fitness values.
  4. 13 Selection Pressure, Elitism and Takeover Time Quantify selection pressure with takeover time, compare generational and steady-state replacement, and use elitism, (mu+lambda) and crowding to balance speed against diversity.

Crossover and Mutation

  1. 14 Crossover for Binary Strings Learn one-point, two-point, k-point and uniform crossover for bit-string genetic algorithms, with Python code, positional bias, and when to prefer each operator.
  2. 15 Crossover for Real Values: Blend, Arithmetic and SBX Learn crossover operators for real-valued chromosomes: discrete, arithmetic, BLX-alpha blend and simulated binary crossover (SBX), with Python code and their effect on diversity.
  3. 16 Crossover for Permutations: OX, PMX, Cycle and Edge Learn permutation crossover operators that always produce valid tours: order crossover (OX), partially mapped (PMX), cycle (CX) and edge recombination, with tested Python code.
  4. 17 Mutation Operators: Bit-Flip, Gaussian and Polynomial Learn mutation for every encoding: bit-flip, uniform, Gaussian, polynomial and boundary mutation for numbers, plus swap, insert and inversion for permutations, with mutation-rate guidance.
  5. 18 Parameter Control and Self-Adaptation Stop hand-tuning mutation and crossover rates: learn deterministic schedules, the 1/5 success rule, self-adaptive step sizes and feedback control, with Python examples.

Constraints and Multi-objective

  1. 19 Handling Constraints with Penalty Functions Learn how to keep a genetic algorithm inside the rules. Build static, dynamic and adaptive penalty functions and see how penalty strength changes the search.
  2. 20 Repair Operators and Decoders Keep every individual feasible by construction. Learn repair functions, random-key decoders and greedy decoders with runnable knapsack and scheduling examples.
  3. 21 Multi-objective Optimization and Pareto Dominance Optimize several goals at once. Learn Pareto dominance, non-dominated sorting and the Pareto front, plus the weighted-sum trap, with runnable Python examples.
  4. 22 NSGA-II from Scratch Build NSGA-II, the classic multi-objective genetic algorithm, in under 80 lines of Python. Covers ranking, crowding tournaments, elitism and the ZDT1 benchmark.

Swarm and Other Metaheuristics

  1. 23 Particle Swarm Optimization Learn how particle swarm optimization works: velocity, inertia, personal and global best. Build PSO in NumPy, tune its parameters and compare it with a genetic algorithm.
  2. 24 Differential Evolution Learn differential evolution, a powerful evolutionary optimizer for real-valued problems. Build DE/rand/1/bin from scratch, tune F and CR, and use scipy.optimize.
  3. 25 Simulated Annealing and Hill Climbing Compare single-solution metaheuristics with genetic algorithms. Code hill climbing, random restarts and simulated annealing in Python, and learn when each wins.
  4. 26 Ant Colony Optimization Understand ant colony optimization (ACO): pheromone trails, heuristic information and evaporation. Build an Ant System for the traveling salesman problem in Python.

Genetic Programming

  1. 27 Genetic Programming: Evolving Programs Learn genetic programming (GP): evolve programs as expression trees. Build trees, evaluate them, apply subtree crossover and mutation, and run a tiny GP in Python.
  2. 28 Symbolic Regression with Genetic Programming Discover a formula from data with genetic programming. Build a full symbolic regression GP with tournament selection, depth limits and parsimony pressure in Python.

Applications and Tuning

  1. 29 Tuning GA Parameters Learn to tune genetic algorithm parameters with evidence: population size, mutation and crossover rates, tournament size and elitism, using repeated runs and diversity metrics.
  2. 30 Fitness Caching and Parallel Evaluation Make genetic algorithms faster. Cache repeated fitness evaluations, vectorize with NumPy, evaluate in parallel with multiprocessing, and use cheap surrogate models.
  3. 31 Feature Selection with a Genetic Algorithm Use a genetic algorithm to choose the best subset of features for a machine learning model. Bit-mask chromosomes, cross-validated fitness and a size penalty in Python.
  4. 32 A Genetic Algorithm for the Traveling Salesman Problem Solve the traveling salesman problem with a genetic algorithm in Python. Permutation encoding, order crossover, swap and inversion mutation, and a 2-opt memetic upgrade.

Projects and Practice

  1. 33 Project: Knapsack Optimizer Build a complete 0/1 knapsack optimizer with a genetic algorithm, check it against the exact dynamic programming answer, and report gap, speed and reliability.
  2. 34 Project: Evolve a Neural Network Train a small neural network without backpropagation. Evolve its weights with a genetic algorithm on XOR and a two-class dataset, using only NumPy.
  3. 35 Practice: Benchmark GA, DE and PSO Compare a real-coded genetic algorithm, differential evolution and particle swarm optimization fairly on standard benchmark functions, with equal budgets and many seeds.
  4. 36 Practice Exercises and Where to Go Next Test your skills with hands-on genetic algorithm exercises (starter code included), a design checklist for new problems, and a roadmap of libraries and topics to explore next.