搜索内容 搜索用户

# 28 麦片

050

34主题 0最佳答案
 clc; clear all; h=3; T1=[1,1,h]; T2=[4,1,h]; T3=[4,4,h]; T4=[1,4,h]; a=[T1(1),T2(1),T3(1),T4(1)]; b=[T1(2),T2(2),T3(2),T4(2)]; d=[1.7967,1.7967,1.7967,1.7967]; %%%%%%%%%%%%%%%%%%%%%%粒子群算法参数初始化%%%%%%%%%%%%%%%%%%%%%%%%% N=100; %群体粒子个数 D=2; T=200; %迭代次数 c1=1.5; %学习因子1 c2=1.5; %学习因子2 Wmax=0.8; %惯性权重 Wmin=0.4; Xmax=5; %位置 Xmin=0; Vmax=1; Vmin=-1; %%%%%%%%%%%%%%%%%%%%%%个体位置和速度初始化%%%%%%%%%%%%%%%%%%%%%%%%% x=rand(N,D)*(Xmax-Xmin)+Xmin; v=rand(N,D)*(Vmax-Vmin)+Vmin; %%%%%%%%%%%%%%%%%%%%%%个体最优值%%%%%%%%%%%%%%%%%%%%%%%%% p=xp; pbest=ones(N,1); for i=1:N     pbest(i)=func2(x(i,:)); end %%%%%%%%%%%%%%%%%%%%%%全局最优值%%%%%%%%%%%%%%%%%%%%%%%%% g=ones(1,D); gbest=inf; for i=1:N     if(pbest(i)Vmax)|(v(j,ii)Xmax|x(j,ii)

# 203 麦片

50500

0主题 41最佳答案
• 关注者： 12

 解答如下 clc; clear all; global a b d h h=3; T1=[1,1,h]; T2=[4,1,h]; T3=[4,4,h]; T4=[1,4,h]; a=[T1(1),T2(1),T3(1),T4(1)]; b=[T1(2),T2(2),T3(2),T4(2)]; d=[1.7967,1.7967,1.7967,1.7967]; %%%%%%%%%%%%%%%%%%%%%%粒子群算法参数初始化%%%%%%%%%%%%%%%%%%%%%%%%% N=100; %群体粒子个数 D=2; T=200; %迭代次数 c1=1.5; %学习因子1 c2=1.5; %学习因子2 Wmax=0.8; %惯性权重 Wmin=0.4; Xmax=5; %位置 Xmin=0; Vmax=1; Vmin=-1; %%%%%%%%%%%%%%%%%%%%%%个体位置和速度初始化%%%%%%%%%%%%%%%%%%%%%%%%% x=rand(N,D)*(Xmax-Xmin)+Xmin; v=rand(N,D)*(Vmax-Vmin)+Vmin; %%%%%%%%%%%%%%%%%%%%%%个体最优值%%%%%%%%%%%%%%%%%%%%%%%%% p=x; pbest=ones(N,1); for i=1:N     pbest(i)=func2(x(i,:)); end %%%%%%%%%%%%%%%%%%%%%%全局最优值%%%%%%%%%%%%%%%%%%%%%%%%% g=ones(1,D); gbest=inf; for i=1:N     if(pbest(i)Vmax)|(v(j,ii)Xmax|x(j,ii)

# 28 麦片

050

34主题 0最佳答案
楼主| 发表于 2020-9-8 11:00:38 | 显示全部楼层
 wjb986555360 发表于 2020-9-7 22:57 解答如下 clc; clear all; 已解决 非常感谢

 您需要登录后才可以回帖 登录 | 注册 本版积分规则 回帖后跳转到最后一页