← Back to CoursesEvolutionary Programming

Neuroanatomy Explorer

Drag to rotate · scroll to zoom · click regions to explore

View
Loading 3D model…

Click a region
to explore it

Memory Deck

Flip each card and rate whether you knew it. Your score is saved.

Term
Definition

Deck complete — score saved.

Match the Pairs

Match each term to its definition. Finish the board to earn your score.

All matched — score saved.

Concept Constellation

Every key idea in this course, mapped as an explorable 3D constellation. Drag to rotate, scroll to zoom, click a node.

Click a node to read its definition.

Genetic Algorithms I: Core Mechanics

Manual: General · Subject: Evolutionary Programming

Study the structure, operators, and workflow of classical genetic algorithms.

Genetic Algorithms

What Is a Genetic Algorithm?

A genetic algorithm is an evolutionary method that typically uses selection, crossover, and mutation on a population of encoded solutions. It is especially common for discrete or combinatorial problems, though it can also handle continuous variables.

GA Components

Chromosome
Encoded candidate solution
Gene
One variable or part of the encoding
Crossover
Combining two parents to form offspring
Mutation
Randomly modifying genes
Generations
Repeated rounds of evolution

Encoding Choices

Binary encoding is classic, but many modern GAs use integer, permutation, or real-valued encodings depending on the problem structure. Good encoding makes valid solutions easier to produce and evaluate.

Canonical GA Pseudocode

  1. 1

    Step 1: Initialize a population of encoded chromosomes.

  2. 2

    Step 2: Evaluate each chromosome's fitness.

  3. 3

    Step 3: Select parents from the population.

  4. 4

    Step 4: Apply crossover to create offspring.

  5. 5

    Step 5: Mutate offspring.

  6. 6

    Step 6: Replace part or all of the population.

  7. 7

    Step 7: Repeat until a stopping condition is met.

Mutation vs Crossover

Mutation

  • Introduces new variation
  • Works on one parent at a time
  • Helps escape local optima

Crossover

  • Mixes information from two parents
  • Exploits useful building blocks
  • Depends on a meaningful encoding

Which operation combines information from two parents?

What is one reason encoding matters in a GA?

Which is most likely to be a chromosome in a GA for the traveling salesperson problem?

💡

Practical Tip

When crossover frequently creates invalid offspring, improve the representation or use specialized repair operators.

Simple GA Example

Suppose we maximize f(x)=x2f(x) = x^2 over a bounded integer range. A GA may encode xx as a bit string, decode it to an integer, evaluate x2x^2, and prefer candidates with larger values.