当适应度没有增加时,我想停止遗传算法。
我在 python 中使用 DEAP 库。
通常,我有以下日志文件:
gen nevals mean max
0 100 0.352431 0.578592
1 83 -0.533964 0.719633
2 82 -0.567494 0.719633
3 81 -0.396759 0.751318
4 74 -0.340427 0.87888
5 80 -0.29756 0.888443
6 86 -0.509486 0.907789
7 85 -0.335586 1.06199
8 69 -0.23967 1.12339
9 73 -0.10727 1.20622
10 88 -0.181696 1.20622
11 77 -0.188449 1.20622
12 72 0.135398 1.25254
13 67 0.0304611 1.26931
14 74 -0.0436463 1.3181
15 70 0.289306 1.37582
16 79 -0.0441134 1.37151
17 73 0.339611 1.37204
18 68 -0.137938 1.37204
19 76 0.000527522 1.40034
20 84 0.198005 1.40078
21 69 0.243705 1.4306
22 74 0.11812 1.4306
23 83 0.16235 1.4306
24 82 0.270455 1.43492
25 76 -0.200259 1.43492
26 77 0.157181 1.43492
27 74 0.210868 1.43492
我最初设置 ngen = 200,但如您所见,适应度函数在第 22 代时达到了局部最大值。所以我想在发生这种情况时停止遗传算法。