HOMEWORKsubmit

# HOMEWORKsubmit - %Residual for k = 1:ngg if Pgg(k>...

This preview shows pages 1–2. Sign up to view the full content.

%fuel cost function is derived from cost matrix, mwlimits matrix shows %limitation of genertor cost=[30 10 0.002 ; 20 8 0.0025 ;10 6 0.005]; % mwlimits=[100 600 ;100 400 ; 50 200]; Pdt=1100; ngg = length(cost(:,1)); alpha=cost(:,1); beta=cost(:,2); gama = cost(:,3); Pmin=mwlimits(:,1); Pmax=mwlimits(:,2); wgt=ones(1, ngg); iterp = 0; % Iteration counter DelP = 10; % Error in DelP is set to a high value E=zeros(ngg, ngg); if exist('lambda')~=1 lambda=6; %set initial value of lambda end while abs(DelP) >= 0.001 % Test for convergence iterp = iterp + 1; % Number of iterations for k=1:ngg if wgt(k) == 1 E(k,k) = gama(k); Dx(k) = 1/2*(lambda - beta(k)); else, E(k,k)=1; Dx(k) = 0; for m=1:ngg if m~=k E(k,m)=0; else,end end end end PP=inv(E)*Dx'; for k=1:ngg if wgt(k)==1 Pgg(k) = PP(k); else,end end Pgtt = sum(Pgg); DelP =Pdt-Pgtt ;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %Residual for k = 1:ngg if Pgg(k) > Pmax(k) & abs(DelP) <=0.001,%check the limitation of generator Pgg(k) = Pmax(k); wgt(k) = 0; %mark the fix value of genertor k elseif Pgg(k) < Pmin(k) & abs(DelP) <= 0.001 Pgg(k) = Pmin(k); wgt(k) = 0; else, end end DelP =Pdt - sum(Pgg); %Residual for k=1:ngg grad(k)=1/(2*gama(k)); end sumgrad=wgt*grad'; Delambda = DelP/sumgrad; % Compute the change in lambda lambda = lambda + Delambda; % Successive solution end fprintf('Incremental cost of delivered power lambda = %9.4f \$/MWh \n', lambda); fprintf('Optimal Dispatch of Generation:\n\n') disp(Pgg') Pmt = [ones(1,ngg); Pgg; Pgg.^2]; for ii = 1:ngg costv(ii) = cost(ii,:)*Pmt(:,ii); end totalcost=sum(costv); fprintf('\nTotal generation cost = % 10.2f \$/h \n', totalcost)...
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

HOMEWORKsubmit - %Residual for k = 1:ngg if Pgg(k>...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online