【优化算法】黑洞模拟算法(MVO)【含Matlab源码 479期】
一、获取代码方式
获取代码方式1:
完整代码已上传我的资源:【优化算法】黑洞模拟算法(MVO)【含Matlab源码 479期】
获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);
二、黑洞模拟算法(MVO)简介
多元宇宙优化算法(Multi-Verse Optimizer,MVO)是Seyedali Mirjalili等于2016年提出的一种新型智能优化算法[1]。它基于宇宙中的物质通过虫洞由白洞向黑洞进行转移的原理进行模拟。在MVO算法中,主要的性能参数是虫洞存在概率和虫洞旅行距离率,参数相对较少,低维度数值实验表现出了相对较优异的性能。
1 算法原理
该算法主要借助宇宙在随机创建过程中高膨胀率物体总是趋于低膨胀率的物体,这种万有引力作用可以使物体转移,借助相关宇宙学规则,可以在搜索空间逐渐趋于最优位置.遍历过程主要分为探索和开采过程,虫洞可以作为转移物体的媒介,通过白洞和黑洞交互作用进行搜索空间探测,本文算法具体操作如下:
2 算法流程图
三、部分源代码
%_______________________________________________________________________________________%
% Multi-Verse Optimizer (MVO) 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, S. M. Mirjalili, A. Hatamlou %
% Multi-Verse Optimizer: a nature-inspired algorithm for global optimization %
% Neural Computing and Applications, in press,2015, %
% DOI: http://dx.doi.org/10.1007/s00521-015-1870-7 %
% %
%_______________________________________________________________________________________%
% You can simply define your cost in a seperate file and load its handle to fobj
% The initial parameters that you need are:
%__________________________________________
% fobj = @YourCostFunction
% dim = number of your variables
% Max_iteration = maximum number of generations
% SearchAgents_no = number of search agents
% lb=[lb1,lb2,...,lbn] where lbn is the lower bound of variable n
% ub=[ub1,ub2,...,ubn] where ubn is the upper bound of variable n
% If all the variables have equal lower bound you can just
% define lb and ub as two single number numbers
% To run MVO: [Best_score,Best_pos,cg_curve]=MVO(Universes_no,Max_iteration,lb,ub,dim,fobj)
%__________________________________________
clear all
clc
Universes_no=60; %Number of search agents (universes)
Function_name='F17'; %Name of the test function that can be from F1 to F23 (Table 1,2,3 in the paper)
Max_iteration=500; %Maximum numbef of iterations
%Load details of the selected benchmark function
[lb,ub,dim,fobj]=Get_Functions_details(Function_name);
[Best_score,Best_pos,cg_curve]=MVO(Universes_no,Max_iteration,lb,ub,dim,fobj);
figure('Position',[290 206 648 287])
%Draw the search space
subplot(1,2,1);
func_plot(Function_name);
title('Test function')
xlabel('x_1');
ylabel('x_2');
zlabel([Function_name,'( x_1 , x_2 )'])
grid off
shading interp;
light;
lighting phong;
shading interp;
%Draw the convergence curve
subplot(1,2,2);
semilogy(cg_curve,'Color','r')
title('Convergence curve')
xlabel('Iteration');
ylabel('Best score obtained so far');
axis tight
grid off
box on
legend('MVO')
%_______________________________________________________________________________________%
% Multi-Verse Optimizer (MVO) 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, S. M. Mirjalili, A. Hatamlou %
% Multi-Verse Optimizer: a nature-inspired algorithm for global optimization %
% Neural Computing and Applications, in press,2015, %
% DOI: http://dx.doi.org/10.1007/s00521-015-1870-7 %
% %
%_______________________________________________________________________________________%
% You can simply define your cost in a seperate file and load its handle to fobj
% The initial parameters that you need are:
%__________________________________________
% fobj = @YourCostFunction
% dim = number of your variables
% Max_iteration = maximum number of generations
% SearchAgents_no = number of search agents
% lb=[lb1,lb2,...,lbn] where lbn is the lower bound of variable n
% ub=[ub1,ub2,...,ubn] where ubn is the upper bound of variable n
% If all the variables have equal lower bound you can just
% define lb and ub as two single number numbers
% To run MVO: [Best_score,Best_pos,cg_curve]=MVO(Universes_no,Max_iteration,lb,ub,dim,fobj)
%__________________________________________
function [Best_universe_Inflation_rate,Best_universe,Convergence_curve]=MVO(N,Max_time,lb,ub,dim,fobj)
%Two variables for saving the position and inflation rate (fitness) of the best universe
Best_universe=zeros(1,dim);
Best_universe_Inflation_rate=inf;
%Initialize the positions of universes
Universes=initialization(N,dim,ub,lb);
%Minimum and maximum of Wormhole Existence Probability (min and max in
% Eq.(3.3) in the paper
WEP_Max=1;
WEP_Min=0.2;
Convergence_curve=zeros(1,Max_time);
%Iteration(time) counter
Time=1;
%Main loop
while Time<Max_time+1
%Eq. (3.3) in the paper
WEP=WEP_Min+Time*((WEP_Max-WEP_Min)/Max_time);
%Travelling Distance Rate (Formula): Eq. (3.4) in the paper
TDR=1-((Time)^(1/6)/(Max_time)^(1/6));
%Inflation rates (I) (fitness values)
Inflation_rates=zeros(1,size(Universes,1));
for i=1:size(Universes,1)
%Boundary checking (to bring back the universes inside search
% space if they go beyoud the boundaries
Flag4ub=Universes(i,:)>ub;
Flag4lb=Universes(i,:)<lb;
Universes(i,:)=(Universes(i,:).*(~(Flag4ub+Flag4lb)))+ub.*Flag4ub+lb.*Flag4lb;
%Calculate the inflation rate (fitness) of universes
Inflation_rates(1,i)=fobj(Universes(i,:));
%Elitism
if Inflation_rates(1,i)<Best_universe_Inflation_rate
Best_universe_Inflation_rate=Inflation_rates(1,i);
Best_universe=Universes(i,:);
end
end
[sorted_Inflation_rates,sorted_indexes]=sort(Inflation_rates);
for newindex=1:N
Sorted_universes(newindex,:)=Universes(sorted_indexes(newindex),:);
end
%Normaized inflation rates (NI in Eq. (3.1) in the paper)
normalized_sorted_Inflation_rates=normr(sorted_Inflation_rates);
Universes(1,:)= Sorted_universes(1,:);
%Update the Position of universes
for i=2:size(Universes,1)%Starting from 2 since the firt one is the elite
Back_hole_index=i;
for j=1:size(Universes,2)
r1=rand();
if r1<normalized_sorted_Inflation_rates(i)
White_hole_index=RouletteWheelSelection(-sorted_Inflation_rates);% for maximization problem -sorted_Inflation_rates should be written as sorted_Inflation_rates
if White_hole_index==-1
White_hole_index=1;
end
%Eq. (3.1) in the paper
Universes(Back_hole_index,j)=Sorted_universes(White_hole_index,j);
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
四、运行结果
五、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,2016.
[2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,2017.
文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。
原文链接:qq912100926.blog.csdn.net/article/details/114573776
- 点赞
- 收藏
- 关注作者
评论(0)