Skip to content
← All questions

What does greedy crossover do in the genetic-algorithm TSP demo?

In the genetic-algorithm TSP demo, greedy crossover uses a heuristic rule that tries to choose the nearest unvisited city as the next move. This approach is presented as a way to quickly obtain an effectively short route.

Conditions

  • Used inside the genetic-algorithm TSP implementation.
  • The crossover option is enabled (greedy crossover: true).
  • At each step, the next city is chosen by nearest-unvisited-city preference.

Reasoning, step by step

  1. Identify the crossover mechanism in the genetic algorithm.
  2. Explain the greedy rule: choose the nearest unvisited city.
  3. Note the benefit: quickly yielding a short route.

Example

The narrator says, "For crossover, we use the greedy algorithms, which tries to choose the nearest unvisited city as the next move." The genetic-programming input panel shows "greedy crossover: true".

Common misconceptions

  • Thinking that greedy crossover guarantees the global optimum.
  • Assuming that crossover always involves random selection of the next city.

Watch the explanation

Explore next

Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.