資源簡介
用python實現(xiàn)的遺傳算法的一個實例 求函數(shù)f x 10 sin 5x + 7 cos 4x 0 < x < 10的最大值
代碼片段和文件信息
#?To?change?this?license?header?choose?License?Headers?in?Project?Properties.
#?To?change?this?template?file?choose?Tools?|?Templates
#?and?open?the?template?in?the?editor.
__author__=“l(fā)sc“
__date__?=“$2014-4-11?16:41:46$“
if?__name__?==?“__main__“:
????print?“Hello?World“
def?best(pop?fitvalue):
px?=?len(pop)
bestindividual?=?[]
bestfit?=?fitvalue[0]
for?i?in?range(1px):
if(fitvalue[i]?>?bestfit):
bestfit?=?fitvalue[i]
bestindividual?=?pop[i]
return?[bestindividual?bestfit]
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?-rw-rw-r--???????583??2014-04-10?16:41??setup.py
?-rw-rw-r--??????1075??2014-04-11?21:23??selection.py
?-rw-rw-r--???????588??2014-04-11?21:59??mutation.py
?-rw-rw-r--??????1457??2014-04-12?16:45??ga.py
?-rw-rw-r--???????777??2014-04-11?21:55??crossover.py
?-rw-rw-r--???????726??2014-04-10?21:47??calobjvalue.py
?-rw-rw-r--???????550??2014-04-11?20:59??calfitvalue.py
?-rw-rw-r--???????502??2014-04-12?12:11??best.py
-----------?---------??----------?-----??----
?????????????????6258????????????????????8
評論
共有 條評論