% Bacteria foraging algorithm for economic dispatch problem with VALVE POINT LOADING %
% by S.PRAVEEN KUMAR EMAIL:[email protected] phone +918074630423,+919959022691 %
clear all;
close all;
clc;
diary prav;
% Bacteria Foraging Optimization %
% ------- initialisation ----------%
Pd=1800;
Ne=200;%no of iteration
Nr=20;
Nc=20;
Np=30;%population size
Ns=10;
D=13;% no of generator units
C=0.001;
Ped=0.9;
; % elimination dispersion probability
cost=[550 8.10 0.00028 00 680 300 0.035
309 8.10 0.00056 00 360 200 0.042
307 8.10 0.00056 00 360 200 0.042
240 7.74 0.00324 60 180 150 0.063
240 7.74 0.00324 60 180 150 0.063
240 7.74 0.00324 60 180 150 0.063
240 7.74 0.00324 60 180 150 0.063
240 7.74 0.00324 60 180 150 0.063
240 7.74 0.00324 60 180 150 0.063
126 8.6 0.00284 40 120 100 0.084
126 8.6 0.00284 40 120 100 0.084
126 8.6 0.00284 55 120 100 0.084
126 8.6 0.00284 55 120 100 0.084];
a=cost(:,1);
b=cost(:,2);
c=cost(:,3);
Pmin=cost(:,4);
Pmax=cost(:,5);
ee=cost(:,6);
ff=cost(:,7);
% bfoinit;
for k=1:Np
for i=1:D
x(k,i)=Pmin(i)+rand*(Pmax(i)-Pmin(i));
end
end
%x
% x=(rand(Np,D)-0.5)*60 % x lies in [-30 30]
J=zeros(Np,1);
for k=1:Np
temp1=0;
temp5=0;
for i=1:D
temp1=temp1+x(k,i);
temp5=temp5+a(i)+b(i)*x(k,i)+c(i)*x(k,i)*x(k,i)+abs(ee(i)*sin(ff(i)*(Pmin(i)-x(k,i))));
% J(k)=sum(100*(x(k,i+1)-x(k,i)^2)^2+(x(k,i)-1)^2); % initial fitness calculation
end
temp2=Pd-temp1;
temp3=0;
if(temp2>0)
temp3=200.0*temp2;
end
J(k)=temp5+temp3;
end
J;
Jlast=J;
for l=1:Ne
for k=1:Nr
Jchem=J;
for j=1:Nc
% Chemotaxis Loop %
for i=1:Np
del=(rand(1,D)-0.5)*2;
x(i,:)=x(i,:)+(C/sqrt(del*del'))*del;
temp1=0;
temp5=0;
for d=1:D
if(x(i,d)<Pmin(d))
x(i,d)=Pmin(d);
end
if(x(i,d)>Pmax(d))
x(i,d)=Pmax(d);
end
temp1=temp1+x(i,d);
temp5=temp5+a(d)+b(d)*x(i,d)+c(d)*x(i,d)*x(i,d)+abs(ee(d)*sin(ff(d)*(Pmin(d)-x(i,d))));
%J(i)=sum(100*(x(i,d+1)-x(i,d)^2)^2+(x(i,d)-1)^2);
end
temp2=Pd-temp1;
temp3=0;
if(temp2>0)
temp3=200.0*temp2;
end
J(i)=temp5+temp3;
for m=1:Ns
if J(i)<Jlast(i)
Jlast(i)=J(i);
x(i,:)=x(i,:)+C*(del/sqrt(del*del'));
temp1=0;
temp5=0;
for d=1:D
if(x(i,d)<Pmin(d))
x(i,d)=Pmin(d);
end
if(x(i,d)>Pmax(d))
x(i,d)=Pmax(d);
end
temp1=temp1+x(i,d);
temp5=temp5+a(d)+b(d)*x(i,d)+c(d)*x(i,d)*x(i,d)+abs(ee(d)*sin(ff(d)*(Pmin(d)-x(i,d))));
% J(i)=sum(100*(x(i,d+1)-x(i,d)^2)^2+(x(i,d)-1)^2);
end
temp2=Pd-temp1;
temp3=0;
if(temp2>0)
temp3=200.0*temp2;
end
J(i)=temp5+temp3;
else
del=(rand(1,D)-0.5)*2;
x(i,:)=x(i,:)+C*(del/sqrt(del*del'));
temp1=0;
temp5=0;
for d=1:D
if(x(i,d)<Pmin(d))
x(i,d)=Pmin(d);
end
if(x(i,d)>Pmax(d))
x(i,d)=Pmax(d);
end
temp1=temp1+x(i,d);
temp5=temp5+a(d)+b(d)*x(i,d)+c(d)*x(i,d)*x(i,d)+abs(ee(d)*sin(ff(d)*(Pmin(d)-x(i,d))));
% J(i)=sum(100*(x(i,d+1)-x(i,d)^2)^2+(x(i,d)-1)^2);
end
temp2=Pd-temp1;
temp3=0;
if(temp2>0)
temp3=200.0*temp2;
end
J(i)=temp5+temp3;
end
end
end
Jchem=[Jchem J];
end % End of Chemotaxis %
for i=1:Np
Jhealth(i)=sum(Jchem(i,:)); % sum of cost function of all chemotactic loops for a given k & l
end
[Jhealth1,I]=sort(Jhealth,'ascend');
x=[x(I(1:Np/2),:);x(I(1:Np/2),:)];
J=[J(I(1:Np/2),:);J(I(1:Np/2),:)];
xmin=x(I(1),:);
end
Jmin(l)=min(J);
% random elimination dispersion
for i=1:Np
r=rand;
if r>=Ped
x(i,:)=(rand(1,D)-0.5);
temp1=0;
temp5=0;
for d=1:D
if(x(i,d)<Pmin(d))
x(i,d)=Pmin(d);
end
if(x(i,d)>Pmax(d))
x(i,d)=Pmax(d);
end
temp1=temp1+x(i,d);
temp5=temp5+a(d)+b(d)*x(i,d)+c(d)*x(i,d)*x(i,d)+abs(ee(d)*sin(ff(d)*(Pmin(d)-x(i,d))));
% J(i)=sum(100*(x(i,d+1)-x(i,d)^2)^2+(x(i,d)-1)^2);
end
temp2=Pd-temp1;
temp3=0;
if(temp2>0)
temp3=200.0*temp2;
end
J(i)=temp5+temp3;
end
end
end
Jmin
plot(Jmin);
xmin
Pg= sum(xmin)
基于细菌觅食算法BFO解决经济调度问题附matlab代码.zip
版权申诉
97 浏览量
2023-12-28
22:46:10
上传
评论
收藏 2KB ZIP 举报
Matlab科研辅导帮
- 粉丝: 1w+
- 资源: 7491
最新资源
- html动态爱心代码一(附源码)
- c40539bc-071a-486c-9d52-9d0c18d62dac 4.html
- 基于物理的非视域成像(NLOS)算法,利用了nerf+python源码+文档说明
- yuluer知更鸟.7z(1).001
- python课程设计-基于tensorflow实现的图文生成程序,数据集flickr30k-images+源代码+文档说明+截图
- python作业-基于Flickr30k数据集实现图像文本跨模态搜索python源码+数据集+测试界面+项目说明(高分课程设计)
- 基于Qt实现医院信息管理系统c++源码+文档说明+数据库(期末大作业)
- 基于python实现的医院信息管理系统完整源码+sql数据库+详细注释(高分课程设计)
- 基于python的眼底图像视杯视盘分割项目源码+文档说明+截图演示+详细注释(高分课程设计)
- ImageBasedModellingEdu-贰壹贰叁零
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