//Chapter 7 //Example 7.4 //page 263 //To find required generation for each plant and losses incurred clear;clc; ///Let us use the program given in the Appendix G in the textbook which includes penalty factor also to write //a function that returns the value of lamda,Loading of each generator and losses //when the total load on the plant is sent to the function function [lamda,Pg,PL]=optimum2(Pd) n=2; //no of generators Alpha=[0.02 0.04]; Beta=[16 20]; lamda=20; //initial value of lamda lamdaprev=lamda; eps=1; //tolerance deltalamda=0.1; Pgmax=[200 200]; Pgmin=[0 0]; B=[0.001 0;0 0]; Pg=zeros(n,1); noofiter=0; PL=0; Pg=zeros(n,1); while abs(sum(Pg)-Pd-PL)>eps for i=1:n sigma=B(i,:)*Pg-B(i,i)*Pg(i); Pg(i)=(1-(Beta(i)/lamda)-(2*sigma))/(Alpha(i)/lamda+2*B(i,i)); PL=Pg.'*B*Pg; if Pg(i)>Pgmax(i) then Pg(i)=Pgmax(i); end if Pg(i)