2

【GA】遗传算法

 3 years ago
source link: https://www.guofei.site/2016/10/05/ga.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

【GA】遗传算法

2016年10月05日

Author: Guofei

文章归类: 6-启发式算法 ,文章编号: 601


版权声明:本文作者是郭飞。转载随意,但需要标明原文链接,并通知本人
原文链接:https://www.guofei.site/2016/10/05/ga.html

Edit

算法打包

已经把算法打包了,scikit-opt

step1: Define a Function

def demo_func(x):
    x1, x2, x3 = x
    return x1 ** 2 + (x2 - 0.05) ** 2 + x3 ** 2

step2: Genetic Algorithm

from sko.GA import GA
ga = GA(func=demo_func, lb=[-1, -10, -5], ub=[2, 10, 2], max_iter=500)
best_x, best_y = ga.fit()

Figure_1-1

Matlab实现GA

原理篇

遗传算法有三个基本操作:

  • 选择(Selection)
  • 交叉(Crossover)
  • 变异(Mutation)。

积木块假设

积木块假设:阶数低、长度短、适应度高的模式(积木块)在遗传算子的作用下,相互结合,能生成阶数高、长度长、适应度高的模式,最终生成全局最优解

早熟现象

早熟(Premature Convergence)

  1. 群体中的所有个体都陷入同一极值而停止进化
  2. 接近最优解的个体总是被淘汰,进化过程不收敛

改进

  1. 。。。其它改进

多种群GA

  1. 早熟对交叉概率和变异概率很敏感
  2. 引入多个种群,不同种群赋予不同的控制参数
  3. 不同种群之间有移民算子
  4. 人工选择算子保存各种群每代的最优,作为判断算法收敛的依据

应用

应用于图像处理

问题是找到一个M,大于M的点灰度值设为255,小于M的值设定为0

适应度函数: f=p1p2(u1-u2)^2 其中p1,p2是目标图像C1,背景图像C2中像素点出现的概率 u1,u2是C1,C2的平均灰度值

算法改进:(GA与Otsu结合)

1、每个个体是8位2进制数


您的支持将鼓励我继续创作!

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK