function main()
clear;
clc;
Pso_size=50;
Part_size=5;
Run_max=200;
c1=0.5;
c2=0.5;
w_max=0.8;
w_min=0.4;
P_require=200;
pmin=[310 250 350 300 325];
pmax=[570 425 700 610 660];
Penish_coefficient=100; %罚函数基数
t=1; %罚函数系数
xmax=500;
L=2*xmax*sqrt(Part_size);
arr_present=ini_pos1(Pso_size,Part_size)
V=5/2*rand(Pso_size,Part_size);
Pbest=arr_present(:,1:Part_size);
Pbest1(:,1:Part_size+2)=arr_present(:,1:Part_size+2);
Pbest2=Pbest1;;
gbest(1,1:Part_size)=450*rand(1,Part_size);
a=gbest(1,1:Part_size);
gbest(1,Part_size+1)=fvalue(a,t);
gbest(1,Part_size+2)=fvalue1(a,t);
gbest1(1,1:Part_size)=gbest(1,1:Part_size);
x=gbest1;
gbest1(1,Part_size+1)=fvalue(x,t);
gbest2=gbest1;
recordgbest=gbest;
Nc=1
for i=1:Run_max
w=w_max-(w_max-w_min)*i/Run_max;
for j=1:Pso_size
V(j,:)=w*V(j)+c1*rand*(Pbest(j,Part_size)-arr_present(j,Part_size))+c2*rand*(gbest(1,Part_size)-arr_present(j,Part_size));
if abs(V(j,:))>12 %判断是否超出Vmax
if V(j,:)>0
V(j,:)=12;
else
V(j,:)=-12;
end
end
arr_present(j,1:Part_size)=arr_present(j,1:Part_size)+V(j,1:Part_size);%粒子位置更新
x=arr_present(j,1:Part_size);
arr_present(j,Part_size+1)=fvalue(x,t);%适应度1,保存到最后一列
arr_present(j,Part_size+2)=fvalue1(x,t);%适应度1,保存到最后一列
if arr_present(j,Part_size+1)<Pbest1(j,Part_size+1)
Pbest1(j,:)=arr_present(j,1:Part_size+2);
Pbest(j,1:Part_size)=Pbest1(j,1:Part_size)*(1-i/Run_max)+Pbest2(j,1:Part_size)*i/Run_max;
end
if arr_present(j,Part_size+2)<Pbest2(j,end)
Pbest2(j,:)=arr_present(j,1:Part_size+2);
Pbest(j,1:Part_size)=Pbest1(j,1:Part_size)*(1-i/Run_max)+Pbest2(j,1:Part_size)*i/Run_max;
end
if arr_present(j,Part_size+1)<gbest1(Part_size+1)
gbest1=arr_present(j,1:Part_size+1);%#ok<AGROW> %更新全局极值是通过当前位置来的,而不是通过个体极值来的
gbest(1,1:Part_size)=gbest1(1,1:Part_size)* i/Run_max+gbest2(1,1:Part_size)*( 1-i/Run_max);%gbest只有位置维数的列数,没有适配值
a=gbest(1,1:Part_size);
gbest(1,Part_size+1)=fvalue(a,t);
gbest(1,Part_size+2)=fvalue1(a,t);%这个gbest尽管没有没有实际含义,最后可以用这个作为最优解
end
if arr_present(j,Part_size+2)<gbest2(Part_size+1)
gbest2(1:Part_size)=arr_present(j,1:Part_size);
gbest2(Part_size+1)=arr_present(j,Part_size+2);%更新全局极值是通过当前位置来的,而不是通过个体极值来的
gbest(1,1:Part_size)=gbest1(1,1:Part_size)* i/Run_max+gbest2(1,1:Part_size)*( 1-i/Run_max);%gbest只有位置维数的列数,没有适配值
a=gbest(1,1:Part_size);
gbest(1,Part_size+1)=fvalue(a,t);
gbest(1,Part_size+2)=fvalue1(a,t);
end
end
recordgbest(i,:)=gbest;
Nc=Nc+1
end
best_recordf3=arr_present(:,Part_size+1);
best_recordf4=arr_present(:,Part_size+2);
plot(best_recordf3,best_recordf4,'r*')
function ini_present=ini_pos1(Pso_size,Part_size)
pmin=[310 250 350 300 325];
pmax=[570 425 700 610 660];
t=1
for k1=1:Pso_size
for k2=1:Part_size
p(k1,k2)=rand(1,1)*(pmax(k2)-pmin(k2))+pmin(k2);
end
end
ini_present=p
for i=1:Pso_size
x=ini_present(i,1:Part_size);
ini_present(i,Part_size+1)=fvalue(x,t);
ini_present(i,Part_size+2)=fvalue1(x,t);
end
function value=fvalue(p,t)
pmin=[310 250 350 300 325];
pmax=[570 4250 700 610 660];
Penish_coefficient=100*t;
P_require=2000;
a=[0.000175 0.000230 0.000116 0.000150 0.000120];
b=[0.11 0.15 0.07 0.13 0.12];
c=[3.0 5.0 7.0 3.0 5.0];
d=length(p);
value=0;
for i=1 : d
if p(i)>pmax(i)
p(i)=p(i)-rand(1,1)*(pmax(i)-pmin(i));
end
if p(i)<pmin(i)
p(i)=p(i)+rand(1,1)*(pmax(i)-pmin(i));
end
value=value+c(i)+b(i)*p(i)+a(i)*p(i)*p(i);
end
function value1=fvalue1(p,t)
pmin=[310 250 350 300 3250];
pmax=[570 425 700 610 660];
Penish_coefficient=100*t;
P_require=2000;
u=[6.49 0.0000005638 4.586 3.380 4.586];
v=[-0.0000005554 -0.0000006047 -0.0000005094 -0.000000355 -0.0000005094];
w=[0.00000004091 -0.0000002543 -0.0000004257 -0.0000005326 -0.0000004258];
d=length(p);
value1=0;
for i=1 : d
if p(i)>pmax(i)
p(i)=p(i)-rand(1,1)*(pmax(i)-pmin(i));
end
if p(i)<pmin(i)
p(i)=p(i)+rand(1,1)*(pmax(i)-pmin(i));
end
value1=value1+w(i)+v(i)*p(i)+u(i)*p(i)*p(i);
end
关于风电并网多目标经济调度,大规模风电并网面临的主要问题,matlab
版权申诉
5星 · 超过95%的资源 111 浏览量
2021-09-10
20:45:51
上传
评论 4
收藏 21KB RAR 举报
lithops7
- 粉丝: 332
- 资源: 4454
最新资源
- 知识蒸馏-基于Pytorch通过匹配训练轨迹进行数据集蒸馏-附项目源码+流程教程-优质项目实战.zip
- 儿童节 python庆祝代码简要介绍-20240601.docx
- 知识蒸馏-基于Pytorch实现的语义分割结构化知识蒸馏算法-附项目源码+流程教程-优质项目实战.zip
- 小白物联网智能家居毕设参考STM32+ESP8266/MQTT+OneNet+UniApp
- BeanUtil.java,对象属性拷贝工具
- 糖尿病肾病检测数据集VOC+YOLO格式4122张5类别.7z
- win10/11 更新禁用/开启
- IMG_3534.CR2.cr2
- FileZilla客户端
- 删除win10/11安全中心
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
前往页