R Genetic Algorithm
Machine Learning
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
基因演算法原理
透過模仿自然法則來設計演算法: 主要有篩選&交配&突變3個主要機制
篩選
從所有的染色體中選取最適配(根據目標函數)的一對(或多對)作為父母染色體 –-> 競爭篩選法
計算每個染色體的適配值–-> 越適合,被選中的機率越高,但人人有機會 –-> 輪盤篩選法
被篩選出來的染色體就進入交配池
交配
交配的目的是交換基因,交換基因也有很多種方式,介紹最簡單的單點交配
從交配池抓出兩個染色體 A&B
A = 111000
B = 101011
若演算法決定在第N個基因為交配點,則兩個染色體的基因在第N個基因後進行互換
–-> 設N=3(從左邊數過來)
A = 111|000
B = 101|011
–-開始交換–-
A = 111|011
B = 101|000
–-交換完成–-
突變
但是如果只是交配還是有問題 –-> 無法產生新的基因
因此演算法要設定一個突變機率
突變也是有許多方法,最簡單就是在要突變的染色體上找一個基因–->將其值反轉
菁英基因
保留前一代一定數量的基因,來讓優秀基因留下來
剩下的染色體則由交配後的子代取代
流程
實作目標
以遺傳演算法去逼近以下方程式
f(x)=abs(x1-sqrt(exp(1)))+abs(x2-log(pi))
找出在指定範圍的x1&x2 –-> 使f(x)之最小值
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
rbga in R (2 variables)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
rbga in R (3 variables)
3個變數,範圍上下限一樣為0~5
基因演算法絕對不是只可以算兩個變數(大部分教學都只展示兩個),其實幾個都行
- 設計function時把變數加上去
- 以3個變數來說,畫圖應該要用3D,更多維就不用畫圖了
- 用plot3D的scatter3D()來畫圖,注意這邊x,y,z要用
"obj之population"的(不信可以把"obj$population" print出來)
- 畫3D圖的其他設定可以參考––->這裡或這裡

reference
第一篇
第二篇
第三篇
4. 應用R語言於資料分析-從機器學習/資料探勘到巨量資料 - 李仁鐘
More tutorial / note
- my coding-blog
- my movie-blog