필터 지우기
필터 지우기

plz can anybody see d below coding for economic load dispatch with the help of genetic alogorithem i have some error plz i tried a lot bt cant do ....this is my own code ....

조회 수: 2 (최근 30일)
clear
%This is a program of economic generation scheduling using genetic algorithm
%method with limits imposed on generators.
%This program calculates the values of generations for all the three
%generators for a given load demand. It loads the fuel cost characteristics
%as well the minimum and maximum limits of generators from fuelcost.m file.
%%%%%%%%%%%%%%ENTER ALL THE REQUIRED DATA%%%%%%%%%%%%%
load fuelcost.m
load losscoefficient1.m
for i=1:6
for j=1:6
B(i,j) = losscoefficient1(i,j);
end
end
af = fuelcost(:,1);
bf = fuelcost(:,2);
cf = fuelcost(:,3);
pgmin = fuelcost(:,4);
pgmax = fuelcost(:,5);
alpha = 1.0;
ITMAX = 50;
BIG = 1.0;
l = input ('Enter the length of string l= ');
L = input ('Enter the population size L = ');
pc= input ('Enter the probability of crossover pc = ');
pd= input ('Enter the value of load demand in MW = ');
%%%%%%GENERATE POPULATION OF RANDOM BINARY NUMBER ARRAY%%%%
for i=1:L
for j=1:l
a=rand(1);
if a > 0.5
b(i,j)=1;
else
b(i,j)=0;
end
end
end
it=1;
k=0;
j=0;
BIG = 1.0;
fmax=0.0;
fmin=1.0;
x=(L/6);
while (it<=ITMAX)
k=k+1;
j=0;
j=j+1;
end
%%%%%%%%%%%CONVERT POPULATION IN BINARY TO DECIMAL%%%%%%%%
while (j<=x)
if it==1
g=1;
d(g,j)=bi2de(b(j,:));
g=2;
d(g,j)=bi2de(b(j+x,:));
g=3;
d(g,j)=bi2de(b(j+(2*x),:));
g=4;
d(g,j)=bi2de(b(j+(3*x),:));
g=5;
d(g,j)=bi2de(b(j+(4*x),:));
g=6;
d(g,j)=bi2de(b(j+(5*x),:));
else
for i=1:n
g=1;
d(g,i)=bin2dec(c1(i,:));
d(g,n+i)=bin2dec(c1(n+i,:));
g=2;
d(g,i)=bin2dec(c2(i,:));
d(g,n+i)=bin2dec(c2(n+i,:));
g=3;
d(g,i)=bin2dec(c3(i,:));
d(g,n+i)=bin2dec(c3(n+i,:));
g=4;
d(g,j)=bi2de(b(j+(3*x),:));
g=5;
d(g,j)=bi2de(b(j+(4*x),:));
g=6;
d(g,j)=bi2de(b(j+(5*x),:));
end
end
%%%%%%%%%CALCULATING THE GENERATION POWER IN MW%%%%%%%%%%
for i=1:6
px(i)=(pgmax(i)-pgmin(i))/((2^(l))-1);
end
for i=1:6
pg(i,j)=pgmin(i)+(px(i)*d(i,j));
end
%%%%%%%%CALCULATING THE TOTAL GENERATION POWER IN MW%%%%%%
sum1=0;
for i =1:6
sum1 =sum1 + pg(i,j);
end
pge(j) = sum1;
%%%%%%%CALCULATING THE TRANSMISSION LINE LOSS IN MW%%%%%%%%%
sum=0;
for i=1:6
for k=1:3
sum = sum +(pg(i,j))*(B(i,k))*(pg(k,j));
end
end
pl = sum;
epsilon(j) = abs (pd + sum-sum1);
if epsilon(j)<BIG
BIG = epsilon(j);
end
%%%%%%%%%CALCULATION THE FITNESS FUNCITON%%%%%%%%%%%%%%
fitness(j)=1/(1+(epsilon(j)/pd));
if fitness(j)>fmax
fmax=fitness(j);
end
if fitness(j)<fmin
fmin=fitness(j);
end
if it==1
explode = zeros(size(fitness));
[c,offset]= max(fitness);
explode(offset) =1;
h = pie (fitness,explode);
pause;
end
j=j+1;
end
%%%%%%%%%CALCULATING MAXIMUM & AVERAGE FITNESS %%%%%%%%%%
fitnessmax= max(fitness);
sum=0;
for i=1:(L/6)
sum= sum + fitness(i);
end
average = (sum / (L/6));
%%%SELECT THE PARENT USING STOCHASTIC REMAINDER ROULETTE WHEEL SELECTION%%%
i=0;
j=0;
sum=average;
j=j+1;
while j<=(L/6)
y=fitness(j)/sum;
a=y/2;
if a>=(0.5)
I=1;
else
I=0;
end
F(j)=y-I;
while I>0
if I<0
if j<20
j=j+1;
else
break
end
else
i=i+1;
I=I-1;
sel(i)=j;
m(i)=sel(i);
end
end
if j<(L/6)
j=j+1;
else
break
end
end
i=(L/12);
n=i;
j=0;
while i<(L/6)
if i>20
break
else
j=j+1;
if j>20
j=1;
else
j=j;
end
if F(j)>0.0
a=rand();
if a>0.5
w=1;
else
w=0;
end
if w==1
i=i+1;
sel1(i)=j;
m1(i)=sel1(i);
F(j)=F(j)-1;
else
end
else
end
end
end
%%%%%%%PERFORM SINGLE POINT CROSSOVER FOR SELECTED PARENTS%%%
for i=1:n
s=m(i);
s1=m1(n+i);
cp=round(pc*l);
for k=1
a1=d(k,s,:);
a2=d(k,s1,:);
bit1=dec2bin(a1,l);
bit2=dec2bin(a2,l);
c1(i,:)=[bit1(1:cp),bit2(cp+1:l)];
c1(n+i,:)=[bit2(1:cp),bit1(cp+1:l)];
end
for k=2
a1=d(k,s,:);
a2=d(k,s1,:);
bit1=dec2bin(a1,l);
bit2=dec2bin(a2,l);
c2(i,:)=[bit1(1:cp),bit2(cp+1:l)];
c2(n+i,:)=[bit2(1:cp),bit1(cp+1:l)];
end
for k=3
a1=d(k,s,:);
a2=d(k,s1,:);
bit1=dec2bin(a1,l);
bit2=dec2bin(a2,l);
c3(i,:)=[bit1(1:cp),bit2(cp+1:l)];
c3(n+i,:)=[bit2(1:cp),bit1(cp+1:l)];
for k=4
a1=d(k,s,:);
a2=d(k,s1,:);
bit1=dec2bin(a1,l);
bit2=dec2bin(a2,l);
c1(i,:)=[bit1(1:cp),bit2(cp+1:l)];
c1(n+i,:)=[bit2(1:cp),bit1(cp+1:l)];
end
for k=5
a1=d(k,s,:);
a2=d(k,s1,:);
bit1=dec2bin(a1,l);
bit2=dec2bin(a2,l);
c2(i,:)=[bit1(1:cp),bit2(cp+1:l)];
c2(n+i,:)=[bit2(1:cp),bit1(cp+1:l)];
end
for k=6
a1=d(k,s,:);
a2=d(k,s1,:);
bit1=dec2bin(a1,l);
bit2=dec2bin(a2,l);
c3(i,:)=[bit1(1:cp),bit2(cp+1:l)];
c3(n+i,:)=[bit2(1:cp),bit1(cp+1:l)];
end
end
it=it+1;
end
%%%%%%%%%%%%%COST OF GENERATION%%%%%%%%%%%%%%%%%%%
sum=0;
for i=1:6
sum=sum + (af(i)*(pg(i,j)^2)+ bf(i)*(pg(i,j))+ cf(i));
end
%%%GENERATING PIE CHART FOR GENERATION AT ALL GENERATOR BUSES%%
for i=1:6
x(i)=pg(i);
end
explode = zeros(size(x));
[c,offset]= max(x);
explode(offset) =1;
g = pie (x,explode);
title('\bfPERCENTAGE OF GENERATION AT GENERATOR BUSES FOR BEST RESULTS');
%%%%%%%%%%%%%%RESULT OF THE PROGRAM%%%%%%%%%%%%%%%%%
fprintf('fmax = %f \n',fmax)
pg1 = pg(1,j);
fprintf('pg1= %f MW \n',pg1);
pg2 = pg(2,j);
fprintf('pg2= %f MW \n',pg2);
pg3 = pg(3,j);
fprintf('pg3= %f MW \n',pg3);
total = pge(j);
fprintf('Total generation = %f MW \n',total);
pl = pl;
fprintf('Transmission losses are = %f MW \n',pl);
totalcost = sum;
fprintf('Total cost of generation are = %f Rs/h \n', sum)
%%%%%fuel cost%%%
0.007 7 240 100 500
0.0095 10 200 50 200
0.009 8.5 220 80 300
0.009 11 200 50 150
0.008 10.5 220 50 200
0.0075 12 120 50 120
%%%%%%%%%losscoefficient11%%%%%%%%%%%
0.000014 0.000017 0.000015 0.000019 0.000026 0.000022
0.000017 0.00006 0.000013 0.000016 0.000015 0.00002
0.000015 0.000013 0.000065 0.000017 0.000024 0.000019
0.000019 0.000016 0.000017 0.000071 0.00003 0.000025
0.000026 0.000015 0.000024 0.00003 0.000069 0.000032
0.000022 0.00002 0.000019 0.000025 0.000032 0.000085
  댓글 수: 16
