《种粒子群算法程序.docx》由会员分享,可在线阅读,更多相关《种粒子群算法程序.docx(28页珍藏版)》请在三一文库上搜索。
1、程序 1当 c11 c21 2 , c12c22 1.5 , w 1.2 。a% 主函数源程序% 根本粒子群算法 (particle swarm optimization)% 名称: 根本粒子群算法% 初始格式化clear all;%去除所有变量clc;%清屏format long;%将数据显示为长整形科学计数%给定初始条条件N=40;%3初始化群体个数D=10;%初始化群体维数T=100;%初始化群体最迭代次数c11=2;%学习因子 1c21=2;%学习因子 2c12=;c22=;w=;%惯性权重eps=10A(-6);%设置精度在最小值的时候用%初始化种群个体限定位置和速度 x=zeros
2、(N,D);v=zeros(N,D);for i=1:Nfor j=1:Dx(i,j)=randn;%随机初始化位置v(i,j)=randn;%随机初始化速度endend% 显示群位置 figure(1)for j=1:Dif (rem(D,2)>0)subplot(D+1)/2,2,j)elsesubplot(D/2,2,j)end plot(x(:,j), 'b*' );grid on xlabel(粒子')ylabel('初始位置')tI nfo=strcat('第:char(j+48),'维'); if(j>9
3、)tInfo=strcat(第',char(floor(j/10)+48), char(rem(j,10)+48),'维');end title(tInfo) end%显示种群速度figure(2)for j=1:D if(rem(D,2)>0) subplot(D+1)/2,2,j)elsesubplot(D/2,2,j)end plot(x(:,j),'b*');grid on xlabel(粒子') ylabel('初始速度') tI nfo=strcat(第,char(j+48),'维'); if(j
4、>9)tin fo=strcat(第:char(floor(j/10)+48), char(rem(j,10)+48),'维);end title(tInfo) end figure(3)%第一个图subplot(1,2,1)% 初始化种群个体(在此限定速度和位置) x1=x;v1=v;% 初始化个体最优位置和最优值 -p1=x1;pbest1=ones(N,1);for i=1:Npbest1(i)=fitness(x1(i,:),D);end% 初始化全局最优位置和最优值 g1=1000*ones(1,D);gbest1=1000;for i=1:Nif (pbest1(i)
5、<gbest1)g1=p1(i,:);gbest1=pbest1(i);endendgb1=ones(1,T);% 浸入主循环,按照公式依次迭代直到满足精度或者迭代次数 -for i=1:Tfor j=1:Nif (fitness(x1(j,:),D)<pbest1(j) p1(j,:)=x1(j,:); pbest1(j)=fitness(x1(j,:),D);endif (pbest1(j)<gbest1)g1=p1(j,:);gbest1=pbest1(j);endv1(j,:)=w*v1(j,:)+c11*rand*(p1(j,:)-x1(j,:)+c21*rand*
6、(g1-x1(j,:); x1(j,:)=x1(j,:)+v1(j,:);endgb1(i)=gbest1;end plot(gb1)TempStr=sprintf('c1= %g ,c2=%g',c11,c21); title(TempStr);xlabel('迭代次数');ylabel('适应度值');%第二个图subplot(1,2,2)% 初始化种群个体(在此限定速度和位置) x2=x;v2=v;%初始化种群个体最有位置和 最优解 p2=x2;pbest2=ones(N,1);for i=1:Npbest2(i)=fitness(x2(i
7、,:),D);end%初始化种全局最有位置和 最优解 g2=1000*ones(1,D);gbest2=1000;for i=1:Nif(pbest2(i)<gbest2)g2=p2(i,:);gbest2=pbest2(i);endendgb2=ones(1,T);%浸入主循环,按照公式依次迭代直到满足精度或者迭代次数for i=1:Tfor j=1:Nif (fitness(x2(j,:),D)<pbest2(j)p2(j,:)=x2(j,:); pbest2(j)=fitness(x2(j,:),D);endif(pbest2(j)<gbest2)g2=p2(j,:);
8、gbest2=pbest2(j);end v2(j,:)=w*v2(j,:)+c12*rand*(p2(j,:)-x2(j,:)+c22*rand*(g2-x2(j,:); x2(j,:)=x2(j,:)+v2(j,:);endgb2(i)=gbest2;endplot(gb2)TempStr=sprintf('c1= %g ,c2=%g',c12,c22); title(TempStr);xlabel('迭代次数');ylabel('适应度值');b)适应度函数 %适应度函数() function result=fitness(x,D) sum
9、=0;for i=1:Dsum=sum+x(i)A2;endresult=sum;程序 2当 c11 c21 2 于 c12 0,c22 2,w 1.2 比照a)%主函数源程序()% 根本粒子群算法 (particle swarm optimization)%名称: 根本粒子群算法%初始格式化clear all;%去除所有变量clc;%清屏format long;%将数据显示为长整形科学计数%给定初始条条件 N=40;%3初始化群体个数D=10;%初始化群体维数T=100;%初始化群体最迭代次数c11=2;%学习因子 1c21=2;%学习因子 2c12=0;c22=2;w=;%惯性权重eps=
10、10(6);%设置精度(在最小值的时候用)%初始化种群个体(限定位置和速度) x=zeros(N,D);v=zeros(N,D);for i=1:Nfor j=1:Dx(i,j)=randn;%随机初始化位置v(i,j)=randn;%随机初始化速度endend%显示群位置 figure(1) for j=1:D if(rem(D,2)>0) subplot(D+1)/2,2,j)elsesubplot(D/2,2,j)end plot(x(:,j),'b*');grid onxlabel(粒子') ylabel('初始位置') tI nfo=st
11、rcat('第:char(j+48),'维'); if(j>9)tInfo=strcat(第',char(floor(j/10)+48), char(rem(j,10)+48),'维');end title(tInfo) end%显示种群速度figure(2)for j=1:Dif(rem(D,2)>0)subplot(D+1)/2,2,j)else subplot(D/2,2,j) end plot(x(:,j), 'b*' );grid on xlabel(粒子')ylabel('初始速度'
12、)tI nfo=strcat('第,char(j+48),'维');if(j>9)tin fo=strcat(第:char(floor(j/10)+48), char(rem(j,10)+48),'维);end title(tinfo)endfigure(3)%第一个图subplot(1,2,1)% 初始化种群个体(在此限定速度和位置) x1=x;v1=v;% 初始化个体最优位置和最优值 -p1=x1;pbest1=ones(N,1);for i=1:N pbest1(i)=fitness(x1(i,:),D);end% 初始化全局最优位置和最优值 g1=
13、1000*ones(1,D); gbest1=1000;for i=1:Nif(pbest1(i)<gbest1) g1=p1(i,:); gbest1=pbest1(i);end end gb1=ones(1,T);%浸入主循环,按照公式依次迭代直到满足精度或者迭代次数for i=1:Tfor j=1:Nif (fitness(x1(j,:),D)<pbest1(j) p1(j,:)=x1(j,:); pbest1(j)=fitness(x1(j,:),D);endif (pbest1(j)<gbest1) g1=p1(j,:); gbest1=pbest1(j);end
14、v1(j,:)=w*v1(j,:)+c11*rand*(p1(j,:)-x1(j,:)+c21*rand*(g1-x1(j,:);x1(j,:)=x1(j,:)+v1(j,:);end gb1(i)=gbest1;endplot(gb1)TempStr=sprintf('c1= %g ,c2=%g',c11,c21); title(TempStr);xlabel('迭代次数');ylabel('适应度值');%第二个图 subplot(1,2,2)% 初始化种群个体(在此限定速度和位置) x2=x;v2=v;%初始化种群个体最有位置和 最优解 p
15、2=x2;pbest2=ones(N,1);for i=1:N pbest2(i)=fitness(x2(i,:),D);end%初始化种全局最有位置和 最优解 g2=1000*ones(1,D);gbest2=1000;for i=1:Nif (pbest2(i)<gbest2)g2=p2(i,:); gbest2=pbest2(i);endend gb2=ones(1,T);%浸入主循环,按照公式依次迭代直到满足精度或者迭代次数for i=1:Tfor j=1:Nif (fitness(x2(j,:),D)<pbest2(j) p2(j,:)=x2(j,:); pbest2(j
16、)=fitness(x2(j,:),D);endif (pbest2(j)<gbest2) g2=p2(j,:); gbest2=pbest2(j);end v2(j,:)=w*v2(j,:)+c12*rand*(p2(j,:)-x2(j,:)+c22*rand*(g2-x2(j,:);x2(j,:)=x2(j,:)+v2(j,:);end gb2(i)=gbest2;endplot(gb2)TempStr=sprintf('c1= %g ,c2=%g',c12,c22); title(TempStr);xlabel('迭代次数');ylabel('
17、;适应度值');b)适应度函数 %适应度函数() function result=fitness(x,D) sum=0;for i=1:Dsum=sum+x(i)A2;end result=sum;程序 3当 c11 c21 2,w 1.2 于 c12 2,c22 0,w 1.2 比照a)%主函数源程序()% 根本粒子群算法 (particle swarm optimization)%名称: 根本粒子群算法%初始格式化clear all;clc;format long;%给定初始条条件N=40;D=10;T=100;c11=2;c21=2;c12=2;c22=0;w=;eps=10A(
18、-6);%去除所有变量%清屏%将数据显示为长整形科学计数%3初始化群体个数%初始化群体维数%初始化群体最迭代次数% 学习因子 1% 学习因子 2%惯性权重%设置精度(在最小值的时候用)%初始化种群个体(限定位置和速度) x=zeros(N,D);v=zeros(N,D);for i=1:Nfor j=1:Dx(i,j)=randn;%随机初始化位置v(i,j)=randn;%随机初始化速度endend%显示群位置 figure(1)for j=1:Dif(rem(D,2)>0)subplot(D+1)/2,2,j)elsesubplot(D/2,2,j)end plot(x(:,j),
19、'b*' );grid on xlabel(粒子')ylabel('初始位置')tI nfo=strcat('第:char(j+48),'维'); if(j>9)tInfo=strcat(第',char(floor(j/10)+48), char(rem(j,10)+48),'维');end title(tInfo) end%显示种群速度figure(2)for j=1:D if(rem(D,2)>0) subplot(D+1)/2,2,j)elsesubplot(D/2,2,j)end plo
20、t(x(:,j),'b*');grid on xlabel(粒子') ylabel('初始速度') tI nfo=strcat(第,char(j+48),'维'); if(j>9)tin fo=strcat(第:char(floor(j/10)+48), char(rem(j,10)+48),'维);end title(tInfo) end figure(3)%第一个图subplot(1,2,1)% 初始化种群个体(在此限定速度和位置) x1=x;v1=v;% 初始化个体最优位置和最优值 -p1=x1;pbest1=ones
21、(N,1);for i=1:Npbest1(i)=fitness(x1(i,:),D);end% 初始化全局最优位置和最优值 g1=1000*ones(1,D);gbest1=1000;for i=1:Nif (pbest1(i)<gbest1)g1=p1(i,:);gbest1=pbest1(i);endendgb1=ones(1,T);% 浸入主循环,按照公式依次迭代直到满足精度或者迭代次数 -for i=1:Tfor j=1:Nif (fitness(x1(j,:),D)<pbest1(j) p1(j,:)=x1(j,:); pbest1(j)=fitness(x1(j,:)
22、,D);endif (pbest1(j)<gbest1)g1=p1(j,:);gbest1=pbest1(j);endv1(j,:)=w*v1(j,:)+c11*rand*(p1(j,:)-x1(j,:)+c21*rand*(g1-x1(j,:); x1(j,:)=x1(j,:)+v1(j,:);endgb1(i)=gbest1;end plot(gb1)TempStr=sprintf('c1= %g ,c2=%g',c11,c21); title(TempStr);xlabel('迭代次数');ylabel('适应度值');%第二个图su
23、bplot(1,2,2)% 初始化种群个体(在此限定速度和位置) x2=x;v2=v;%初始化种群个体最有位置和 最优解 p2=x2;pbest2=ones(N,1);for i=1:Npbest2(i)=fitness(x2(i,:),D);end%初始化种全局最有位置和 最优解 g2=1000*ones(1,D);gbest2=1000;for i=1:Nif(pbest2(i)<gbest2)g2=p2(i,:);gbest2=pbest2(i);endendgb2=ones(1,T);%浸入主循环,按照公式依次迭代直到满足精度或者迭代次数for i=1:Tfor j=1:Nif
24、(fitness(x2(j,:),D)<pbest2(j)p2(j,:)=x2(j,:); pbest2(j)=fitness(x2(j,:),D);endif(pbest2(j)<gbest2)g2=p2(j,:);gbest2=pbest2(j);end v2(j,:)=w*v2(j,:)+c12*rand*(p2(j,:)-x2(j,:)+c22*rand*(g2-x2(j,:);x2(j,:)=x2(j,:)+v2(j,:);end gb2(i)=gbest2;endplot(gb2) TempStr=sprintf('c1= %g ,c2=%g',c12,
25、c22);title(TempStr);xlabel('迭代次数');ylabel('适应度值');b)适应度函数 %适应度函数() function result=fitness(x,D) sum=0;for i=1:Dsum=sum+x(i)A2;endresult=sum;程序 41.5 测试函对 c1c2,Wjw2 分别对其取值 s 1.1 ,c22 ,Wj1.2 ,w2数。a)%主函数源程序()% 根本粒子群算法 (particle sWarm optimization)%名称: 根本粒子群算法%初始格式化clear all;%去除所有变量clc;%清
26、屏format long;%将数据显示为长整形科学计数%给定初始条条件 N=40;%3初始化群体个数D=10;%初始化群体维数T=100;%初始化群体最迭代次数c1=;%学习因子 1c2=2;%学习因子 2w1=;%惯性权重w2=;%惯性权重eps=10(6);%设置精度(在最小值的时候用)-%初始化种群个体(限定位置和速度) x=zeros(N,D); v=zeros(N,D);for i=1:Nfor j=1:Dx(i,j)=randn;%随机初始化位置v(i,j)=randn;%随机初始化速度endend%显示群位置 figure(1)for j=1:D if(rem(D,2)>0
27、) subplot(D+1)/2,2,j)elsesubplot(D/2,2,j) plot(x(:,j), 'b*') ; grid onxlabel(粒子')ylabel('初始位置')tI nfo=strcat('第:char(j+48),'维');if(j>9)tInfo=strcat(第',char(floor(j/10)+48), char(rem(j,10)+48),'维');end title(tInfo)end% 显示种群速度 figure(2)for j=1:Dif(rem(D,2
28、)>0)subplot(D+1)/2,2,j)else subplot(D/2,2,j) end plot(x(:,j), 'b*' );grid onxlabel(粒子')ylabel('初始速度')tI nfo=strcat('第,char(j+48),'维');if(j>9)tin fo=strcat(第:char(floor(j/10)+48), char(rem(j,10)+48),'维);end title(tinfo)endfigure(3)subplot(1,2,1)% 初始化种群个体(在此限定
29、速度和位置) x1=x;v1=v;% 初始化个体最优位置和最优值 -p1=x1; pbest1=ones(N,1);for i=1:N pbest1(i)=fitness(x1(i,:),D);end% 初始化全局最优位置和最优值 g1=1000*ones(1,D); gbest1=1000;for i=1:N if(pbest1(i)<gbest1) g1=p1(i,:); gbest1=pbest1(i);endendgb1=ones(1,T);%浸入主循环,按照公式依次迭代直到满足精度或者迭代次数for i=1:Tfor j=1:Nif (fitness(x1(j,:),D)<
30、;pbest1(j) p1(j,:)=x1(j,:); pbest1(j)=fitness(x1(j,:),D);endif (pbest1(j)<gbest1) g1=p1(j,:); gbest1=pbest1(j);end v1(j,:)=w1*v1(j,:)+c1*rand*(p1(j,:)-x1(j,:)+c2*rand*(g1-x1(j,:); x1(j,:)=x1(j,:)+v1(j,:);end gb1(i)=gbest1;end plot(gb1) TempStr=sprintf('w= %g ',w1); title(TempStr);xlabel(&
31、#39;迭代次数');ylabel('适应度值');subplot(1,2,2)% 初始化种群个体(在此限定速度和位置) x2=x;v2=v;%初始化种群个体最有位置和 最优解 p2=x2;pbest2=ones(N,1);for i=1:N pbest2(i)=fitness(x2(i,:),D);end%初始化种全局最有位置和 最优解 g2=1000*ones(1,D);gbest2=1000;for i=1:Nif (pbest2(i)<gbest2)g2=p2(i,:); gbest2=pbest2(i);endend gb2=ones(1,T);% 浸入
32、主循环,按照公式依次迭代直到满足精度或者迭代次数 -for i=1:Tfor j=1:Nif (fitness(x2(j,:),D)<pbest2(j) p2(j,:)=x2(j,:); pbest2(j)=fitness(x2(j,:),D);endif (pbest2(j)<gbest2) g2=p2(j,:); gbest2=pbest2(j);end v2(j,:)=w2*v2(j,:)+c1*rand*(p2(j,:)-x2(j,:)+c2*rand*(g2-x2(j,:); x2(j,:)=x2(j,:)+v2(j,:);end gb2(i)=gbest2;endplo
33、t(gb2) TempStr=sprintf('w= %g ',w2); title(TempStr);xlabel('迭代次数');ylabel('适应度值');b)适应度函数 %适应度函数() function result=fitness(x,D) sum=0;for i=1:Dsum=sum+x(i)A2;endresult=sum;程序5对CiC22,对分别取Wi1.2 , w 0随笔其迭代影响a%主函数源程序% 根本粒子群算法 particle swarm optimization%名称: 根本粒子群算法%初始格式化clear all
34、;%去除所有变量clc;%清屏format long;%将数据显示为长整形科学计数%给定初始条条件 N=40;%3初始化群体个数D=10;%初始化群体维数T=100;%初始化群体最迭代次数c1=;%学习因子 1c2=2;%学习因子 2w1=;%惯性权重w2=0;%惯性权重eps=10A-6;%设置精度在最小值的时候用-%初始化种群个体限定位置和速度 x=zeros(N,D);v=zeros(N,D);for i=1:Nfor j=1:Dx(i,j)=randn; %随机初始化位置v(i,j)=randn; %随机初始化速度 endend%显示群位置 figure(1)for j=1:D if(
35、rem(D,2)>0)subplot(D+1)/2,2,j) elsesubplot(D/2,2,j) plot(x(:,j), 'b*');grid onxlabel(粒子') ylabel('初始位置') tI nfo=strcat('第:char(j+48),'维'); if(j>9)tI nfo=strcat(第:char(floor(j/10)+48), char(rem(j,10)+48),'维');endtitle(tInfo)end% 显示种群速度 figure(2)for j=1:D
36、if(rem(D,2)>0) subplot(D+1)/2,2,j)elsesubplot(D/2,2,j)end plot(x(:,j),'b*');grid on xlabel(粒子') ylabel('初始速度') tI nfo=strcat(第,char(j+48),'维'); if(j>9)tin fo=strcat(第',char(floor(j/10)+48), char(rem(j,10)+48),'维);endtitle(tInfo)endfigure(3)subplot(1,2,1)% 初始
37、化种群个体(在此限定速度和位置) x1=x;v1=v;% 初始化个体最优位置和最优值 -p1=x1;pbest1=ones(N,1);for i=1:N pbest1(i)=fitness(x1(i,:),D);end% 初始化全局最优位置和最优值 g1=1000*ones(1,D);gbest1=1000;for i=1:Nif (pbest1(i)<gbest1)g1=p1(i,:); gbest1=pbest1(i);endend gb1=ones(1,T);% 浸入主循环,按照公式依次迭代直到满足精度或者迭代次数 -for i=1:Tfor j=1:Nif (fitness(x1
38、(j,:),D)<pbest1(j) p1(j,:)=x1(j,:); pbest1(j)=fitness(x1(j,:),D);endif (pbest1(j)<gbest1) g1=p1(j,:); gbest1=pbest1(j);end v1(j,:)=w1*v1(j,:)+c1*rand*(p1(j,:)-x1(j,:)+c2*rand*(g1-x1(j,:); x1(j,:)=x1(j,:)+v1(j,:);end gb1(i)=gbest1;endplot(gb1)TempStr=sprintf('w= %g ',w1); title(TempStr)
39、;xlabel('迭代次数');ylabel('适应度值');subplot(1,2,2)% 初始化种群个体(在此限定速度和位置) x2=x;v2=v;%初始化种群个体最有位置和 最优解 p2=x2;pbest2=ones(N,1);for i=1:Npbest2(i)=fitness(x2(i,:),D);end% 初始化种全局最有位置和最优解 g2=1000*ones(1,D);gbest2=1000;for i=1:Nif(pbest2(i)<gbest2)g2=p2(i,:); gbest2=pbest2(i);endend gb2=ones(1,
40、T);% 浸入主循环,按照公式依次迭代直到满足精度或者迭代次数 -for i=1:Tfor j=1:Nif (fitness(x2(j,:),D)<pbest2(j) p2(j,:)=x2(j,:); pbest2(j)=fitness(x2(j,:),D);endif(pbest2(j)<gbest2) g2=p2(j,:); gbest2=pbest2(j);endv2(j,:)=w2*v2(j,:)+c1*rand*(p2(j,:)-x2(j,:)+c2*rand*(g2-x2(j,:); x2(j,:)=x2(j,:)+v2(j,:);endgb2(i)=gbest2;en
41、dplot(gb2)TempStr=sprintf('w= %g ',w2); title(TempStr);xlabel('迭代次数'); ylabel('适应度值');b)适应度函数 %适应度函数() function result=fitness(x,D) sum=0;for i=1:Dsum=sum+x(i)A2;endresult=sum;程序 6标准粒子群a%主函数源程序%根本粒子群算法( particle swarm optimization)% 名称: 根本粒子群算法%初始格式化clear all;clc;format long;
42、%给定初始条条件N=40;D=10;T=100;c1=2;c2=2;%去除所有变量%清屏%将数据显示为长整形科学计数%3初始化群体个数%初始化群体维数%初始化群体最迭代次数%学习因子 1%学习因子 2w=; eps=10A(-6);%惯性权重%设置精度在最小值的时候用%初始化种群个体限定位置和速度x=zerosN,D;v=zerosN,D;for i=1:Nfor j=1:Dx(i,j)=randn;%随机初始化位置v(i,j)=randn;%随机初始化速度endend% 显示群位置 figure(1)for j=1:Dif (rem(D,2)>0)subplot(D+1)/2,2,j)
43、elsesubplot(D/2,2,j)end plot(x(:,j), 'b*' );grid on xlabel(粒子') ylabel('初始位置')tI nfo=strcat('第:char(j+48),'维');if(j>9)tI nfo=strcat(第:char(floor(j/10)+48),char(rem(j,10)+48),'维'); end title(tInfo)end% 显示种群速度 figure(2)for j=1:Dif(rem(D,2)>0)subplot(D+1)/2
44、,2,j)elsesubplot(D/2,2,j)end plot(x(:,j),'b*');grid on xlabel(粒子') ylabel('初始速度') tI nfo=strcat(第',char(j+48),'维');if (j>9)tl nfo=strcat('第:char(floor(j/10)+48),char(rem(j,10)+48),'维'); end title(tInfo) end figure(3)% 初始化群体个体最有位置和最优解 p=x;pbest=ones(N,1)
45、;for i=1:Npbest(i)=fitness(x(i,:),D);end%-初始化全局最优位置和最优解 g=1000*ones(1,D);gbest=1000;for i=1:Nif (pbest(i)<gbest)g=p(i,:);gbest=pbest(i);endend gb=ones(1,T);% 进入主循环,按照公式依次迭代,直到满足精度要求 -for i=1:Tfor j=1:Nif (fitness(x(j,:),D)<pbest(j)p(j,:)=x(j,:);pbest(j)=fitness(x(j,:),D);endif(pbest(j)<gbes
46、t)g=p(j,:);gbest=pbest(j);end v(j,:)=w*v(j,:)+c1*rand*(p(j,:)-x(j,:)+c2*rand*(g-x(j,:); x(j,:)=x(j,:)+v(j,:);endgb(i)=gbest;endplot(gb)TempStr=sprintf('w= %g ',w);title(TempStr);xlabel('迭代次数'); ylabel (适应值');%适应度函数function result=fitness(x,D)sum=0;for i=1:D sum=sum+x(i)A2;endresu
47、lt=sum;程序6对Ci C2 2,对分别取wi1.2 , W20随笔其迭代影响a)%主函数源程序()% 根本粒子群算法 (partiCle swarm optimization)%名称: 根本粒子群算法%初始格式化Clear all;ClC;format long;%去除所有变量%清屏%将数据显示为长整形科学计数%给定初始条条件N=40;D=10;T=100;C1=;C2=2;w1=w2=w3=w4=%3初始化群体个数 %初始化群体维数 %初始化群体最迭代次数 %学习因子 1 %学习因子 2% 惯性权重 1%惯性权重2%惯性权重3%惯性权重 4w5=%惯性权重 5eps=10(6);%设置精度(在最小值的时