【Matlab】智能优化算法_多元宇宙优化算法MVO

1.背景介绍

在这里插入图片描述

大爆炸理论讨论了我们的宇宙是从大爆炸开始的。根据这一理论,大爆炸是这个世界上一切事物的起源,在此之前什么都没有。多元宇宙理论是物理学家之间最近又一个著名的理论。在这个理论中,人们认为有不止一次的大爆炸,每一次大爆炸都会导致一个宇宙的诞生。“多元宇宙”一词与宇宙相对,宇宙指的是除了我们都生活在其中的宇宙之外,还有其他宇宙的存在。在多元宇宙理论中,多个宇宙相互作用,甚至可能相互碰撞。多元宇宙理论还表明,在每个宇宙中可能存在不同的物理定律。

我们选择了多宇宙理论的三个主要概念作为MVO算法的灵感来源:白洞、黑洞和虫洞。白洞在我们的宇宙中从未出现过,但物理学家认为大爆炸可以被认为是一个白洞,可能是宇宙诞生的主要组成部分。多宇宙理论的循环模型也认为,大爆炸/白洞是在平行宇宙之间发生碰撞的地方产生的。已经被频繁观测到的黑洞,其行为与白洞完全相反。它们以其极高的引力吸引一切,包括光束[16]。虫洞是那些将一个宇宙的不同部分连接在一起的洞。多重宇宙理论中的虫洞作为时间/空间旅行隧道,物体能够在一个宇宙的任何角落(甚至从一个宇宙到另一个宇宙)之间即时旅行。多重宇宙理论的这三个关键组成部分的概念模型如图1所示。

在这里插入图片描述

每个宇宙都有一个膨胀率(永恒的膨胀),它会导致宇宙在太空中膨胀。宇宙的膨胀速度对于恒星、行星、小行星、黑洞、白洞、虫洞、物理定律和生命的适宜性都非常重要。在一个循环多宇宙模型中,有人认为多个宇宙通过白色、黑色和虫洞相互作用,以达到稳定的状态。这正是MVO算法的灵感来源,该算法在以下小节中进行了概念和数学建模。

2.数学模型

如前一节所述,基于群体的算法将搜索过程分为两个阶段:探索和开发。我们利用白洞和黑洞的概念来探索MVO的搜索空间。相反,虫洞有助于MVO利用搜索空间。我们假设每个解都类似于一个宇宙,并且解中的每个变量都是该宇宙中的一个对象。此外,我们为每个解分配一个膨胀率,该膨胀率与解的相应适应度函数值成比例。由于时间是多元宇宙理论和宇宙学中的一个常见术语,我们在本文中也使用了时间来代替迭代。

在优化过程中,以下规则适用于MVO的universes:

  1. 通货膨胀率越高,出现白洞的概率就越高。
  2. 通货膨胀率越高,产生黑洞的可能性就越低。
  3. 膨胀率较高的宇宙往往会将物体穿过白色的洞。
  4. 膨胀率较低的宇宙往往会通过黑洞接收更多的物体。
  5. 无论膨胀率如何,所有宇宙中的物体都可能面临通过虫洞向最佳宇宙的随机运动。

所提出的算法的概念模型如图2所示。

在这里插入图片描述

该图显示,物体可以通过白/黑洞隧道在不同的宇宙之间移动。当在两个宇宙之间建立白/黑隧道时,具有较高膨胀率的宇宙被认为具有白洞,而具有较低膨胀率的太空被认为具有黑洞。然后,这些物体从源宇宙的白洞转移到目的地宇宙的黑洞。这种机制使宇宙可以很容易地交换物体。为了提高宇宙的整体膨胀率,我们假设具有高膨胀率的宇宙极有可能存在白洞。相反,低膨胀率的宇宙有很高的几率产生黑洞。因此,将物体从高通胀率的宇宙移动到低膨胀率的宇宙的可能性总是很高的。这可以保证整个宇宙的平均通货膨胀率的提高。

为了对白/黑洞隧道进行数学建模并交换宇宙的物体,我们使用了轮盘机制。在每一次迭代中,我们都会根据它们的通货膨胀率对宇宙进行排序,并通过轮盘赌选择其中一个来产生一个白色的洞。为此,请执行以下步骤。

在这里插入图片描述

其中d是参数(变量)的数量,n是宇宙(候选解)的数量:

在这里插入图片描述

其中,xj i表示第i个宇宙的第j个参数,Ui表示第i个宇宙,NI(Ui)是第i个世界的归一化膨胀率,r1是[0,1]中的随机数,xj k表示由轮盘选择机制选择的第k个宇宙的第一个参数。

