> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/19/internals/geqo/geqo-intro2.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 61.2. 遺傳演算法 \#

### 61.2. 遺傳演算法 [#](#geqo-intro2) <a href="#geqo-intro2" id="geqo-intro2"></a>

遺傳演算法（GA）是一種透過隨機化搜尋運作的啟發式最佳化方法。最佳化問題的可能解集合視為由*個體*組成的*族群*。個體對環境的適應程度以其*適應度*表示。

個體在搜尋空間中的座標以*染色體*表示，本質上是一組字串。*基因*是染色體的一個子區段，會編碼單一待最佳化參數的值。基因的典型編碼可以是*二進位*或*整數*。

透過模擬*重組*、*突變*與*選擇*等演化操作，可找到平均適應度高於祖先的新一代搜尋點。[圖 61.1](#geqo-figure) 說明這些步驟。

#### 圖 61.1. 遺傳演算法的結構 [#](#geqo-figure) <a href="#geqo-figure" id="geqo-figure"></a>

<figure><img src="https://253668857-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F892nl51gFukGPxnuxeE0%2Fuploads%2Fgit-blob-381ec7e64d6cb78eb937d253079153e42c0c5bf8%2Fgenetic-algorithm.svg?alt=media" alt="圖 61.1. 遺傳演算法的結構"><figcaption></figcaption></figure>

如 comp.ai.genetic FAQ 所強調，GA 並非純粹隨機搜尋問題解答。GA 使用隨機程序，但結果明顯並非隨機（優於隨機）。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/geqo-intro2.html)（原文版本：18.6；核對日期：2026-09-10）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.postgresql.tw/19/internals/geqo/geqo-intro2.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
