遗传算法ga如何导出每代的最佳适应度和平均适应度函数值?
11 ビュー (過去 30 日間)
古いコメントを表示
用的2021a版本,help给的函数样例为[x,fval,exitflag,output,population,scores] = ga(___)
输出参数没有每代的过程变量。
每代的最佳适应度和平均适应度函数值会给出一张图,但我想知道确切的值。

0 件のコメント
回答 (1 件)
yang feng
2024 年 3 月 25 日
編集済み: yang feng
2024 年 3 月 25 日
打开ga函数,从后往前找,大概400行左右,根据你的优化问题类型找到对应的求解函数,比如我之前用线性规划的时候就打开galincon这个函数,在galincon的第95行代码:state.Best(generation) = fval;后边添加以下两行代码:
output.fitever(generation) = fval;%######
output.bestpopulationever(generation,:) = state.Population(best,:);%#######
这样在调用ga函数的时候输出变量output这个结构体里就保存了历史最优适应度fitever和历史最优种群bestpopulationever。
更具体的可以参考以下两个链接:
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Genetic Algorithm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!