双目标PSO优化算法

1.问题描述:


 双目标PSO优化算法,目标函数如下:

function  Z=fitness(x)

z1=1-exp(-sum((x-(1/sqrt(3))).^2));
z2=1-exp(-sum((x+(1/sqrt(3))).^2));

Z=[z1 z2]';

end


2.部分程序:

clc
clear
close all
format shortG
%% parameters setting

nvar=3;        % number of variable
lb=[-4 -4 -4]; % lower bound
ub=[4 4 4];    % upper bound


nparticle=50;  % number of particle
nrep=200;       % number of repository

maxiter=200;    % max iteration

nobj=2;        % number of objective

Ngrid=3;


beta=10;
lambda=10;

w=1;
c1=2;
c2=2;

wdamp=0.95;

%% initialization

empty.pos=[];
empty.cost=[];
empty.velocity=[];
empty.isdominate=0;

particle=repmat(empty,nparticle,1);


for i=1:nparticle

particle(i).pos=lb+rand(1,nvar).*(ub-lb);
particle(i).cost=fitness(particle(i).pos);
particle(i).velocity=zeros(1,nvar);

end

bparticle=particle;

[particle  Q]=determinate_repository(particle);

rep=particle(Q);

grid=create_grid(rep,Ngrid,nobj);

M=create_M(nobj,Ngrid);


rep=determinate_index(rep,M,nobj,grid);


%% main loop

for iter=1:maxiter
    
    for i=1:nparticle
        
    leader=determinate_leader(rep,beta);
    particle(i).velocity=w*particle(i).velocity...
                         +c1*rand(1,nvar).*(bparticle(i).pos-particle(i).pos)...
                         +c2*rand(1,nvar).*(leader.pos-particle(i).pos);
        
    particle(i).pos=particle(i).pos+particle(i).velocity;
    
    particle(i).pos=min(particle(i).pos,ub);
    particle(i).pos=max(particle(i).pos,lb);
    
    particle(i).cost=fitness(particle(i).pos);
    
    if domination(particle(i).cost,bparticle(i).cost)
        
        bparticle(i)=particle(i);
        
    elseif domination(bparticle(i).cost,particle(i).cost)
        
        
    else
        
        if rand<0.5
           bparticle(i)=particle(i);
        end
    end
    
    

    end
    
   [particle  Q]=determinate_repository(particle);
   
   newrep=particle(Q);
   
   grid=create_grid(rep,Ngrid,nobj);
   
   newrep=determinate_index(newrep,M,nobj,grid);
   
   [rep]=[rep;newrep];
   
   [rep  Q]=determinate_repository(rep);
   
   rep=rep(Q);
   
   extra=length(rep)-nrep;
   
   if extra>0
       
       for i=1:extra
           rep=delet_ones_rep(rep,lambda);
       end
       
   end
   
   
   
       disp([ ' iter  = ' num2str(iter)  ' Nrep = ' num2str(length(rep))]);

        
    Crep=[rep.cost]';
    Cp=[particle.cost]';
    
    
    figure(1)
    plot(Crep(:,1),Crep(:,2),'r*')
    hold  on
    plot(Cp(:,1),Cp(:,2),'bo')
    hold off

   


    
    
    
    
    
    
 w=w*wdamp;   
end
%% results

pareto=rep;


 


3.仿真结论:

D*56

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

fpga和matlab

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

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

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

打赏作者

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

抵扣说明:

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

余额充值