循环迭代程序 数据文件的读写~
c1:=2.0;c2:=2.0;
w:=0.5;
v_max=100;
var temp,temp_p,ran:=real;
position:=array[0..dim] of real;
pi_min:=array[0..dim] of real;
pg_min:=array[0..dim] of real;
begin
position[0]:=-50.2;
position[1]:=60.0;
pi_min[0]:=100;
pi_min[1]:=100;
pg_min[0]:=0;
pg_min[1]:=0;
temp:=0;temp_p:=0
randomsize;
ran:=random(50);
for i to dim do
begin
for k to ran do
temp:=w*position[i]+c1*ran*(pi_min[i]-position[i])+c2*ran*(pg_min[i]-position[i]);
if temp>v_max then v_max:=temp;
if temp<-v_max then v_max:=temp;
temp_p:=temp+position;
if temp>v_max then v_max:=temp;
if temp<-v_max then v_max:=temp;
end;
end;