liveBook · Manning

Crossover

As explained in Optimization Algorithms: AI techniques for design, planning, and control problems

Crossover is a genetic operator that combines genetic material from parent candidate solutions to produce offspring.

Crossover combines parts of two selected candidate solutions to make offspring. In a genetic algorithm, it follows parent selection and precedes mutation, fitness evaluation, and survivor selection. It can bring useful traits together, but a new combination is not automatically a better solution. section 7.2.3 section 7.3

Choose a method that fits how solutions are encoded:

  • For binary chromosomes, 1-point crossover splits both parents at a chosen position and exchanges their tails. N-point crossover alternates segments between parents; uniform crossover chooses each gene’s parent independently. section 7.3.4
  • For real-valued chromosomes, arithmetic crossover uses a weight between 0 and 1 to average parent genes. Single, simple, and whole arithmetic methods differ in whether they blend one gene, a suffix, or the entire chromosome. Simulated binary crossover is another real-valued option. section 8.2.1

Ticket-price candidates

Encode each candidate ticket price as an eight-bit chromosome. A 1-point exchange produces candidates 01010001 and 01001101: prices of $81 and $77, with respective profits of $20,980 and $8,820. A 2-point exchange in the same pricing exercise produces $141 and $81 candidates. Evaluate the offspring rather than assuming recombination improved either parent. section 7.3.4

def crossover(parents, crossover_prob): 
    chromosome_length = len(parents[0]) 
    if crossover_prob > random.random():                                  #1
        cross_point = random.randint(0,chromosome_length)                 #2
        parents+=tuple([(parents[0][0:cross_point+1] +parents[1][cross_   #3
point+1])]) 
        parents+=tuple([(parents[1][0:cross_point+1] +parents[0][cross_   #4
point+1])]) 
    return parents                                                        #5

The Python function shows a probability check, a randomly selected split, and construction of two offspring from opposite parent prefixes and suffixes. section 7.4

Set a crossover probability, then test performance rather than treating any rate as universal. The binary ticket-pricing implementation uses 0.7; a pymoo configuration uses two-point crossover at 0.8. A relatively high crossover rate helps share traits, while mutation supplies additional variation. Crossover is mainly exploitative, though new combinations can explore; depending on the split, an offspring may even duplicate an existing candidate. For constrained problems, check and repair offspring before admitting them to the next generation. section 7.4 section 7.3.5 section 7.3 section 8.9

How Optimization Algorithms: AI techniques for design, planning, and control problems covers it

How deep it goes
Works through binary crossover variants and pricing outcomes, then gives Python implementation and real-valued alternatives without formal proofs.
Examples
Uses binary ticket-price candidates, a Python one-point crossover function, and a pymoo two-point configuration.
What it assumes
Starts from candidate solutions and genetic-algorithm building blocks while explaining chromosome exchange and its variants.
What you can do after
Build it from scratch with one-point binary crossover, or apply it via pymoo and tune its probability.
How it connects
Links parent selection, mutation, fitness evaluation, survivor selection, solution encoding, and exploration versus exploitation.

Also explained in

Compare how 7 books explain crossover →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Optimization Algorithms: AI techniques for design, planning, and control problems. The section links point to the parts of the book it draws on.