radhe  krishan
radhe krishan 2017년 4월 17일
편집: Walter Roberson 2017년 4월 17일
sir why here we take (L/6) in other loop in population size.
and how can add mutation code in programmed
Walter Roberson
Walter Roberson 2017년 4월 17일
I have no idea why L/6 was taken as the population size.
The author of the code, kishan bhayani, posted it in 2013, and is probably no longer available to ask questions of.

댓글을 달려면 로그인하십시오.

답변 (3개)

kishan bhayani
kishan bhayani 2013년 3월 11일
Attempted to access F(11); index out of bounds because numel(F)=10.
Error in ==> jaydeep at 210 if F(j)>0.0

Walter Roberson
Walter Roberson 2013년 3월 11일
Your while i<(L/6) loop can increments j until j > 20, controlled by i < (L/6), but i is only incremented if w==1. You need to trace further and determine whether possibly that conditional increment of i can lead to situations in which j is incremented past the point F(j) is defined to (which is (L/6))
  댓글 수: 1
kishan bhayani
kishan bhayani 2013년 3월 11일
Index exceeds matrix dimensions.
Error in ==> jaydeep at 76 d(g,n+i)=bin2dec(c1(n+i,:)); now new error started????????

댓글을 달려면 로그인하십시오.


radhe  krishan
radhe krishan 2017년 5월 5일
편집: Walter Roberson 2017년 5월 5일
BIG = 1.0;
fmax=0.0;
fmin=1.0;
x=(L/6);
while (it<=ITMAX)
k=k+1;
j=0;
j=j+1;
end
sir
here why we take x=L/6 in binary to decimal conversion

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by