//Chapter 7 //Example 7.1 //page 246 //To find incremental cost and load sharing clear;clc; ///Let us use the program given in the Appendix G in the textbook to write //a function that returns the value of lamda and Loading of each generator //when the total load on the plant is sent to the function function [lamdaprev,Pg]=optimum(Pd) n=2; //number of generators Alpha=[0.2 0.25]; Beta=[40 30]; lamda=35; //initial guess for lambda lamdaprev=lamda; eps=1; //tolerance deltalamda=0.25; //increment in lamda Pgmax=[125 125]; Pgmin=[20 20]; Pg=100*ones(n,1); while abs(sum(Pg)-Pd)>eps for i=1:n Pg(i)=(lamda-Beta(i))/Alpha(i); if Pg(i)>Pgmax(i) then Pg(i)=Pgmax(i); end if Pg(i)