% Program for SOPSO where there are 2 variable and m generation
%% initialisation
clear all
clc
% v= sprintf('\n number of variables= ');
% nvar=input(v);
% if nvar=2 then
pop=20;
maxit=100;
xmin=-512;
ymin=-512;
xmax=512;
ymax=512;
% xmin=-2*ones(pop,1)
% xmax=2*ones(pop,1)
% ymin=-2*ones(pop,1)
% ymax=2*ones(pop,1)
% xpop= (xmax-xmin).*rand(pop,1)+xmin
% ypop= (ymax-ymin).*rand(pop,1)+ymin
xpop=unifrnd(xmin, xmax, pop,1);
ypop=unifrnd(ymin, ymax, pop,1);
fpop=eggholder(xpop,ypop);
[g,I]= min(fpop);
gxbest=xpop(I);
gybest=ypop(I);
pxbest=xpop;
pybest=ypop;
gen(1)=1;
%% DVSOPSO
for i=2:maxit
velx=zeros(pop,1);
vely=zeros(pop,1);
ro1=rand(pop,1);
ro2=rand(pop,1);
velx= velx+ro1.*(pxbest-xpop)+ro2.*(gxbest.*ones(pop,1)-xpop);
vely= vely+ro1.*(pybest-ypop)+ro2.*(gybest.*ones(pop,1)-ypop);
x= xpop+velx;
y= ypop+vely;
xpoptemp(:,1)=xpop;
xpoptemp(:,2)=x;
xpoptempvertical=xpoptemp(:);
ypoptemp(:,1)=ypop;
ypoptemp(:,2)=y;
ypoptempvertical=ypoptemp(:);
poptempf(:,1)=eggholder(xpop,ypop);
poptempf(:,2)=eggholder(x,y);
% ypoptempf(:,1)=eggholder(ypop)
% ypoptempf(:,2)=eggholder(y)
fnfinalvertical=poptempf(:);
% funcfinal=eggholder(xpopfinal, ypopfinal)
xpop=x;
ypop=y;
for j=1:pop;
[rmin,I]=min(poptempf(j,:));
pxbest(j,1)=xpoptemp(j,I);
pybest(j,1)=ypoptemp(j,I);
end
[g1,I1]=min(fnfinalvertical)
gxbest=xpoptempvertical(I1);
gybest=ypoptempvertical(I1);
gen(i)=i;
meanfn(i)= mean(fnfinalvertical)
globalmin(i)= g1
end
%% Results
display('Maximum value is')
g1
display('and lies at')
[gxbest,gybest]
%% plots
% figure
plot(gen,meanfn,'*--b',gen,globalmin,'.--r')
xlabel('Generations');ylabel('Fitness');
legend('Minimum fitness','Average fitness');
没有合适的资源?快使用搜索试试~ 我知道了~
SOPSO.rar_OBJECTIVE FUNCTION_Single and Single
共1个文件
m:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 137 浏览量
2022-07-13
20:52:03
上传
评论
收藏 822B RAR 举报
温馨提示
PSO file which is handling single objective function and is providing solution in very 2nd iteration
资源推荐
资源详情
资源评论
收起资源包目录
SOPSO.rar (1个子文件)
SOPSO.m 2KB
共 1 条
- 1
资源评论
林当时
- 粉丝: 100
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功