4 AI基礎:超越經典搜索算法

4.1 Classical Search 經典搜索

  • In previous chapter, we addressed a single category of problems, where the solution is a sequence of actions with following features:
    上一章《經典搜索算法》,我們討論了一個單一類別的問題,其解決方案是具有如下特點的一系列動作:
    -observable, 可觀測
    -deterministic, 確定性
    -known environments. 已知環境
  • In this chapter, we will discuss the local search algorithms, evaluating and modifying one or more current states rather than systematically exploring paths from an initial state.
    本章我們將討論:局部搜索算法,考慮對一個或多個狀態進行評價和修改,而不是系統地探索從初始狀態開始的路徑。
  • The search algorithms that we have seen so far are designed to explore search spaces systematically, they are called Classic Search.
    我們前面介紹過的搜索算法都系統地探索空間,稱爲經典搜索算法
  • This systematicity is achieved by keeping one or more paths in memory and by recording which alternatives have been explored at each point along the path.
    這種系統性是通過將一條或多條路徑保存在內存中,並在路徑的每個點上記錄已經探索過哪些備選方案來實現的。(record how to chose a node to be expanded)
  • When a goal is found, the path to that goal also constitutes a solution to the problem.
    當找到目標時,到達此目標的路徑就是這個問題的一個解。
  • In many problems, however, the path to the goal is irrelevant to the solution.
    然而在許多問題中,到達目標的路徑與解是無關的。目標本身就是解,而不關心如何到達的。
  • For example, in the 8-queens problem, what matters is the final configuration of queens, not the order in which they are added.
    例如,在八皇后問題中,重要的是最終皇后在棋盤上的佈局,而不是皇后加入的先後次序。
  • The same general property holds for many important applications such as integrated-circuit design, factory-floor layout, job-shop scheduling, automatic programming, telecommunications network optimization, vehicle routing, and portfolio management.
    許多重要的應用都具有這樣的性質,例如集成電路設計、工廠場地佈局、作業車間調度、自動程序設計,電信網絡優化、車輛尋徑和文件夾管理。
    在集成電路設計時:只關心各種電子器件的佈局,關注電容、電阻最終放在什麼位置,至於先放哪個元器件、後放哪個元器件,並不是我們關心的。

4.2 Local Search Algorithms(局部搜索算法)

  • In many optimization problems, the path to the goal does not matter; the goal state itself is the solution.
    在許多優化問題中,到達目標的路徑是無關緊要的;目標狀態本身就是解決方案。
  • In such cases, we can use a different class of algorithms that do not worry about paths at all. That is local search algorithm.
    在此情況下,我們可以採用一種不同類型的搜索算法,這類算法不關心路徑,它就
    是局部搜索算法。
  • Local search algorithms operate using a single current node (rather than multiple paths), and generally move only to neighbors of that node. 局部搜索算法從單個當前節點(而不是多條路徑)出發,通常只移動到它的鄰近狀態。
  • Typically, the paths followed by the search are not retained.
    通常,不保留搜索路徑。

Basic idea:

Basic idea: in the search process, always search towards the direction closest to the target.
基本思想:在搜索過程中,始終向着離目標最接近的方向搜索。

  • The goal can be the maximum or the minimum.
    目標可以是最大值,也可以是最小值
  • Local search algorithms have two key advantages:局部搜索算法有如下兩個主要優點:
    -use very little memory; 使用很少的內存;
    -can find reasonable solutions in large or infinite (continuous) state spaces. 在大的或無限(連續)狀態空間中,能發現合理的解。

Methods of Local Search

  • Hill-climbing search(爬山搜索)
  • Local beam search(局部束搜索)
  • Simulated annealing search(模擬煺火搜索)
  • Genetic algorithms(遺傳算法)

