问题描述
仿真过程
matlab源码
%20201104lu注:该代码在matlab2019b成功运行
clear
clc
fitnessfcn = @GA_demo; % 适应度函数句柄
nvars = 2; % 个体的变量数目
options = gaoptimset('PopulationSize',100,'EliteCount',10,'CrossoverFraction',0.75,'Generations',500,'StallGenLimit',500,'TolFun',1e-100,'PlotFcns',{@gaplotbestf,@gaplotbestindiv}); %参数设置
[x_best,fval] =ga(fitnessfcn,nvars,[],[],[],[],[],[],[],options); % 调用ga函数
function f=GA_demo(x)
f1=4*x(1).^3+4*x(1)*x(2)+2*x(2).^2-42*x(1)-14;
f2=4*x(2).^3+4*x(1)*x(2)+2*x(1).^2-26*x(1)-22;
f=f1.^2+f2.^2;
end
中 MATLAB智能算法30个案例分析(第2版)[史峰 - 王辉 - 郁磊][北京航空航天大学出版社][2015-9-1][9787512414112]