问题描述
仿真过程
使用matlab自带的gamultiobj函数
matlab源码
%20201104lu注:该代码在matlab2019b成功运行(运行代码出现报错提示我的gamultiobj相关函数有问题,我改动后可以正常运行。我的matlab2019b之前有改动,可能在未改动的matlab2019b运行不会出现我的问题);将程序中的函数独立出去在matlab2014a也成功运行
clear
clc
dbstop if error
fitnessfcn = @fun; % Function handle to the fitness function
nvars = 2; % Number of decision variables
lb = [-5,-5]; % Lower bound
ub = [5,5]; % Upper bound
A = []; b = []; % No linear inequality constraints
Aeq = []; beq = []; % No linear equality constraints
options = gaoptimset('ParetoFraction',0.3,'PopulationSize',100,'Generations',200,'StallGenLimit',200,'TolFun',1e-100,'PlotFcns',@gaplotpareto);
[x,fval] = gamultiobj(fitnessfcn,nvars, A,b,Aeq,beq,lb,ub,options);
%%fun函数:
function f = fun(x)
f(1) = x(1)^4 - 10*x(1)^2+x(1)*x(2) + x(2)^4 - (x(1)^2)*(x(2)^2);
f(2) = x(2)^4 - (x(1)^2)*(x(2)^2) + x(1)^4 + x(1)*x(2);
end
算法的种群是随机产生的,所以每次结果会有差异
中 MATLAB智能算法30个案例分析(第2版)[史峰 - 王辉 - 郁磊][北京航空航天大学出版社][2015-9-1][9787512414112]