%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MATLAB Code for %
% %
% Multi-Objective Particle Swarm Optimization (MOPSO) %
% Version 1.0 - Feb. 2011 %
% %
% According to: %
% Carlos A. Coello Coello et al., %
% "Handling Multiple Objectives with Particle Swarm Optimization," %
% IEEE Transactions on Evolutionary Computation, Vol. 8, No. 3, %
% pp. 256-279, June 2004. %
% %
% Developed Using MATLAB R2009b (Version 7.9) %
% %
% Programmed By: S. Mostapha Kalami Heris %
% %
% e-Mail: sm.kalami@gmail.com %
% kalami@ee.kntu.ac.ir %
% %
% Homepage: http://www.kalami.ir %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;
clear;
close all;
%% Problem Definition
TestProblem=1; % Set to 1, 2, or 3
switch TestProblem
case 1
CostFunction=@(x) MyCost1(x);
nVar=5;
VarMin=-4;
VarMax=4;
case 2
CostFunction=@(x) MyCost2(x);
nVar=3;
VarMin=-5;
VarMax=5;
case 3
CostFunction=@(x) MyCost3(x);
nVar=2;
VarMin=0;
VarMax=1;
end
VarSize=[1 nVar];
VelMax=(VarMax-VarMin)/10;
%% MOPSO Settings
nPop=100; % Population Size
nRep=100; % Repository Size
MaxIt=100; % Maximum Number of Iterations
phi1=2.05;
phi2=2.05;
phi=phi1+phi2;
chi=2/(phi-2+sqrt(phi^2-4*phi));
w=chi; % Inertia Weight
wdamp=1; % Inertia Weight Damping Ratio
c1=chi*phi1; % Personal Learning Coefficient
c2=chi*phi2; % Global Learning Coefficient
alpha=0.1; % Grid Inflation Parameter
nGrid=10; % Number of Grids per each Dimension
beta=4; % Leader Selection Pressure Parameter
gamma=2; % Extra (to be deleted) Repository Member Selection Pressure
%% Initialization
particle=CreateEmptyParticle(nPop);
for i=1:nPop
particle(i).Velocity=0;
particle(i).Position=unifrnd(VarMin,VarMax,VarSize);
particle(i).Cost=CostFunction(particle(i).Position);
particle(i).Best.Position=particle(i).Position;
particle(i).Best.Cost=particle(i).Cost;
end
particle=DetermineDomination(particle);
rep=GetNonDominatedParticles(particle);
rep_costs=GetCosts(rep);
G=CreateHypercubes(rep_costs,nGrid,alpha);
for i=1:numel(rep)
[rep(i).GridIndex rep(i).GridSubIndex]=GetGridIndex(rep(i),G);
end
%% MOPSO Main Loop
for it=1:MaxIt
for i=1:nPop
rep_h=SelectLeader(rep,beta);
particle(i).Velocity=w*particle(i).Velocity ...
+c1*rand*(particle(i).Best.Position - particle(i).Position) ...
+c2*rand*(rep_h.Position - particle(i).Position);
particle(i).Velocity=min(max(particle(i).Velocity,-VelMax),+VelMax);
particle(i).Position=particle(i).Position + particle(i).Velocity;
flag=(particle(i).Position<VarMin | particle(i).Position>VarMax);
particle(i).Velocity(flag)=-particle(i).Velocity(flag);
particle(i).Position=min(max(particle(i).Position,VarMin),VarMax);
particle(i).Cost=CostFunction(particle(i).Position);
if Dominates(particle(i),particle(i).Best)
particle(i).Best.Position=particle(i).Position;
particle(i).Best.Cost=particle(i).Cost;
elseif ~Dominates(particle(i).Best,particle(i))
if rand<0.5
particle(i).Best.Position=particle(i).Position;
particle(i).Best.Cost=particle(i).Cost;
end
end
end
particle=DetermineDomination(particle);
nd_particle=GetNonDominatedParticles(particle);
rep=[rep
nd_particle];
rep=DetermineDomination(rep);
rep=GetNonDominatedParticles(rep);
for i=1:numel(rep)
[rep(i).GridIndex rep(i).GridSubIndex]=GetGridIndex(rep(i),G);
end
if numel(rep)>nRep
EXTRA=numel(rep)-nRep;
rep=DeleteFromRep(rep,EXTRA,gamma);
rep_costs=GetCosts(rep);
G=CreateHypercubes(rep_costs,nGrid,alpha);
end
disp(['Iteration ' num2str(it) ': Number of Repository Particles = ' num2str(numel(rep))]);
w=w*wdamp;
end
%% Results
costs=GetCosts(particle);
rep_costs=GetCosts(rep);
figure;
plot(costs(1,:),costs(2,:),'b.');
hold on;
plot(rep_costs(1,:),rep_costs(2,:),'rx');
legend('Main Population','Repository');
没有合适的资源?快使用搜索试试~ 我知道了~
多目标粒子群优化算法代码.rar
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共16个文件
m:15个
url:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
0 下载量 48 浏览量
2023-10-20
19:45:47
上传
评论
收藏 10KB RAR 举报
温馨提示
多目标粒子群优化算法代码.rar
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 16 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/22afe094e1314d60869b1fc74f32bd65_m0_64087341.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
抱抱宝
- 粉丝: 1w+
- 资源: 66
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)