Genetic Algorithm (One-Max) Calculator

Read the Theory Guide →

Enter a population of binary chromosomes, choose how fitness is scored, and define crossover and mutation rules. The solver runs one evolution cycle and shows fitness evaluation, ranking, crossover, mutation, and the final generation.

What You Can Explore

  • Edit the population of binary chromosomes. Each chromosome must contain only 0s and 1s, and all chromosomes must have the same length.
  • Choose Count 1s or Count 0s as the fitness criterion to change how chromosomes are scored and ranked.
  • Add, edit, or remove crossover rules by selecting two ranked parents and a crossover cut bit, or mutation rules by selecting a child and bit position.
  • Press Run Evolution Cycle to follow the population from fitness evaluation and selection through crossover, mutation, and final-generation fitness.
Core Mechanics
▼
  • The "Hello World" of GAs: The objective is embarrassingly simple: breed a chromosome of pure 11s. The fitness score requires absolutely no complex math—just count the total number of 11s in the string!
  • Survival of the Fittest: Strings with more 11s are prioritized to become parents. On an exam or trace table, you simply rank the population by their fitness scores, pair up the winners, and leave the losers behind.
  • Targeted Crossover: Just like the Knapsack problem, you will be given an exact crossover point. Slice both parent strings at that specified index and swap their tails to combine their winning bits into a strictly better child.
  • Mutation (The Rescue Operation): If your entire population accidentally loses the 11 at a specific position, crossover can never bring it back! You will be instructed to mutate a specific bit (flipping a 00 back to a 11) to rescue that lost genetic material.
Initializing Workspace...

Understanding Your Result

The evolution cycle uses your population, fitness criterion, crossover rules, and mutation rules to produce one new generation. The solver first evaluates and ranks the original chromosomes, then applies the configured crossover and mutation operations before calculating the fitness of the resulting children.

  • Step 1 evaluates the fitness of the original chromosomes. With Count 1s, a chromosome with more 1s receives a higher fitness; with Count 0s, more 0s produces a higher fitness.
  • Step 2 sorts the chromosomes by fitness and assigns ranked positions such as New #1, New #2, and so on. Crossover rules use these ranked positions rather than the original P1, P2, etc. IDs.
  • Bit positions start at 1. In a crossover rule, the bits after the selected cut point are exchanged between the two selected parents.
  • Step 3 shows the chromosomes produced after crossover and highlights the portions affected by each crossover rule. Children not affected by crossover carry their selected chromosome forward unchanged at this stage.
  • Step 4 applies the configured mutation rules by flipping the selected bit from 0 to 1 or from 1 to 0. Compare this step with Step 3 to see exactly what mutation changed.
  • Step 5 calculates the final fitness of every child and shows whether it was affected by crossover, mutation, or remained unchanged. A higher fitness means the chromosome is better according to the selected fitness criterion.

Try These Experiments

Switch the Fitness Criterion

Setup: Run the preloaded population with Count 1s. P5 has the highest fitness at 8, while P6 has the lowest at 3.

Action: Change Fitness Criteria from Count 1s to Count 0s, keep all crossover and mutation rules unchanged, and run the cycle again.

What to Observe: The fitness values reverse according to the number of 0s: P6 now has fitness 7, while P5 has fitness 2. The ranking in Step 2 changes, so the chromosomes used by the crossover rules also change.

Takeaway: The fitness criterion determines which chromosomes are considered better. Changing it can change the selection order even when the population and evolution rules stay the same.

Remove the Mutation Rule

Setup: Run the preloaded population with the mutation rule targeting Child 4 at Bit 8. Step 4 shows C4 changing from 0111000101 to 0111000001.

Action: Remove the mutation rule by clicking its × button, then run the evolution cycle again without changing the population or crossover rules.

What to Observe: C4 now remains 0111000101 with fitness 5 instead of changing to 0111000001 with fitness 4. It is no longer affected by mutation.

Takeaway: Mutation introduces a bit-level change but does not guarantee better fitness. In this case, flipping Bit 8 from 1 to 0 reduced the Count 1s fitness by one.

Move a Crossover Cut Point

Setup: Run the preloaded population with Crossover Rule 2 crossing New #5 and New #6 after Bit 5. The resulting C5 and C6 have fitness values of 2 and 5.

Action: Change the cut point in Crossover Rule 2 from Bit 5 to Bit 4 and run the cycle again.

What to Observe: The two selected chromosomes have the same first four bits, so cutting after Bit 4 simply exchanges their remaining tails. C5 and C6 therefore become the two original parent chromosomes in swapped order, with fitness values 3 and 4.

Takeaway: The crossover point determines how much genetic material is exchanged. If the parents share the same prefix up to the cut, changing the cut can produce very different amounts of mixing.