(1)Hill-climbing Search(爬山搜索)

  • Hill-Climbing search algorithm is the most basic local search technique.
    爬山搜索算法是最基本的局部搜索方法。
  • It is an iterative algorithm: 爬山法是一種迭代算法:
    starts with an arbitrary solution to a problem,
    then incrementally change a single element of the solution,
    if it’s a better solution, the change is made to the new solution,
    repeating until no further improvements can be found.
    開始時選擇問題的一個任意解,然後遞增地修改該解的一個元素,若得到一個更好的解,則將該修改作爲新的解;重複直到無法找到進一步的改善。
  • Hill-climbing Search is simply a loop that continually moves in the direction
    of increasing value—that is, uphill.
    爬山搜索是簡單的循環過程,不斷向值增加的方向持續移動—— 即,登高。
  • It terminates when it reaches a “peak” where no neighbor has a higher value.
    算法在到達一個“峯頂”時終止,鄰接狀態中沒有比它值更高的。
  • The algorithm does not maintain a search tree, so the data structure for the
    current node need only record the state and the value of the objective function.
    算法不維護搜索樹,因此當前結點的數據結構只需要記錄當前狀態和目標函數值。
  • Hill climbing does not consider the state that are not the neighbors of the current state. 爬山法不會考慮與當前狀態不相鄰的狀態。
  • It is sometimes called greedy local search, because it grabs the best neighbor state without thinking ahead about where to go next.
    爬山法有時被稱爲貪婪局部搜索,因爲它總是選擇鄰居中狀態最好的一個,而不考慮一步該如何走。
  • It turns out that greedy local search algorithms often perform quite well.
    貪婪局部搜索算法往往很有效。
  • It often makes rapid progress toward a solution, because it is usually quite easy
    to improve a bad state.
    爬山法很快朝着解(目標狀態)的方向進展,因爲它可以很容易地改善一個不良狀態。
    在這裏插入圖片描述
  • If the peak is taken as the goal, h(n) to represent the height difference between the peak and the current position n, the algorithm is equivalent to always climbing towards the top of the mountain. Under the condition of single peak, it will be able to reach the peak.
    如果把山頂作爲目標,h(n)表示山頂與當前位置n之間的高度差,則該算法相當於總是登向山頂。在單峯的條件下,必能到達山頂
    在這裏插入圖片描述
  • At each step the current node is replaced by the best neighbor; in this version, that means the neighbor with the highest VALUE, but if a heuristic cost estimate h is used, we would find the neighbor with the lowest h.
    在每一步,當前結點都會被它的最佳相鄰結點所代替;這裏,最佳相鄰結點是指VALUE 最高的相鄰結點,但是若使用啓發式代價評估函數h, 我們要找的就是h 最低的相鄰結點。

Example: n-queens problems n皇后問題

  • To illustrate hill climbing, we will use it to solve the n-queens problem.
    爲了舉例說明爬山法,我們將用它解決n皇后問題。
  • Put all n queens on an n × n board. Each time move a queen to reduce the number of conflicts, so that there are no two queens on the same row, column, or diagonal.
    把n個皇后放在n x n的棋盤上。每次移動一個皇后來減少衝突數量,使得沒有兩個皇后在同一行、同一列、或同一對角線上。
  • each state has 8 queens on the board, one per column.
    每個狀態都是在棋盤上放置8 個皇后,每列一個皇后。
  • The heuristic cost function h is the number of pairs of queens that are attacking each other, either directly or indirectly.
    啓發式評估函數h 是形成相互攻擊的皇后對的數量;不管是直接還是間接。
  • The global minimum of this function is zero, which occurs only at perfect solutions. 該函數的全局最小值是0, 僅在找到解時纔會是這個值。
    在這裏插入圖片描述
  • Hill-climbing algorithms typically choose one randomly among the set of best successors if there is more than one.
    如果有多個最佳後繼,爬山算法通常會從一組最佳後繼中隨機選擇一個。

Weaknesses of Hill-Climbing 爬山法的弱點

