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

举报
海神之光 发表于 2022/05/29 02:00:34 2022/05/29
【摘要】 一、获取代码方式 获取代码方式1: 通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。 获取代码方式2: 完整代码已上传我的资源:【多目标求解】基于matlab自适应风驱动算法求解多目...

一、获取代码方式

获取代码方式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 counter
for 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 user
        maxV = 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 purposes
        pres2plot = 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.

%----------------------------------------------------------------------
%----------------------------------------------------------------------
%----------------------------------------------------------------------


  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142

三、运行结果

在这里插入图片描述

四、matlab版本及参考文献

1 matlab版本
2014a

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

文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。

原文链接:qq912100926.blog.csdn.net/article/details/120872059

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。