-1

我现在正在学习如何使用 GAUL。我从第一个例子开始,fight.c 可以理解并成功运行。但是,似乎最好的结果永远不会与目标字符串相同。

目标字符串是“当我们反思这场斗争时,我们可以用充分的信念来安慰自己,自然的战争不会无休止,没有恐惧,死亡通常是迅速的,充满活力的,健康的,快乐的人得以生存和繁衍。”

GA 运行 50 次,最好的结果是这样的

“当 w^ yeil^ct%on%this strsggln,#we 可以安慰自己 nith,她 gbll ^eomef' that&thk wir#od(n qure bl nfx kgciss\nt,)what no#bear is-[egt, wh_t deaxh is g_jerally promph, ans[at+th] v gormxs, rhe'he_jshy,&apd the hapsy survivTna#kqitiphy。”

这是正常的还是我以某种方式安装错误?谢谢。这是fight.c教程的链接 http://gaul.sourceforge.net/tutorial/simple.html

4

1 回答 1

0

I'm not familiar with GAUL but for this type of example elitism normally makes a big difference. If you can turn that on you'll probably see much faster convergence as you're not constantly discarding good partial solutions.

As an alternative to increasing the number of generations, you could instead try increasing the population size so that you have more diversity to work with. You could also try altering the mutation rate. If you're using the 0.2 mentioned on the page that you're linking to it could be a bit high. When mutation is too frequent it undermines the progress that the algorithm is making.

If you just want to see the program find the target string you could try using a shorter string. The longer the string the more generations it will take to converge.

于 2014-10-02T12:54:58.063 回答