Skip to content
Tutorials Center
My learning

Topics

Lesson 15 of 36 ยท Crossover and Mutation

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.

Bit-string crossover only shuffles values that already exist in the parents. That is fine for bits, but for real numbers it is a handicap: if both parents have x = 2.0 and x = 3.0, swapping genes can only ever produce 2.0 or 3.0 again. A real-coded GA needs operators that can create new values between, and even beyond, the parents.

This lesson covers four standard real-valued crossover operators. They all take two parent vectors and return children, and all of them can be dropped into the real-coded loop from real-valued encoding.

Discrete (uniform) crossover

Copy each gene from a randomly chosen parent, exactly like uniform crossover for bits. It creates no new values but preserves the parents' genes. It is often combined with a strong mutation, and it is the right choice when genes are categorical.

Arithmetic (intermediate) crossover

Create the child as a weighted average of the parents. With weight alpha (often 0.5, or a random number in [0, 1]):

child = alpha * parent1 + (1 - alpha) * parent2

and the second child uses 1 - alpha. Every child lies on the line segment between the parents, so it never leaves the region the parents define. This is contractive: the population drifts toward its centre, losing spread quickly unless mutation compensates.

BLX-alpha (blend crossover)

BLX-alpha fixes that contraction. For each gene, take the interval between the two parents' values, widen it by alpha * d on each side (where d is the distance between them, commonly alpha = 0.5; written BLX-0.5), and sample the child uniformly from the widened interval. Children can fall slightly outside the parents, so the operator can expand and explore.

Python Arithmetic versus blend crossover

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Arithmetic children stay inside the parents' ranges, while BLX-0.5 children spill out on both sides (x from about 1 to 5). Note one more difference: arithmetic crossover with the same weight on every gene places children on a line, whereas BLX samples every gene independently, filling a box.

Simulated binary crossover (SBX)

SBX is the standard operator in many real-coded GAs, including NSGA-II (see NSGA-II from scratch). It was designed to imitate what one-point crossover does to bit strings: children are placed symmetrically around the parents, mostly close to them, with a tunable chance of landing far away. The spread is controlled by a distribution index eta (often 2 to 20).

For each gene, draw u uniformly from [0, 1) and compute a spread factor

  • beta = (2u)^(1/(eta+1)) if u <= 0.5
  • beta = (1 / (2(1-u)))^(1/(eta+1)) otherwise

Then the children are

c1 = 0.5 * ((1 + beta) * p1 + (1 - beta) * p2) and c2 = 0.5 * ((1 - beta) * p1 + (1 + beta) * p2)

Their mean always equals the parents' mean. A small eta makes children far from the parents (exploration); a large eta keeps them close (exploitation).

Python SBX: the eta parameter

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

As eta increases, the standard deviation of the children shrinks from 2.2 towards 1.0, which is the spread of the parents themselves, so children stay close to the parents. About half of the children fall outside the interval between the parents for every eta, so SBX both contracts and expands. The mean stays at 3.0 throughout, so SBX does not bias the search in a direction.

Parent-centric and other operators

  • Heuristic crossover: child = better + r * (better - worse) pushes the child away from the worse parent and past the better one, with r random in [0, 1]. It follows a "gradient" estimated from two parents.
  • Parent-centric (PCX, UNDX, SPX): for high-dimensional problems; children are sampled around parents using the geometry of several parents. They matter for hard continuous problems and are used in ES-like algorithms.
  • Differential evolution (see Swarm and Other Metaheuristics) replaces crossover by adding a scaled difference of vectors.

Choosing and combining

Operator New values? Can leave parents' range? Tends to
Discrete no no keep genes, needs strong mutation
Arithmetic yes no shrink the population towards its centre
BLX-0.5 yes yes keep or expand diversity
SBX yes yes tunable by eta, mimics bit crossover

A common recipe: SBX with eta 5 to 20 as crossover plus polynomial or Gaussian mutation. Remember to clip children into the gene bounds afterwards.

Python Diversity under arithmetic versus BLX over generations

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Without mutation, arithmetic crossover's spread collapses to exactly zero by generation 20 and the run freezes at a cost of about 0.01, while BLX-0.5 keeps a little spread alive and keeps improving towards 0. On a multimodal problem the faster loss of spread would trap the population even earlier.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why is plain arithmetic crossover said to be contractive?

    A weighted average of two values always lies between them, so the population's spread can only decrease unless something else adds variation.
  2. 2. What does a larger distribution index eta do in SBX?

    Large eta concentrates the spread factor near 1, so children are close copies of the parents (more exploitation).
  3. 3. What is the key difference between BLX-0.5 and arithmetic crossover?

    BLX widens the sampling interval on both sides by alpha times the gap, so it can expand beyond the parents' range.
  4. 4. Which operator copies each gene from one parent or the other without creating new values?

    Discrete crossover only recombines existing gene values, like uniform crossover on bits.

Summary

  • Real-coded crossover should create new values, not just shuffle existing ones.
  • Arithmetic crossover averages parents but contracts diversity; BLX-0.5 samples a widened interval and can expand.
  • SBX imitates bit-string crossover with a distribution index eta: small explores, large exploits.
  • Pair real crossover with Gaussian or polynomial mutation and clip to bounds.
  • Always watch the spread (diversity) of the population while tuning.

Next: Crossover for Permutations