【多目标优化求解】基于matlab蜻蜓算法求解多目标优化问题【含Matlab源码 477期】
一、获取代码方式
获取代码方式1:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
获取代码方式2:
完整代码已上传我的资源:【多目标优化求解】基于matlab蜻蜓算法求解多目标优化问题【含Matlab源码 477期】
备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);
二、蜻蜓算法简介
蜻蜓算法(Dragonfly Algorithm)是由Seyedali Mirjalili在2015年提出的一种新兴群智能算法。Reynoldz指出三个关于蜂群体行为准则:分离度、对齐度与聚合度。分离度是指相邻个体间保持适当距离,以免碰撞;对齐度是指速度和方向与相邻个体对齐;聚合度是指个体飞向相邻区域中心。蜻蜓主要目标都是生存,Seyedali Mirjalili提出五个因素影响蜻蜓算法的位置更新:分离,列队,聚集,捕食,逃离。数学模型如下:
三、部分源代码
%___________________________________________________________________%
% Multi-Objective Dragonfly Algorithm (MODA) source codes demo %
% version 1.0 %
% %
% Developed in MATLAB R2011b(7.13) %
% %
% Author and programmer: Seyedali Mirjalili %
% %
% e-Mail: ali.mirjalili@gmail.com %
% seyedali.mirjalili@griffithuni.edu.au %
% %
% Homepage: http://www.alimirjalili.com %
% %
% Main paper: %
% %
% S. Mirjalili, Dragonfly algorithm: a new meta-heuristic %
% optimization technique for solving single-objective, discrete, %
% and multi-objective problems, Neural Computing and Applications %
% DOI: http://dx.doi.org/10.1007/s00521-015-1920-1 %
%___________________________________________________________________%
clc;
clear;
close all;
% Change these details with respect to your problem%%%%%%%%%%%%%%
ObjectiveFunction=@ZDT1;
dim=5;
lb=0;
ub=1;
obj_no=2;
if size(ub,2)==1
ub=ones(1,dim)*ub;
lb=ones(1,dim)*lb;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Initial parameters of the MODA algorithm
max_iter=100;
N=100;
ArchiveMaxSize=100;
Archive_X=zeros(100,dim);
Archive_F=ones(100,obj_no)*inf;
Archive_member_no=0;
r=(ub-lb)/2;
V_max=(ub(1)-lb(1))/10;
Food_fitness=inf*ones(1,obj_no);
Food_pos=zeros(dim,1);
Enemy_fitness=-inf*ones(1,obj_no);
Enemy_pos=zeros(dim,1);
X=initialization(N,dim,ub,lb);
fitness=zeros(N,2);
DeltaX=initialization(N,dim,ub,lb);
iter=0;
position_history=zeros(N,max_iter,dim);
for iter=1:max_iter
r=(ub-lb)/4+((ub-lb)*(iter/max_iter)*2);
w=0.9-iter*((0.9-0.2)/max_iter);
my_c=0.1-iter*((0.1-0)/(max_iter/2));
if my_c<0
my_c=0;
end
if iter<(3*max_iter/4)
s=my_c; % Seperation weight
a=my_c; % Alignment weight
c=my_c; % Cohesion weight
f=2*rand; % Food attraction weight
e=my_c; % Enemy distraction weight
else
s=my_c/iter; % Seperation weight
a=my_c/iter; % Alignment weight
c=my_c/iter; % Cohesion weight
f=2*rand; % Food attraction weight
e=my_c/iter; % Enemy distraction weight
end
for i=1:N %Calculate all the objective values first
Particles_F(i,:)=ObjectiveFunction(X(:,i)');
if dominates(Particles_F(i,:),Food_fitness)
Food_fitness=Particles_F(i,:);
Food_pos=X(:,i);
end
if dominates(Enemy_fitness,Particles_F(i,:))
if all(X(:,i)<ub') && all( X(:,i)>lb')
Enemy_fitness=Particles_F(i,:);
Enemy_pos=X(:,i);
end
end
end
[Archive_X, Archive_F, Archive_member_no]=UpdateArchive(Archive_X, Archive_F, X, Particles_F, Archive_member_no);
if Archive_member_no>ArchiveMaxSize
Archive_mem_ranks=RankingProcess(Archive_F, ArchiveMaxSize, obj_no);
[Archive_X, Archive_F, Archive_mem_ranks, Archive_member_no]=HandleFullArchive(Archive_X, Archive_F, Archive_member_no, Archive_mem_ranks, ArchiveMaxSize);
else
Archive_mem_ranks=RankingProcess(Archive_F, ArchiveMaxSize, obj_no);
end
Archive_mem_ranks=RankingProcess(Archive_F, ArchiveMaxSize, obj_no);
% Chose the archive member in the least population area as foods
% to improve coverage
index=RouletteWheelSelection(1./Archive_mem_ranks);
if index==-1
index=1;
end
Food_fitness=Archive_F(index,:);
Food_pos=Archive_X(index,:)';
% Chose the archive member in the most population area as enemies
% to improve coverage
index=RouletteWheelSelection(Archive_mem_ranks);
if index==-1
index=1;
end
Enemy_fitness=Archive_F(index,:);
Enemy_pos=Archive_X(index,:)';
for i=1:N
index=0;
neighbours_no=0;
clear Neighbours_V
clear Neighbours_X
% Find the neighbouring solutions
for j=1:N
Dist=distance(X(:,i),X(:,j));
if (all(Dist<=r) && all(Dist~=0))
index=index+1;
neighbours_no=neighbours_no+1;
Neighbours_V(:,index)=DeltaX(:,j);
Neighbours_X(:,index)=X(:,j);
end
end
% Seperation%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Eq. (3.1)
S=zeros(dim,1);
if neighbours_no>1
for k=1:neighbours_no
S=S+(Neighbours_X(:,k)-X(:,i));
end
S=-S;
else
S=zeros(dim,1);
end
% Alignment%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Eq. (3.2)
if neighbours_no>1
A=(sum(Neighbours_V')')/neighbours_no;
else
A=DeltaX(:,i);
end
% Cohesion%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Eq. (3.3)
if neighbours_no>1
C_temp=(sum(Neighbours_X')')/neighbours_no;
else
C_temp=X(:,i);
end
C=C_temp-X(:,i);
% Attraction to food%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Eq. (3.4)
Dist2Attraction=distance(X(:,i),Food_pos(:,1));
if all(Dist2Attraction<=r)
F=Food_pos-X(:,i);
iter;
else
F=0;
end
% Distraction from enemy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Eq. (3.5)
Dist=distance(X(:,i),Enemy_pos(:,1));
if all(Dist<=r)
E=Enemy_pos+X(:,i);
else
E=zeros(dim,1);
end
for tt=1:dim
if X(tt,i)>ub(tt)
X(tt,i)=lb(tt);
DeltaX(tt,i)=rand;
end
if X(tt,i)<lb(tt)
X(tt,i)=ub(tt);
DeltaX(tt,i)=rand;
end
end
if any(Dist2Attraction>r)
if neighbours_no>1
for j=1:dim
DeltaX(j,i)=w*DeltaX(j,i)+rand*A(j,1)+rand*C(j,1)+rand*S(j,1);
if DeltaX(j,i)>V_max
DeltaX(j,i)=V_max;
end
if DeltaX(j,i)<-V_max
DeltaX(j,i)=-V_max;
end
X(j,i)=X(j,i)+DeltaX(j,i);
end
- 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
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162
- 163
- 164
- 165
- 166
- 167
- 168
- 169
- 170
- 171
- 172
- 173
- 174
- 175
- 176
- 177
- 178
- 179
- 180
- 181
- 182
- 183
- 184
- 185
- 186
- 187
- 188
- 189
- 190
- 191
- 192
- 193
- 194
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
四、运行结果
五、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,2016.
[2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,2017.
[3]周品.MATLAB 神经网络设计与应用[M].清华大学出版社,2013.
[4]陈明.MATLAB神经网络原理与实例精解[M].清华大学出版社,2013.
[5]方清城.MATLAB R2016a神经网络设计与应用28个案例分析[M].清华大学出版社,2018.
文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。
原文链接:qq912100926.blog.csdn.net/article/details/114573066
- 点赞
- 收藏
- 关注作者
评论(0)