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






