Imagine natural evolution (survival of the fittest). In nature, strong individuals survive, mate with other strong individuals, and produce even stronger babies. Sometimes a random mutation gives a baby a superpower. GA uses this exact same concept to solve math problems by breeding "chromosomes" representing solutions!
How is GA different from PSO & ACO?
GA
PSO
ACO
Inspired by
Evolution / Genetics
Birds flocking
Ants finding food
Mechanism
Crossover & Mutation
Velocity updates
Pheromone deposits
Representation
Binary strings (0101)
Continuous numbers
Discrete choices
Memory
None (only current pop)
Remembers Personal Best
Pheromone memory
Key Terms Explained
Term
Symbol
Simple Meaning
Chromosome / Genotype
-
A single solution encoded as a binary string (e.g., 101011). Think of it as a person's DNA.
Phenotype
x
The real, decoded value of the chromosome (e.g., length = 15.5m).
Gene / Allele
-
A single bit (0 or 1) inside the chromosome.
Population Size
m
The number of chromosomes (solutions) currently alive in a generation.
Fitness Function
F(x)
How "good" a solution is. Better fitness = more likely to survive and reproduce.
Penalty Function
P(x)
If a solution breaks a rule (e.g., stress is too high), we subtract a massive penalty from its fitness so it dies out.
Crossover Prob.
pc
Mating chance. How often parents swap DNA to create babies (usually 80-90% or 0.8-0.9).
Mutation Prob.
pm
Random flip chance. Tiny chance (e.g., 1-5%) a bit flips (0→1). Prevents inbreeding and getting stuck.
Bits per Variable
L
How many 0s and 1s represent one variable. More bits = higher accuracy (e.g., 4 bits max = 15, 8 bits max = 255).
Step-by-Step Walkthrough with Example
Step 1: Encoding & Initialization
Convert the continuous range (e.g., 0.15 to 0.40) into binary. Let's use 4 bits (max value = 15). We generate a random population:
Formula: Real Value = Min + Decimal × (Max - Min) / (2^bits - 1)
We generate a random number r between 0 and 1 to pick parents:
If r = 0.250 → Falls in P2's range (0.125 to 0.375) → Parent 2 is selected!
If r = 0.810 → Falls in P3's range (0.375 to 1.000) → Parent 3 is selected!
Step 4: Crossover (Mating)
We take selected Parent 2 and Parent 3, pick a random cut point (e.g., after the 2nd bit), and swap their tails:
Parent 2: 00 | 11
Parent 3: 11 | 11
Child 1 : 00 | 11 (Took head of P2, tail of P3)
Child 2 : 11 | 11 (Took head of P3, tail of P2)
Step 5: Mutation
We check every bit of Child 1 (0011). Let's say the 3rd bit gets lucky and mutates (flips):
Child 1 (Before): 0011
Child 1 (After) : 0001 (The '1' flipped to '0')
Step 6: Repeat
The mutated children replace the old parents to form Generation 2. We repeat Steps 1-5 until the maximum number of generations is reached or the best fitness stops improving.
Optimization Dashboard
Ready
Best Feasible Solution
Run the optimization to see results.
Convergence Log
Gen
Best Fitness
Best Values
SF (Std Dev)
Detailed Calculations (Generation 1 Step-by-Step)
Run the optimization to see step-by-step GA calculations.
All Generations Population Details
Run the optimization to see population details for all generations.