It often gets stuck for the three reasons: 它在如下三種情況下經常被困:
- Local maxima 局部最大值
higher than its neighbors but lower than global maximum. 高於相鄰節點但低於全局最大值。
A local maximum is a peak that is higher than each of its neighboring states but lower than the global maximum.
局部極大值是一個比它的每個鄰接結點都高的峯頂,但是比全局最大值要小。
Hill-climbing algorithms that reach the vicinity of a local maximum will be drawn upward toward the peak but will then be stuck with nowhere else to go.
爬山法算法到達局部極大值附近就會被拉向峯頂,然後就卡在局部極大值處無處可走。
- Plateaux 高原
can be a flat local maximum, or a shoulder. 可能是一個平坦的局部最大值,或山肩。
- Ridges 山嶺
result in a sequence of local maxima that is very difficult to navigate.
結果是一系列局部最大值,非常難爬行。
在這裏插入圖片描述
在這裏插入圖片描述

Example of local maxima

在這裏插入圖片描述

  • h = number of pairs of queens that are attacking each other, either directly or indirectly ,h = 17
  • It shows the values of all its successors, with the best successors having h=12.
  • Hill-climbing algorithms typically choose one randomly among the set of best successors if there is more than one. 如果有多個後繼同是最小值,爬山法會在最佳後繼集合中隨機選擇一個進行擴展。
    (a) Its heuristic cost estimate h=17. It shows the value of h for each possible successor obtained by moving a queen within its column. The best moves are marked.
    當前狀態的啓發式代價評估h =17, 方格中顯示的數字表示將這一列中的皇后移到該方格而得到的後繼的h 值。最佳移動在圖中做了標記.
    (1) Choose one randomly among the set of best successors and place the queen in the same
    column to this cell.
    在當前狀態中,從若干個最佳後繼中隨機挑選一個,將該列的皇后移到此位置,
    (2) Recalculate the value of h in each cell. 再重新計算各個方格里的h值,
    (3) goto step (1) until the optimal solution is obtained or can not find a neighbor with lower value than the current node .
    轉到步驟(1),直到得到最優解或無法找到比的當前狀態h值更小的相鄰狀態。
    (b) A local minimum in the 8-queens state space; the state has h=1 but every successor has a higher cost.
    八皇后問題狀態空間中的一個局部極小值:該狀態的 h=l, 但是它的每個後繼的 h 值都會比它.

Now hill climbing gets stuck in local maxima.
此時,爬山法陷入了局部最大值,無法找到全局的最優解。
在這裏插入圖片描述

Problem of Hill-Climbing

  • It is very difficult for greedy algorithms to deal with the situation of falling into local maxima.
    貪婪算法很難處理陷入局部極大值的情況。
  • In each case, the algorithm reaches a point at which no progress is being made.
    在這種情況下,爬山法都會到達無法再取得進展的地點。
  • Starting from a randomly generated 8-queens state, steepest-ascent hill climbing gets stuck 86% of the time, solving only 14% of problem instances.
    從隨機生成的八皇后問題開始,最陡上升的爬山法86%的情況下會被卡住,只有14%的問題實例能求得解。
  • The hill-climbing algorithms described so far are incomplete—they often fail to find a goal when one exists because they can get stuck on local maxima.
    到現在爲止我們描述的爬山法是不完備的—— 它們經常會在目標存在的情況下因爲被局部極大值卡住而找不到目標。

Variants of Hill-Climbing 爬山法的變型

Stochastic hill-climbing 隨機爬山法

  • It chooses at random among uphill moves; the probability of selection can vary with the steepness of uphill move.
    在向上移動的過程中,隨機地選擇下一步, 被選中的概率可能隨向上移動的陡峭程度的不同而變化。
  • This usually converges more slowly than steepest ascent.
    與最陡上升算法相比,收斂速度通常較慢。
  • still incomplete—they may get stuck on local maxima.
    仍然不完備,還會被局部極大值卡住。

