# Genetic Algorithms & Genetic Programming

[**What is the difference?**](https://stackoverflow.com/questions/3819977/what-are-the-differences-between-genetic-algorithms-and-genetic-programming) **Genetic programming and genetic algorithms are very similar. They are both used to evolve the answer to a problem, by comparing the fitness of each candidate in a population of potential candidates over many generations.**<br>

**Each generation, new candidates are found by randomly changing (mutation) or swapping parts (crossover) of other candidates. The least 'fit' candidates are removed from the population. - peterjwest**<br>

![](https://lh4.googleusercontent.com/yPOIDc7UzG8oMQ4p5QiO4igfI0BToXt2GhQBRz2hVflRVFNw9dw88RP5qsXF3ZM5O7f_ytYT9ZGXXjqmeq5Et1UGi8jFZ2qPEfQsauYfrF1U0Qan2qSRThXNdvki2ZSG59BpWsK8)

**Genetic algorithms (GA) are search algorithms that mimic the process of natural evolution, where each individual is a candidate solution: individuals are generally "raw data" (in whatever encoding format has been defined).**

**Genetic programming (GP) is considered a special case of GA, where each individual is a computer program (not just "raw data"). GP explore the algorithmic search space and evolve computer programs to perform a defined task.**

**johnIdol**<br>

![](https://lh3.googleusercontent.com/ueNhmSzZnl2VlTs44mnsdqeEckZvZ87jMhGY1bRAX8uuj9EW_m5BbXKpR70o1hv-yKX1z5_NGA4rHWzvkbPi2YtQSzTPvAqbPNRObNtPjHoWvnf9z_HYoYTG27iy0iAB6_Lnc5hi)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.mlcompendium.com/machine-learning/genetic-algorithms-and-genetic-programming.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
