Program8a
clc;
clear;
Pd=input("Enter the Total Power Demand: ");
n=input("Enter the number of Generating units: ");
disp("Enter the cost function parameters of each units:")
for (i=1:n)
Pmax(i)=input("Enter the Maximum Power limit: ");
Pmin(i)=input("Enter the Minimum Power limit: ");
a(i)=input("Enter the co-efficient of P^2: ");
b(i)=input("Enter the co-efficient of P: ");
c(i)=input("Enter the constant: ");
t(i)=0
end
nu=0;
de=0;
C=0;
for (i=1:n)
nu = (nu + (b(i)/(2*a(i))));
de = (de + (1/(2*a(i))));
end
l = ((Pd + nu)/de);
for (i=1:n)
if (t(i)==0) then
for (k=1:n)
if (t(k)==0) then
P(k)=((l - b(k))/(2*a(k)));
if (P(k)>Pmax(k)) then
P(k)=Pmax(k);
t(k)=1;
nu = (nu - (b(k)/(2*a(k))));
de = (de - (1/(2*a(k))));
Pd = Pd - P(k);
l = ((Pd + nu)/de);
elseif (P(k)<Pmin(k)) then
P(k)=Pmin(k);
t(k)=1;
nu = (nu - (b(k)/(2*a(k))));
de = (de - (1/(2*a(k))));
Pd = Pd - P(k);
l = ((Pd + nu)/de);
end
end
end
end
end
disp(P,"Generation in each unit: ");
for(i=1:n)
F(i)=c(i)+(b(i)*P(i))+(a(i)*(P(i)^2));
C= C + F(i);
disp(F(i));
end
disp(C);
Output:
Enter the Total Power Demand: 925
Enter the number of Generating units: 3
Enter the cost function parameters of each units:
Enter the Maximum Power limit: 450
Enter the Minimum Power limit: 250
Enter the co-efficient of P^2: 0.0045
Enter the co-efficient of P: 5.2
Enter the constant: 580
Enter the Maximum Power limit: 350
Enter the Minimum Power limit: 200
Enter the co-efficient of P^2: 0.0056
Enter the co-efficient of P: 4.5
Enter the constant: 640
Enter the Maximum Power limit: 225
Enter the Minimum Power limit: 125
Enter the co-efficient of P^2: 0.00792
Enter the co-efficient of P: 5.8
Enter the constant: 820
Generation in each unit:
390.82126
350.
184.17874
3299.6062
2901.
2156.8974
8357.5036