该部分的伪代码如下:

在这里插入图片描述

从这些伪代码和等式(3.1)中可以看出,白洞的选择和确定是通过轮盘来完成的,轮盘是基于归一化的通货膨胀率。通货膨胀率越低,物体通过白/黑洞隧道的概率就越高。请注意,对于最大化问题,-NI应改为NI。使用这种机制可以保证探索,因为为了探索搜索空间,宇宙需要交换对象并面临突然的变化。

通过上述机制,宇宙在没有扰动的情况下不断交换物体。为了保持宇宙的多样性并进行开发,我们认为每个宇宙都有虫洞,可以随机地将其物体运送到太空中。在图2中,白点表示通过虫洞转移的物体。可以观察到,虫洞随机改变宇宙的物体,而不考虑它们的膨胀率。为了为每个宇宙提供局部变化,并有很高的概率使用虫洞提高膨胀率,我们假设虫洞隧道总是建立在宇宙和迄今为止形成的最佳宇宙之间。这一机制的表述如下:

在这里插入图片描述

其中Xj表示迄今为止形成的最佳宇宙的第j个参数,TDR是一个系数,WEP是另一个系数。lbj表示第j个变量的下界,ubj表示第j个变量的上界,xji表示第i个宇宙的第j个参数,r2、r3、r4是[0,1]中的随机数。

伪代码如下(假设ub和lb表示变量的上界和下界):

在这里插入图片描述

从伪码和数学公式可以推断,这里有两个主要系数:虫洞存在概率(WEP)和行进距离率(TDR)。前一个系数是用来定义宇宙中虫洞存在的概率。它需要在迭代过程中线性增加,以强调开发是优化过程的进展。行进距离速率也是定义物体可以被虫洞传送到迄今为止获得的最佳宇宙周围的距离速率(变化)的一个因素。与WEP相比,TDR在迭代过程中增加,以围绕最佳获得的宇宙进行更精确的利用/局部搜索。虫洞的存在和行进距离率如图3所示。两个系数的自适应公式如下:

在这里插入图片描述

在这里插入图片描述

其中min是最小值(本文中为0.2),max是最大值(本文为1),l表示当前迭代,l表示最大迭代。

在这里插入图片描述

其中p(在本文中等于6)定义了迭代过程中的利用精度。p越高,利用/本地搜索越快、越准确。请注意,WEP和TDR也可以被视为常数,但我们根据本文的结果推荐自适应值。

在MVO算法中,优化过程从创建一组随机宇宙开始。在每次迭代中,膨胀率高的宇宙中的物体往往会通过白/黑洞移动到膨胀率低的宇宙。同时,每一个宇宙都面临着其物体通过虫洞向最佳宇宙的随机传送。该过程被迭代,直到满足结束标准(例如,预定义的最大迭代次数)。

3.文件结构

在这里插入图片描述

func_plot.m						% 绘制的基准函数
Get_Functions_details.m			% 基准的全部信息和实现
initialization.m				% 初始化
main.m							% 主函数
MVO.m							% 多元宇宙优化算法
RouletteWheelSelection.m		% 轮盘选择

4.详细代码及注释

4.1 func_plot.m

function func_plot(func_name)

[lb,ub,dim,fobj]=Get_Functions_details(func_name);

switch func_name 
    case 'F1' 
        x=-100:2:100; y=x; %[-100,100]
        
    case 'F2' 
        x=-100:2:100; y=x; %[-10,10]
        
    case 'F3' 
        x=-100:2:100; y=x; %[-100,100]
        
    case 'F4' 
        x=-100:2:100; y=x; %[-100,100]
    case 'F5' 
        x=-200:2:200; y=x; %[-5,5]
    case 'F6' 
        x=-100:2:100; y=x; %[-100,100]
    case 'F7' 
        x=-1:0.03:1;  y=x  %[-1,1]
    case 'F8' 
        x=-500:10:500;y=x; %[-500,500]
    case 'F9' 
        x=-5:0.1:5;   y=x; %[-5,5]    
    case 'F10' 
        x=-20:0.5:20; y=x;%[-500,500]
    case 'F11' 
        x=-500:10:500; y=x;%[-0.5,0.5]
    case 'F12' 
        x=-10:0.1:10; y=x;%[-pi,pi]
    case 'F13' 
        x=-5:0.08:5; y=x;%[-3,1]
    case 'F14' 
        x=-100:2:100; y=x;%[-100,100]
    case 'F15' 
        x=-5:0.1:5; y=x;%[-5,5]
    case 'F16' 
        x=-1:0.01:1; y=x;%[-5,5]
    case 'F17' 
        x=-5:0.1:5; y=x;%[-5,5]
    case 'F18' 
        x=-5:0.06:5; y=x;%[-5,5]
    case 'F19' 
        x=-5:0.1:5; y=x;%[-5,5]
    case 'F20' 
        x=-5:0.1:5; y=x;%[-5,5]        
    case 'F21' 
        x=-5:0.1:5; y=x;%[-5,5]
    case 'F22' 
        x=-5:0.1:5; y=x;%[-5,5]     
    case 'F23' 
        x=-5:0.1:5; y=x;%[-5,5]  
