失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 【多目标优化求解】基于matlab自适应风驱动算法求解多目标优化问题【含Matlab源码 1414期】

【多目标优化求解】基于matlab自适应风驱动算法求解多目标优化问题【含Matlab源码 1414期】

时间:2021-03-24 03:04:41

相关推荐

【多目标优化求解】基于matlab自适应风驱动算法求解多目标优化问题【含Matlab源码 1414期】

一、获取代码方式

获取代码方式1:

通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。

获取代码方式2:

完整代码已上传我的资源:【多目标求解】基于matlab自适应风驱动算法求解多目标优化问题【含Matlab源码 1414期】

备注:

订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);

二、部分源代码

function MO_AWDO_v01()%-------------------------------------------------------------------------tic; clear; close all; clc; format long g;%--------------------------------------------------------------ArchiveParetoFronts = [];% User defined parameters:param.popsize = 100;% population size.param.npar = 10; % Dimension of the problem.param.maxit = 100;% Maximum number of iterations.maximumV = 0.5; % maximum allowed speed.%--------------------------------------------------------------% AWDO will select the coefficient values; alpha, RT, g, c, and Vmax:rec.arx = rand(5,param.popsize); %consistent with the CMAES indexing%---------------------------------------------------------------% Initialize WDO population, position and velocity:% Randomize population position in the range of [-1, 1]:pos = 2*(rand(param.popsize,param.npar)-0.5);% Randomize velocity in the range of [-Vmax, Vmax]:vel = maximumV * 2 * (rand(param.popsize,param.npar)-0.5); %---------------------------------------------------------------% Evaluate initial population via multi-objective function:for K=1:param.popsize,%[f1,f2] = kursawe(pos(K,:));%[f1,f2] = kita(pos(K,:));%[f1,f2] = schaffer(pos(K,:));%[f1,f2] = ZDT1(pos(K,:));[f1,f2] = ZDT4(pos(K,:));pres(K,:) = [f1,f2];end%----------------------------------------------------------------% % Call non-dominated sorting to identify the Pareto-front that each particle belongs:posF=[pos, pres];f = non_domination_sort_mod(posF, 2,param.npar); % f = [pos, f1, f2, rank]% extract the rank index, i.e. which Pareto-front the particle belongs:rank_ind = f(:,param.npar+3);% Select the Pareto-front == 1 particles as Global Best Position:globalposPOP = f( (f(:,param.npar+3) ==1) , 1:param.npar);% Archieve the rank 1 particles:ArchiveParetoFronts = [ArchiveParetoFronts; f( (f(:,param.npar+3) ==1) , 1:(param.npar+2) )];%-----------------------------------------------------------------% Start iterations :iter = 1; % iteration counterfor ij = 2:param.maxit,ij% Update the velocity:for i=1:param.popsize% choose random dimensions:a = randperm(param.npar); % choose velocity based on random dimension:velot(i,:) = vel(i,a);% randomly select a globalpos from the 1st Pareto-front members[aa, bb] = size(globalposPOP);globalpos = globalposPOP(round(((aa-1) * rand(1,1)) + 1),:);vel(i,:) = (1-rec.arx(1,i))*vel(i,:)-(rec.arx(2,i)*pos(i,:))+ ...abs(1-1/rank_ind(i))*((globalpos-pos(i,:)).*rec.arx(3,i))+ ...(rec.arx(4,i)*velot(i,:)/rank_ind(i)); end% maxV is optimized by CMAES. Limit it maximumV defined by usermaxV = rec.arx(5,:);maxV = min(maxV, repmat(maximumV, size(rec.arx(5,:),1), size(rec.arx(5,:),2)) );maxV = max(maxV, repmat(-maximumV, size(rec.arx(5,:),1), size(rec.arx(5,:),2)) );% Check velocity limits:vel = min(vel, repmat(maxV',1,param.npar));vel = max(vel, -repmat(maxV',1,param.npar));% Update air parcel positions:pos = pos + vel;pos = min(pos, 1.0);pos = max(pos, -1.0); % Evaluate population: (Pressure)for K=1:param.popsize,% [f1,f2] = kursawe(pos(K,:));% [f1,f2] = kita(pos(K,:));% [f1,f2] = schaffer(pos(K,:));% [f1,f2] = ZDT1(pos(K,:));[f1,f2] = ZDT4(pos(K,:));pres(K,:) = [f1,f2];end% Call non-dominated sorting to identify the Pareto-front that each particle belongs:posF=[pos, pres];f = non_domination_sort_mod(posF, 2,param.npar); % f = [pos, f1, f2, rank]% extract the rank index, i.e. which Pareto-front the particle belongs:rank_ind = f(:,param.npar+3);% Select the Pareto-front == 1 particles and add them to the archieve along previous Pareto-fronts:ArchiveParetoFronts = [ArchiveParetoFronts; f( (f(:,param.npar+3) ==1) , 1:(param.npar+2) )];% Run the non-dominated sort among the Archieve members:f = non_domination_sort_mod(ArchiveParetoFronts, 2,param.npar); % Replace the archieve with only the rank=1 members:ArchiveParetoFronts = f( (f(:,param.npar+3) ==1) , 1:(param.npar+2) );% Use rank=1 members as global position:globalposPOP = f( (f(:,param.npar+3) ==1) , 1:param.npar); %--------------------------------% call CMAES [rec] = purecmaes_wdo(ij,rec,param.popsize,pres(:, mod(ij,2)+1));%%% PRES has two values, pass one of the pres values at each iter%%% alternating between two.%----------------------------------------------------end%%% PLOT RESULTS:% Call non-dominant sorting:f = non_domination_sort_mod(ArchiveParetoFronts, 2,param.npar);% Plot the MO-results -- debugging purposespres2plot = f( (f(:,param.npar+3) ==1) , param.npar+1 : param.npar+2);plot(pres2plot(:,1), pres2plot(:,2),'ko')xlabel('F1'); ylabel('F2')grid on% save('Results.mat','pres2plot')hold on% load the known-Pareto-front data for plotting:z = load('paretoZDT4.dat');[a,b]=sort(z(:,2));z = z(b,:);plot(z(:,1),z(:,2),'-k')end% end-of-WDO.%----------------------------------------------------------------------%----------------------------------------------------------------------%----------------------------------------------------------------------

三、运行结果

四、matlab版本及参考文献

1 matlab版本

a

2 参考文献

《智能优化算法及其MATLAB实例(第2版)》包子阳 余继周 杨杉著 电子工业出版社

如果觉得《【多目标优化求解】基于matlab自适应风驱动算法求解多目标优化问题【含Matlab源码 1414期】》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。