example5_17.m
来自「MATLAB7辅助控制系统设计与仿真 第5章」· M 代码 · 共 20 行
M
20 行
%维数n=3
%设置参数边界
bounds =[1 4;1 7;1 7];
%遗传算法优化
%二进制编码
options=[1e-6 2];
%initPop=initializega(10,bounds,'f553',[],options);
%[m endPop] = ga(bounds,'f553',[],initPop,[1e-6 1 1],'maxGenTerm',100,'normGeomSelect',…
[0.08],['arithXover'],[2], 'nonUnifMutation',[2 5 3]);
[p,endPop,bestSols,trace]=ga(bounds,'f553');
%性能跟踪
plot(trace(:,1),trace(:,3),'b-');
hold on
plot(trace(:,1),trace(:,2),'r-');
xlabel('Generation');
ylabel('Fittness');
legend('解的变化','种群平均值的变化');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?