end    

    

L=length(x);
f=[];

for i=1:L
    for j=1:L
        if strcmp(func_name,'F15')==0 && strcmp(func_name,'F19')==0 && strcmp(func_name,'F20')==0 && strcmp(func_name,'F21')==0 && strcmp(func_name,'F22')==0 && strcmp(func_name,'F23')==0
            f(i,j)=fobj([x(i),y(j)]);
        end
        if strcmp(func_name,'F15')==1
            f(i,j)=fobj([x(i),y(j),0,0]);
        end
        if strcmp(func_name,'F19')==1
            f(i,j)=fobj([x(i),y(j),0]);
        end
        if strcmp(func_name,'F20')==1
            f(i,j)=fobj([x(i),y(j),0,0,0,0]);
        end       
        if strcmp(func_name,'F21')==1 || strcmp(func_name,'F22')==1 ||strcmp(func_name,'F23')==1
            f(i,j)=fobj([x(i),y(j),0,0]);
        end          
    end
end

surfc(x,y,f,'LineStyle','none');

end

4.2 Get_Functions_details.m

function [lb,ub,dim,fobj] = Get_Functions_details(F)


switch F
    case 'F1'
        fobj = @F1;
        lb=-100;
        ub=100;
        dim=10;
        
    case 'F2'
        fobj = @F2;
        lb=-10;
        ub=10;
        dim=10;
        
    case 'F3'
        fobj = @F3;
        lb=-100;
        ub=100;
        dim=10;
        
    case 'F4'
        fobj = @F4;
        lb=-100;
        ub=100;
        dim=10;
        
    case 'F5'
        fobj = @F5;
        lb=-30;
        ub=30;
        dim=10;
        
    case 'F6'
        fobj = @F6;
        lb=-100;
        ub=100;
        dim=10;
        
    case 'F7'
        fobj = @F7;
        lb=-1.28;
        ub=1.28;
        dim=10;
        
    case 'F8'
        fobj = @F8;
        lb=-500;
        ub=500;
        dim=10;
        
    case 'F9'
        fobj = @F9;
        lb=-5.12;
        ub=5.12;
        dim=10;
        
    case 'F10'
        fobj = @F10;
        lb=-32;
        ub=32;
        dim=10;
        
    case 'F11'
        fobj = @F11;
        lb=-600;
        ub=600;
        dim=10;
        
    case 'F12'
        fobj = @F12;
        lb=-50;
        ub=50;
        dim=10;
        
    case 'F13'
        fobj = @F13;
        lb=-50;
        ub=50;
        dim=10;
        
    case 'F14'
        fobj = @F14;
        lb=-65.536;
        ub=65.536;
        dim=2;
        
    case 'F15'
        fobj = @F15;
        lb=-5;
        ub=5;
        dim=4;
        
    case 'F16'
        fobj = @F16;
        lb=-5;
        ub=5;
        dim=2;
        
    case 'F17'
        fobj = @F17;
        lb=[-5,0];
        ub=[10,15];
        dim=2;
        
    case 'F18'
        fobj = @F18;
        lb=-2;
        ub=2;
        dim=2;
        
    case 'F19'
        fobj = @F19;
        lb=0;
        ub=1;
        dim=3;
        
    case 'F20'
        fobj = @F20;
        lb=0;
        ub=1;
        dim=6;     
        
    case 'F21'
        fobj = @F21;
        lb=0;
        ub=10;
        dim=4;    
        
    case 'F22'
        fobj = @F22;
        lb=0;
        ub=10;
        dim=4;    
        
    case 'F23'
        fobj = @F23;
        lb=0;
        ub=10;
        dim=4;            
end

end

% F1

function o = F1(x)
o=sum(x.^2);
end

% F2

function o = F2(x)
o=sum(abs(x))+prod(abs(x));
end

% F3

function o = F3(x)
dim=size(x,2);
o=0;
for i=1:dim
    o=o+sum(x(1:i))^2;
end
end

% F4

function o = F4(x)
o=max(abs(x));
end

% F5

function o = F5(x)
dim=size(x,2);
o=sum(100*(x(2:dim)-(x(1:dim-1).^2)).^2+(x(1:dim-1)-1).^2);
end

% F6

function o = F6(x)
o=sum(abs((x+.5)).^2);
end

% F7

function o = F7(x)
dim=size(x,2);
o=sum([1:dim].*(x.^4))+rand;
end

% F8

function o = F8(x)
o=sum(-x.*sin(sqrt(abs(x))));
end

% F9

function o = F9(x)
dim=size(x,2);
o=sum(x.^2-10*cos(2*pi.*x))+10*dim;
end

% F10

function o = F10(x)
dim=size(x,2);
o=-20*exp(-.2*sqrt(sum(x.^2)/dim))-exp(sum(cos(2*pi.*x))/dim)+20+exp(1);
end

% F11

function o = F11(x)
dim=size(x,2);
o=sum(x.^2)/4000-prod(cos(x./sqrt([1:dim])))+1;
end

% F12

function o = F12(x)
dim=size(x,2);
o=(pi/dim)*(10*((sin(pi*(1+(x(1)+1)/4)))^2)+sum((((x(1:dim-1)+1)./4).^2).*...
(1+10.*((sin(pi.*(1+(x(2:dim)+1)./4)))).^2))+((x(dim)+1)/4)^2)+sum(Ufun(x,10,100,4));
end

% F13

function o = F13(x)
dim=size(x,2);
o=.1*((sin(3*pi*x(1)))^2+sum((x(1:dim-1)-1).^2.*(1+(sin(3.*pi.*x(2:dim))).^2))+...
((x(dim)-1)^2)*(1+(sin(2*pi*x(dim)))^2))+sum(Ufun(x,5,100,4));
end

% F14

function o = F14(x)
aS=[-32 -16 0 16 32 -32 -16 0 16 32 -32 -16 0 16 32 -32 -16 0 16 32 -32 -16 0 16 32;,...
-32 -32 -32 -32 -32 -16 -16 -16 -16 -16 0 0 0 0 0 16 16 16 16 16 32 32 32 32 32];

for j=1:25
    bS(j)=sum((x'-aS(:,j)).^6);
end
o=(1/500+sum(1./([1:25]+bS))).^(-1);
end

% F15

function o = F15(x)
aK=[.1957 .1947 .1735 .16 .0844 .0627 .0456 .0342 .0323 .0235 .0246];
bK=[.25 .5 1 2 4 6 8 10 12 14 16];bK=1./bK;
o=sum((aK-((x(1).*(bK.^2+x(2).*bK))./(bK.^2+x(3).*bK+x(4)))).^2);
end

% F16

function o = F16(x)
o=4*(x(1)^2)-2.1*(x(1)^4)+(x(1)^6)/3+x(1)*x(2)-4*(x(2)^2)+4*(x(2)^4);
end

% F17

function o = F17(x)
o=(x(2)-(x(1)^2)*5.1/(4*(pi^2))+5/pi*x(1)-6)^2+10*(1-1/(8*pi))*cos(x(1))+10;
end

% F18

function o = F18(x)
o=(1+(x(1)+x(2)+1)^2*(19-14*x(1)+3*(x(1)^2)-14*x(2)+6*x(1)*x(2)+3*x(2)^2))*...
    (30+(2*x(1)-3*x(2))^2*(18-32*x(1)+12*(x(1)^2)+48*x(2)-36*x(1)*x(2)+27*(x(2)^2)));
end

% F19

function o = F19(x)
aH=[3 10 30;.1 10 35;3 10 30;.1 10 35];cH=[1 1.2 3 3.2];
pH=[.3689 .117 .2673;.4699 .4387 .747;.1091 .8732 .5547;.03815 .5743 .8828];
o=0;
for i=1:4
    o=o-cH(i)*exp(-(sum(aH(i,:).*((x-pH(i,:)).^2))));
end
end

% F20

function o = F20(x)
aH=[10 3 17 3.5 1.7 8;.05 10 17 .1 8 14;3 3.5 1.7 10 17 8;17 8 .05 10 .1 14];
cH=[1 1.2 3 3.2];
pH=[.1312 .1696 .5569 .0124 .8283 .5886;.2329 .4135 .8307 .3736 .1004 .9991;...
.2348 .1415 .3522 .2883 .3047 .6650;.4047 .8828 .8732 .5743 .1091 .0381];
o=0;
for i=1:4
    o=o-cH(i)*exp(-(sum(aH(i,:).*((x-pH(i,:)).^2))));
end
end

% F21

function o = F21(x)
aSH=[4 4 4 4;1 1 1 1;8 8 8 8;6 6 6 6;3 7 3 7;2 9 2 9;5 5 3 3;8 1 8 1;6 2 6 2;7 3.6 7 3.6];
cSH=[.1 .2 .2 .4 .4 .6 .3 .7 .5 .5];

o=0;
for i=1:5
    o=o-((x-aSH(i,:))*(x-aSH(i,:))'+cSH(i))^(-1);
end
end

% F22

function o = F22(x)
aSH=[4 4 4 4;1 1 1 1;8 8 8 8;6 6 6 6;3 7 3 7;2 9 2 9;5 5 3 3;8 1 8 1;6 2 6 2;7 3.6 7 3.6];
cSH=[.1 .2 .2 .4 .4 .6 .3 .7 .5 .5];

o=0;
for i=1:7
    o=o-((x-aSH(i,:))*(x-aSH(i,:))'+cSH(i))^(-1);
end
end

% F23

function o = F23(x)
aSH=[4 4 4 4;1 1 1 1;8 8 8 8;6 6 6 6;3 7 3 7;2 9 2 9;5 5 3 3;8 1 8 1;6 2 6 2;7 3.6 7 3.6];
cSH=[.1 .2 .2 .4 .4 .6 .3 .7 .5 .5];

o=0;
for i=1:10
    o=o-((x-aSH(i,:))*(x-aSH(i,:))'+cSH(i))^(-1);
end
end

function o=Ufun(x,a,k,m)
o=k.*((x-a).^m).*(x>a)+k.*((-x-a).^m).*(x<(-a));
end

4.3 initialization.m

function X=initialization(SearchAgents_no,dim,ub,lb)

Boundary_no= size(ub,2); % numnber of boundaries

% If the boundaries of all variables are equal and user enter a signle
% number for both ub and lb
if Boundary_no==1
    X=rand(SearchAgents_no,dim).*(ub-lb)+lb;
end

% If each variable has a different lb and ub
if Boundary_no>1
    for i=1:dim
        ub_i=ub(i);
        lb_i=lb(i);
        X(:,i)=rand(SearchAgents_no,1).*(ub_i-lb_i)+lb_i;
    end
end

4.4 main.m

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')

display(['The best solution obtained by MVO is : ', num2str(Best_pos)]);
display(['The best optimal value of the objective funciton found by MVO is : ', num2str(Best_score)]);

4.5 MVO.m

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
            
            if (size(lb,2)==1)
                %Eq. (3.2) in the paper if the boundaries are all the same
                r2=rand();
                if r2<WEP
                    r3=rand();
                    if r3<0.5
                        Universes(i,j)=Best_universe(1,j)+TDR*((ub-lb)*rand+lb);
                    end
                    if r3>0.5
                        Universes(i,j)=Best_universe(1,j)-TDR*((ub-lb)*rand+lb);
                    end
                end
            end
            
            if (size(lb,2)~=1)
                %Eq. (3.2) in the paper if the upper and lower bounds are
                %different for each variables
                r2=rand();
                if r2<WEP
                    r3=rand();
                    if r3<0.5
                        Universes(i,j)=Best_universe(1,j)+TDR*((ub(j)-lb(j))*rand+lb(j));
                    end
                    if r3>0.5
                        Universes(i,j)=Best_universe(1,j)-TDR*((ub(j)-lb(j))*rand+lb(j));
                    end
                end
            end
            
        end
    end
    
    %Update the convergence curve
    Convergence_curve(Time)=Best_universe_Inflation_rate;
    
    %Print the best universe details after every 50 iterations
    if mod(Time,50)==0
        display(['At iteration ', num2str(Time), ' the best universes fitness is ', num2str(Best_universe_Inflation_rate)]);
    end
    Time=Time+1;
end

4.6 RouletteWheelSelection.m

function choice = RouletteWheelSelection(weights)
  accumulation = cumsum(weights);
  p = rand() * accumulation(end);
  chosen_index = -1;
  for index = 1 : length(accumulation)
    if (accumulation(index) > p)
      chosen_index = index;
      break;
    end
  end
  choice = chosen_index;

5.运行结果

在这里插入图片描述

6.参考文献

[1]Seyedali Mirjalili,Seyed Mohammad Mirjalili,Abdolreza Hatamlou. Multi-Verse Optimizer: a nature-inspired algorithm for global optimization[J]. Neural Computing and Applications,2016,27(2).

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

敲代码两年半的练习生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值