🧬 Genetic Algorithms
Evolutionary optimization — searching a solution space by breeding better answers, generation after generation.
🎯 Core Concept
🔑 Key Components
Chromosome
An encoded candidate solution — often a bitstring or vector of ‘genes’ representing the parameters being optimized.
Fitness Function
Scores how good each solution is. It defines the objective and steers the whole search — design it carefully.
Crossover
Recombines two parents at a cut point to produce offspring, blending traits and enabling large exploratory jumps.
Mutation
Randomly perturbs genes with small probability. Injects diversity and prevents premature convergence to a local optimum.
⚙️ How It Works
- Initialize a random population of chromosomes.
- Evaluate each individual with the fitness function.
- Select fitter parents (tournament or roulette-wheel — higher fitness, higher odds).
- Crossover selected parents to breed a new generation of offspring.
- Mutate offspring slightly, then repeat until fitness plateaus or a generation budget is hit.
🌎 Real-World Applications
🧪 Checkpoint Questions
1. Why does a GA maintain a whole population rather than improving a single solution like gradient descent?
Hint: think about escaping local optima and exploring a rugged, non-differentiable landscape in parallel.
2. What breaks if you set the mutation rate to zero — and what breaks if you set it too high?
Hint: zero mutation kills diversity (premature convergence); too much turns evolution into random search.
3. When would you reach for a GA instead of gradient descent or a convex solver?
Hint: no usable gradient, discrete/combinatorial variables, or a highly multimodal objective.
