遗传算法ga如何导出每代的最佳适应度和平均适应度函数值?
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
用的2021a版本,help给的函数样例为[x,fval,exitflag,output,population,scores] = ga(___)
输出参数没有每代的过程变量。
每代的最佳适应度和平均适应度函数值会给出一张图,但我想知道确切的值。

0 Kommentare
Antworten (1)
yang feng
am 25 Mär. 2024
Bearbeitet: yang feng
am 25 Mär. 2024
打开ga函数,从后往前找,大概400行左右,根据你的优化问题类型找到对应的求解函数,比如我之前用线性规划的时候就打开galincon这个函数,在galincon的第95行代码:state.Best(generation) = fval;后边添加以下两行代码:
output.fitever(generation) = fval;%######
output.bestpopulationever(generation,:) = state.Population(best,:);%#######
这样在调用ga函数的时候输出变量output这个结构体里就保存了历史最优适应度fitever和历史最优种群bestpopulationever。
更具体的可以参考以下两个链接:
0 Kommentare
Siehe auch
Kategorien
Mehr zu Genetic Algorithm finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!