Random-restart hill-climbing 隨機重啓爬山法

  • It adopts the well-known adage, “If at first you don’t succeed, try, try again.”
  • It conducts a series of hill-climbing searches from randomly generated initial states, until a goal is found.
    隨機生成一個初始狀態,開始搜索,執行一系列這樣的爬山搜索,直到找到目標爲止。
  • It is complete with probability approaching 1, because it will eventually generate a goal state as the initial state.
    它十分完備,概率逼近1,因爲最終它將生成一個目標狀態作爲初始狀態。
  • If each hill-climbing search has a probability p of success, then the expected number of restarts required is 1/p.
    如果每次爬山搜索成功的概率爲p,則重啓需要的期望值是1/p。
  • For 8-queens, then, random-restart hill climbing is very effective indeed. Even for three million queens, the approach can find solutions in under a minute.
    對於八皇后問題,隨機重啓爬山法實際上是有效的。即使有300 萬個皇后,這個方法找到解的時間不超過1分鐘。
  • The success of hill climbing depends very much on the shape of the state-space landscape: if there are few local maxima and plateaux, random-restart hill climbing will find a good solution very quickly.
    爬山法成功與否嚴重依賴於狀態空間地形圖的形狀:如果在圖中幾乎沒有局部極大值和高原,隨機重啓爬山法會很快找到好的解。隨機重啓爬山法依然不完備

(2)Simulated Annealing Search 模擬退火

  • A hill-climbing algorithm that never makes “downhill” moves toward states with lower value (or higher cost) is guaranteed to be incomplete, because it can get stuck on a local maximum.
    爬山法搜索從來不“下山”, 即不會向值比當前結點低的(或代價高的)方向搜索,它肯定是不完備的,理由是可能卡在局部極大值上。
  • In contrast, a purely random walk—that is, moving to a successor chosen uniformly at random from the set of successors—is complete but extremely inefficient.
    與之相反,純粹的隨機行走完備的,但是效率極低。隨機行走就是從後繼集合中完全等概率的隨機選取後繼。
  • Therefore, it seems reasonable to try to combine hill climbing with a random walk in some way that yields both efficiency and completeness. Simulated annealing is such an algorithm.
    因此,把爬山法和隨機行走以某種方式結合,同時得到效率和完備性的想法是合理的。模擬退火就是這樣的算法。

Annealing 退火

  • In metallurgy, annealing is the process used to temper or harden metals and glass by heating them to a high temperature and then gradually cooling them, thus allowing the material to reach a low energy crystalline state.
    在冶金中,退火是通過將金屬和玻璃加熱到高溫,然後逐漸冷卻,使材料達到低能結晶狀態,從而使金屬和玻璃回火或硬化的過程。
  • To explain simulated annealing, we switch our point of view from hill climbing to gradient descent (i.e., minimizing cost) and imagine the task of getting a ping-pong ball into the deepest crevice in a bumpy surface.
    爲了更好地理解模擬退火,我們把注意力從爬山法轉向梯度下降(即,減小代價),想象在髙低不平的平面上有個乒乓球掉到最深的裂縫中。
  • If we just let the ball roll, it will come to rest at a local minimum.
    如果只允許乒乓球滾動,那麼它會停留在局部極小點。
  • If we shake the surface, we can bounce the ball out of the local minimum.
    如果晃動平面,我們可以使乒乓球彈出局部極小點。
  • The trick is to shake just hard enough to bounce the ball out of local minima but not hard enough to dislodge it from the global minimum.
    竅門是晃動幅度要足夠大讓乒乓球能從局部極小點彈出來,但又不能太大把它從全局最小點彈出來。
  • The simulated-annealing solution is to start by shaking hard (i.e., at a high temperature) and then gradually reduce the intensity of the shaking (i.e., lower the temperature).
    模擬退火的解決方法就是開始使勁搖晃(也就是先高溫加熱)然後慢慢降低搖晃的強度(也就是逐漸降溫)。

