日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

人工智能中的局部搜索算法

發布時間:2024/1/17 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 人工智能中的局部搜索算法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

??在局部搜索算法中,我們不再關心從初始節點到目標節點之間的路徑,而是考慮從當前節點出發,移動到它的鄰近狀態,直到到達合理的目標狀態。相比于前面所說的無信息搜索算法和有信息搜索算法,局部搜索算法往往能以常數的空間復雜度(不用保存路徑)在很大甚至無限的狀態空間中找到合理解。

爬山法

爬山法不斷向值增加的方向移動,直到到達頂峰。

function HillClimbing(problem) returns a local maximum statecurrent_state = initial_stateloop donext_state = the highest neighborif (next_state is higher than current_state)current_state = next_stateelsereturn current_state

爬山法的問題在于它只能保證到達局部最大值,卻不能保證到達全局最大值。

比如我們從C點出發,那么我們會停在局部最大值A點,因此沒辦法到達全局最大值B點。

模擬退火算法

??模擬退火算法與爬山法類似,只是我們不再一味地往值增加的方向移動,而是以一定的幾率容許往值減小的方向移動,從而使得我們有可能從局部最大值A點走出來,并到達全局最大值B點。
??只所以叫做模擬退火,是因為一開始這個幾率相對較高,而隨著時間的增加,這個幾率則像溫度一樣慢慢減小。

function SimulatedAnnealing () returns a solution statecurrent_state = initial_statefor t = 1 to infinite doT = schedule(t)if T = 0 thenreturn current_statenext_state = a randomly selected neighborE = next_state.height - current_state.heightif E > 0 thencurrent_state = next_stateelse current_state = next_state with probability e^(E/T)

遺傳算法

??遺傳算法模擬生物中的遺傳過程,從初始種群開始,迭代進行一系列雜交和變異直到獲得合適的種群,并從中挑選出最佳個體。

function GeneticAlgorithm(population, fitin) returns a solution stateinputs: population, a set of individualsfitness, a function that measures fitness of an individualrepeatnew_population = empty_setfor i = 1 to sizeof(population) dox = RandomSelect(population, fitness)y = RandomSelect(population, fitness)new_individual = Reproduce(x, y)if (a probability) thennew_individual = Mutate(new_individual)add new_individual to new_populationuntil some individuals are fit enough or time has elapsedreturn the best individual in the population ---------------------------------------------------------------- function Reproduce(x, y) returns a new individualinputs: x, y, the parents of the new individuallength = Length(x)mutation_point = RandomSelectIn(1, length)new_individual = Sub(x, 1, mutation_point)+ Sub(y, mutation_point, length)return new_individual

轉載于:https://www.cnblogs.com/zhangyubao/p/7016968.html

總結

以上是生活随笔為你收集整理的人工智能中的局部搜索算法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。