Error in implementing particle swarm optimization in power system using MATLAB -


i'm trying solution of economic load despatch using particle swarm optimization. i've written code during updating velocity , particle position in second iteration, not generate power value of generator adds 850. somehow algorithm isn't converging. please try run in matlab

clear clc %initialization c1 = 2.0, c2 = 2.0 wmax = 0.9, wmin = 0.4 count = 0,countv=0 p1min = 100,p1max = 600 p2min = 50,p2max = 200 p3min = 100,p3max = 400 v1min = -50, v1max = 300 v2min = -25, v2max = 100 v3min = -50, v3max = 200 pd = 850 counter=0  i=1:10000     sum1=0;     if count<10         g(i-counter,1) = (p1max - p1min)*rand() + p1min         g(i-counter,2) = (p2max - p2min)*rand() + p2min         g(i-counter,3) = (p3max - p3min)*rand() + p3min         sum1=round(g(i-counter,1)+g(i-counter,2)+g(i-counter,3))         if sum1==pd             count=count+1;         else             g(i-counter,:)=[]             counter=counter+1;         end     end end     i=1:10                                                   %cost function found     f(i,1) = 0.0016*(g(i,1))^2+7.92*g(i,1)+561 + 0.0048*(g(i,2))^2+ 7.92*g(i,2) + 78 +    0.0019*(g(i,3))^2 + 7.85*g(i,3) + 310 end    total1 = [f g]   i=1:10                                                         %intial velocity obtained     v(i,1)= v1min + rand()*(v1max-v1min)     v(i,2)= v2min + rand()*(v2max-v2min)     v(i,3)= v3min + rand()*(v3max-v3min)     countv = countv +1     if countv == 10         break     end  end  ginti = 0 k=1:100      w=wmax - ((wmax-wmin)/100)*k                   %k final loop      gbest=min(total1(:,:))                                           %pbest , gbest found     pbest=total1(:,:)     counter = 0     count = 0       %velocity updated     i=1:100000         if count<10             vnew(i-counter,1) = w*v(i-counter,1) + c1*rand()*(pbest(i-counter,2)-g(i-counter,1)) + c2*rand()*(gbest(1,2)-g(i-counter,1))             vnew(i-counter,2) = w*v(i-counter,2) + c1*rand()*(pbest(i-counter,3)-g(i-counter,2)) + c2*rand()*(gbest(1,3)-g(i-counter,2))             vnew(i-counter,3) = w*v(i-counter,3) + c1*rand()*(pbest(i-counter,4)-g(i-counter,3)) + c2*rand()*(gbest(1,4)-g(i-counter,3))              gnew(i-counter,1) = g(i-counter,1) + vnew(i-counter,1)             gnew(i-counter,2) = g(i-counter,2) + vnew(i-counter,2)             gnew(i-counter,3) = g(i-counter,3) + vnew(i-counter,3)              if gnew(i-counter,1)<=600 & gnew(i-counter,1)>=100 & gnew(i-counter,2)>=50 & gnew(i-counter,2)<=200& gnew(i-counter,3)>=100 & gnew(i-counter,3) <=400 & round(gnew(i-counter,1) + gnew(i-counter,2) + gnew(i-counter,3))==pd                 count = count + 1;             else                 vnew(i-counter,:) = []                 gnew(i-counter,:) = []                 counter = counter+1;             end         end      end       i=1:10                                                   % updated cost function found         fnew(i,1) = 0.00156*(gnew(i,1))^2+7.92*gnew(i,1)+561 + 0.00194*(gnew(i,2))^2+ 7.85*gnew(i,2) + 310 + 0.00482*(gnew(i,3))^2 + 7.97*gnew(i,3) + 78     end      total2 = [fnew gnew]      % comparison of 2 tables     i=1:10         if (total1(i,1)<=total2(i,1))             total3(i,:)= total1(i,:)         else             total3(i,:)= total2(i,:)         end     end     total1=total3     g(:,1)=total3(:,1)     g(:,2)=total3(:,2)     g(:,3)=total3(:,3)     ginti= ginti + 1 end 


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -