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 ....
이전 댓글 표시
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
Azzi Abdelmalek
2013년 3월 9일
Walter Roberson
2013년 3월 9일
What error do you encounter?
kishan bhayani
2013년 3월 9일
kishan bhayani
2013년 3월 9일
편집: Walter Roberson
2013년 3월 9일
Walter Roberson
2013년 3월 9일
Which line is 234 ?
kishan bhayani
2013년 3월 10일
Walter Roberson
2013년 3월 10일
At the command line, please give the command
dbstop if error
and then run the program. When it stops, please show the value of k, and of s1.
I have a suspicion that s1 might be 0.
Deepika raghani
2014년 1월 28일
hey did u find the error?? i tried but cant get the output?
radhe krishan
2017년 4월 12일
why here use fmin and fmax in this program
Walter Roberson
2017년 4월 12일
fmin and fmax give some information about the minimum and maximum fitness values encountered. Sometimes those are interesting to look at afterwards or while debugging.
radhe krishan
2017년 4월 14일
if F(j)>0.0 am facing some problem to run the program in this line and its output is come " Attempted to access F(8); index out of bounds because numel(F)=6"
Walter Roberson
2017년 4월 14일
I see a number of places where the code is quite questionable. For example right near the beginning:
while (it<=ITMAX)
k=k+1;
j=0;
j=j+1;
end
Why set j to 0 and then add 1 to it? And if the loop body gets entered at all then this will be an infinite loop because it does not change it or ITMAX.
Or further down,
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
Look at the first if there, if I<0 -- but if I < 0 then you would have left the while already because it is I>0 . Why is the code written that way?
I would not have confidence in this code.
radhe krishan
2017년 4월 15일
편집: Walter Roberson
2017년 4월 15일
but sir am facing some problem in below loop
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
and i can't find the problem in the program and i not get the value of sel(i)=j and m(i)=sel(i)
Walter Roberson
2017년 4월 15일
I tried the code as posted, but I can't seem to get past the infinite loop that I mentioned. How did you get past it?
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
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
2013년 3월 11일
0 개 추천
댓글 수: 1
radhe krishan
2017년 4월 14일
sir you solved this problem if you solve this problem than guide me, am facing same problem in this program
Walter Roberson
2013년 3월 11일
0 개 추천
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))
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
댓글 수: 1
Walter Roberson
2017년 5월 5일
It appears to me that a 2D array with 6 rows (or 6 columns) is being emulated.
카테고리
도움말 센터 및 File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!