Basic Idea of Simulated Annealing Search

  • escape local maxima by allowing some “bad” moves but gradually decrease their frequency.
    避免局部極大值,允許一些“壞”的移動,但逐漸減少他們的頻率。
  • Break through Local Optima with probability and move towards Global Optimum
    以概率突破局部最優,走向全局最優。

  • The innermost loop of the simulated-annealing algorithm is quite similar to hill climbing.
    模擬退火算法的內層循環與爬山法類似。
  • Instead of picking the best move, however, it picks a random move.
    只是它沒有選擇最佳移動,選擇的是隨機移動
  • If the move improves the situation, it is always accepted.
    如果該移動使情況改善,該移動則被接受。
  • Otherwise, the algorithm accepts the move with some probability less than 1.
    否則,算法以某個小於1 的概率接受該移動。
  • The probability decreases exponentially with the “badness” of the move—the amount ΔE by which the evaluation is worsened.
    隨着移動導致狀態“變壞”, 概率會成指數級下降一一評估值ΔE 變壞。
  • The probability also decreases as the “temperature” T goes down: “bad” moves are more likely to be allowed at the start when T is high, and they become more unlikely as T ecreases.
    這個概率也隨“溫度”T的 降低而下降:開始T高的時候可能允許“壞的”移動,當T降低時則不可能允許“壞的”移動。
  • If the schedule lowers T slowly enough, the algorithm will find a global optimum with probability approaching 1.
    如果調度讓溫度T下降得足夠慢,算法找到全局最優解的概率接近於1。
  • Simulated annealing was first used extensively to solve VLSI (very large scale integration) layout problems in the early 1980s. It has been applied widely to factory scheduling and other large-scale optimization tasks.
    模擬退火在20 世紀80 年代早期廣泛用於求解VLSI (大規模集成電路)佈局問題。現在它
    已經廣泛地應用於工廠調度和其他大型最優化任務。
  • Simulated annealing is a probabilistic method to approach the global optimal
    solution, which was published in 1953.
    模擬退火是一種逼近全局最優解的概率方法,發表於1953年。
    在這裏插入圖片描述
  • The simulated annealing algorithm, a version of stochastic hill climbing where some downhill moves are allowed. Downhill moves are accepted readily early in the annealing schedule and then less often as time goes on.
    模擬退火算法,允許下山的隨機爬山法。在退火初期下山移動容易被採納,隨時間推移下山的次數越來越少。
    在這裏插入圖片描述

(3)Local Beam Search 局部束搜索

  • Keeping just one node in memory might seem to be an extreme reaction to the problem of memory limitations.
    雖然內存有限,但在內存中只保存一個結點又有些極端。(爬山法只記錄當前狀態及其目標函數值)
  • The local beam search algorithm keeps track of k states rather than just one.
    局部束搜索算法記錄k 個狀態而不是隻記錄一個。
  • It starts with k randomly generated states
    它從k個隨機生成的狀態開始。
  • At each step, all the successors of all k states are generated.
    在每一步,生成所有k個狀態的所有後繼狀態。
  • If any one is a goal state, stop; else select the k best successors from the complete list and repeat.
    如果其中有一個是目標狀態,則算法停止;否則從整個後繼列表中選擇k個最佳後繼,重複這個過程。

Example: Travelling Salesperson Problem (TSP) 旅行推銷員問題

  • Given the distance between a series of cities and each pair of cities, find the shortest loop to visit each city only once and return to the original city
    給定一系列城市和每對城市之間的距離,求解訪問每一座城市僅一次並回到起始城市的最短迴路。
  • The problem is to find a Hamilton loop with the least weight in a undirected completed graph with weight.
    該問題實質是在一個帶權無向完全圖中,找一個權值最小的Hamilton迴路

哈密頓迴路圖,與歐拉回路圖正好互相呼應,歐拉回路要求通過每條邊一次且僅僅一次,而哈密頓迴路圖則要求通過每個頂點一次且僅僅一次。
迄今沒有一個能簡單判定 哈密頓圖 的充要條件。從算法設計理論來說,還沒有有效的方法可求得該問題的精確解。好在有(nearest neighbor algorithm)最近鄰居算法,(best-edge algorithm)最佳邊算法都能給出比較不錯的結果。

  • Suppose that the weights of the horizontal and vertical line segments are equal and less than the diagonal weight. 假設水平和豎直線段的權值相等,均小於對角線的權值。
  • Keeps track of k states rather than just 1. Start with k randomly generated states. k=2 in this example. 保持k個狀態而不僅僅爲1。從k個隨機生成的狀態開始。本例中k=2。
    在這裏插入圖片描述
  • Generate all successors of all the k states. None of these is a goal state so we continue.
    生成所有k個狀態的全部後繼節點。這些後繼節點中沒有目標狀態,故繼續下一步。
    Select the best k successors from the complete list. Repeat the process until goal found.
    從完成表中選擇最佳k個後繼節點。重複上述過程,直到找到目標。

(4)Genetic Algorithms 遺傳算法(GA)

  • The elements of genetic algorithms was introduced in 1960s.Became popular
    through the work of John Holland in early 1970s, and particularly his book
    Adaptation in Natural and Artificial Systems(1975).
    遺傳算法的一些要素是1960年代提出的。通過約翰·霍蘭在1970年代早期的工作,尤其是他的《神經元與人工系統的適應性》(1975年)一書,使得遺傳算法流行起來。
  • It is a search heuristic that mimics the process of natural selection.
    它是一種模仿自然選擇過程的搜索啓發式算法。
  • In this algorithm, successor states are generated by combining two parent states rather than by modifying a single state. It is dealing with sexual reproduction rather than asexual reproduction.
    在該算法中, 後繼節點是由兩個父輩狀態的組合而不是修改單一狀態生成的。其處理過程是有性繁殖,而不是無性繁殖。
  • Genetic algorithms belong to the larger class of evolutionary algorithms. 遺傳算法屬於進化算法這個大分類。
  • The algorithms generate solutions to optimization problems using techniques inspired by natural evolution, such as inheritance, mutation, selection, and crossover.
    該算法採用自然進化所派生的技法來生成優化問題的解,例如:遺傳、變異、選擇、以及雜交。
  • It begin with a set of k randomly generated states, called the population. 該算法開始時具有一組k個隨機生成的狀態,稱其爲種羣
  • Each state, or individual, is represented as a string over a finite alphabet, most commonly, a string of 0s and 1s.
    每個狀態,或稱爲個體,表示爲有限字母表上的一個字符串,通常是0和1的字符串。
  • Each state is rated by the objective function, or (in GA terminology) the fitness function.
    每個狀態都由它的目標函數或(用遺傳算法術語)適應度函數給出評估值。
  • A fitness function should return higher values for better states.
    對於好的狀態,適應度函數應返回較高的值。

遺傳算法—基本概念

  • 種羣(Population):指初始給定的多個解的集合。
  • 個體(Individual):指種羣中的單個元素,通常由一個用於描述其基本遺傳結構的數據結構來表示。
  • 染色體(Chromosome):指對個體進行編碼後所得到的編碼串。染色體中的每一位稱爲基因,染色體上由若干個基因構成的一個有效信息段稱爲基因組。例如:11011爲一個染色體,每一位上的0或1表示基因。
  • 適應度(Fitness)函數:一種用來對種羣中各個個體的環境適應性進行度量的函
    數。其函數值是遺傳算法實現優勝劣汰的主要依據。
  • 遺傳操作(Genetic Operator):指作用於種羣而產生新的種羣的操作。標準的遺傳操作包括以下三種基本形式:
     選擇(Selection)
     交叉(Crossover)
     變異(Mutation)

Example: 8-queens problem 8皇后問題

An 8-queens state must specify the positions of 8 queens, each in a column of 8
squares, the state could be represented as 8 digits, each in the range from 1to 8.
某8皇后狀態需要指明8個皇后的位置,每個位於8個方格的一列,其狀態可用8個數字表示,每個位於1到8之間。
在這裏插入圖片描述
在這裏插入圖片描述
Fig. 1 Digit strings representing 8-queens states.
(a) the initial population, (b) ranked by the fitness function,
© resulting in pairs for mating, (d) reproduce child, (e) subject to mutation.
數字串表示8皇后的狀態(a)爲初始種羣,(b)通過適應函數進行分級,©導致交配對產生,(d)繁殖後代,(e)取決於突變。

  • For the 8-queens problem, we use the number of nonattacking pairs of queens to define the fitness, which has a value of 28 for a solution. 在八皇后問題中,我們用不相互攻擊的皇后對的數目來表示適應度. 最優解的適應度是28。
  • The values of the four states are 24, 23, 20, and 11. 這四個狀態的適應度分別是24、23、20 和11.
  • In this particular variant of the genetic algorithm, the probability of being chosen for reproducing is directly proportional to the fitness score, and the percentages are shown next to the raw scores.在這個特定的遺傳算法實現中,被選擇進行繁殖的概率直接與個體的適應度成正比,其百分比標在旁邊。
  • In ©, two pairs are selected at random for reproduction, in accordance with the probabilities in (b). 在圖1 © 中,按照(b) 中的概率隨機地選擇兩對進行繁殖。
  • Notice that one individual is selected twice and one not at all.4 For each pair to be mated, a crossover point is chosen randomly from the positions in the string.
    請注意其中一個個體被選中兩次, 而有一個個體一次也沒被選中,對於要配對的每對個體,在字符串中隨機選擇一個位置作爲雜交點。
  • In Figure 1, the crossover points are after the third digit in the first pair and after the fifth digit in the second pair.
    圖1 中的雜交點在第一對的第三位數字之後和第二對的第五位數字之後。
  • In (d), the offspring themselves are created by crossing over the parent strings at the crossover point.
    在圖1 (d) 中,父串在雜交點上進行雜交而創造出後代。
  • For example, the first child of the first pair gets the first three digits from the first parent and
    the remaining digits from the second parent, whereas the second child gets the first three
    digits from the second parent and the rest from the first parent. The 8-queens states involved
    in this reproduction step are shown in Figure 2.
    例如,第一對的第一個後代從第一個父串那裏得到了前三位數字、從第二個父串那裏得到了後五位數字,而第二個後代從第二個父串那裏得到了前三位數字從第一個父串那裏得到了後五位數字.
  • Finally, in (e), each location is subject to random mutation with a small independent probability.
    最後,在圖1 (e) 中每個位置都會按照某個小的獨立概率隨機變異。
  • One digit was mutated in the first, third, and fourth offspring.
    在第1、第3和第4 個後代中都有一個數字發生了變異。
  • In the 8-queens problem, this corresponds to choosing a queen at random and moving it to a random square in its column.
    在八皇后問題中,這相當於隨機地選取一個皇后並把它隨機地放到該列的某一個方格里。
    在這裏插入圖片描述
    Fig. 2 Those three 8-queens states correspond to the first two parents in “Selection” and their
    offspring in “Crossover”.
    The shaded columns are lost in the crossover step and the unshaded columns are retained.
    這三個8皇后的狀態分別對應於“選擇”中的兩個父輩和“雜交”中它們的後代。
    陰影的若干列在雜交步驟中被丟掉,而無陰影的若干列則被保留下來。

The Genetic Algorithm

在這裏插入圖片描述

Applications of Genetic Algorithms 遺傳算法的應用

在這裏插入圖片描述

Vivid Interpretation —形象解釋

  • Hill climbing algorithm: a kangaroo jumps higher than it is now. It found the highest peak not far away, but not really the highest peak, perhaps just the secondary peak.
    爬山算法:一隻袋鼠不斷跳向比現在高的地方。它找到了不遠處的最高山峯,但不一定真的是最高峯,也許只是次高峯。
  • Simulated annealing: the kangaroo is drunk and jumps randomly for a long time, during which time it may go high or low. However, it gradually sobered up and jumped to the highest peak.
    模擬退火:袋鼠喝醉了,它隨機地跳了很長時間,這期間它可能走向高處,也可能走向低處。但是,它漸漸清醒了,並跳向最高山峯。
  • Genetic algorithm: n kangaroos were randomly put into the mountain. Kangaroos do not know that their task is to find the highest peak. But every few years, some kangaroos are shot at the low peaks. As a result, the kangaroo at the low peak died, while the kangaroo at the mountain peak multiplied. Many years later, the kangaroos would unconsciously gather at the high peaks.
    遺傳算法:在山中隨機投放N只袋鼠。袋鼠不知道自己的任務是尋找最高山峯。但每過幾年,就在低山峯射殺一些袋鼠。於是,低山峯的袋鼠不斷死去,而高山峯的袋鼠繁衍生息。許多年後,袋鼠就會不自覺地聚攏到高山峯處。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章