Skip to content

xauat-liushipeng/Genetic-Algorithm-optimizes-function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

None

Use GA optim a function to get the maximum.

使用遗传算法优化函数,获取其极大值

选取的函数是

def F(x, y):

ss = x**2 + y**2

return  (0.5 - ((np.sin(np.sqrt(ss)))**2 - 0.5) / (1 + 0.001 * (ss))**2)

约束范围是[-100,100]

图像如图所示:

img

参数设置:

DNA_SIZE = 24

POP_SIZE = 200

CROSSOVER_RATE = 0.8

MUTATION_RATE = 0.005

N_GENERATIONS = 100

最后选取每代函数值均值作为纵轴绘制优化曲线:

img

About

遗传算法优化函数,取极大值

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published