Está en la página 1de 3

# ALGORITMO PARA EL CALCULO DE DESPACHO

ECONOMICO
clear all
clc
format compact
format short
%C1=200+7*P1+0.008*P1^2;
%C2=180+6.3*P2+0.009*P2^2;
%C1=140+6.8*P3+0.007*P3^2;

%PL=0.000218*P1^2+0.000228*P2^2+0.000179*P3^2;

%P1=10:85;
%P2=10:80;
%P3=10:70;

A=input('ingrese alfas:');
B=input('ingrese betas:');
G=input('ingrese gamas:');
Bi=input('ingrese betas de perdidas:');
lan=input('ingrese lamda inicial:')

iter=1;

P1=(lan-B(1,1))/(2*G(1,1)+2*lan*Bi(1,1));
P2=(lan-B(1,2))/(2*G(1,2)+2*lan*Bi(1,2));
P3=(lan-B(1,3))/(2*G(1,3)+2*lan*Bi(1,3));
PL=Bi(1,1)*P1^2+Bi(1,2)*P2^2+Bi(1,3)*P3^2;

DP=PD+PL-(P1+P2+P3);
J=(G(1,1)+Bi(1,1)*B(1,1))/(2*(G(1,1)+lan*Bi(1,1))^2)+
(G(1,2)+Bi(1,2)*B(1,2))/(2*(G(1,2)+lan*Bi(1,2))^2)+
(G(1,3)+Bi(1,3)*B(1,3))/(2*(G(1,3)+lan*Bi(1,3))^2);
Dlan=DP/J;

iter=iter+1;
lan=lan+Dlan

P1=(lan-B(1,1))/(2*G(1,1)+2*lan*Bi(1,1));
P2=(lan-B(1,2))/(2*G(1,2)+2*lan*Bi(1,2));
P3=(lan-B(1,3))/(2*G(1,3)+2*lan*Bi(1,3));
PL=Bi(1,1)*P1^2+Bi(1,2)*P2^2+Bi(1,3)*P3^2;

DP=PD+PL-(P1+P2+P3);
J=(G(1,1)+Bi(1,1)*B(1,1))/(2*(G(1,1)+lan*Bi(1,1))^2)+
(G(1,2)+Bi(1,2)*B(1,2))/(2*(G(1,2)+lan*Bi(1,2))^2)+
(G(1,3)+Bi(1,3)*B(1,3))/(2*(G(1,3)+lan*Bi(1,3))^2);
Dlan=DP/J;

iter=iter+1;
lan=lan+Dlan

P1=(lan-B(1,1))/(2*G(1,1)+2*lan*Bi(1,1));
P2=(lan-B(1,2))/(2*G(1,2)+2*lan*Bi(1,2));
P3=(lan-B(1,3))/(2*G(1,3)+2*lan*Bi(1,3));
PL=Bi(1,1)*P1^2+Bi(1,2)*P2^2+Bi(1,3)*P3^2;

DP=PD+PL-(P1+P2+P3);
J=(G(1,1)+Bi(1,1)*B(1,1))/(2*(G(1,1)+lan*Bi(1,1))^2)+
(G(1,2)+Bi(1,2)*B(1,2))/(2*(G(1,2)+lan*Bi(1,2))^2)+
(G(1,3)+Bi(1,3)*B(1,3))/(2*(G(1,3)+lan*Bi(1,3))^2);
Dlan=DP/J;

iter=iter+1;
lan=lan+Dlan

P1=(lan-B(1,1))/(2*G(1,1)+2*lan*Bi(1,1));
P2=(lan-B(1,2))/(2*G(1,2)+2*lan*Bi(1,2));
P3=(lan-B(1,3))/(2*G(1,3)+2*lan*Bi(1,3));
PL=Bi(1,1)*P1^2+Bi(1,2)*P2^2+Bi(1,3)*P3^2;

DP=PD+PL-(P1+P2+P3);
J=(G(1,1)+Bi(1,1)*B(1,1))/(2*(G(1,1)+lan*Bi(1,1))^2)+
(G(1,2)+Bi(1,2)*B(1,2))/(2*(G(1,2)+lan*Bi(1,2))^2)+
(G(1,3)+Bi(1,3)*B(1,3))/(2*(G(1,3)+lan*Bi(1,3))^2);
Dlan=DP/J;

disp('-------------------------------------------------------
------')
disp([' iter DP lan P1 P2
P3 '])

## disp('---------COSTO MINIMO TOTAL DE GENERACION------------')

CT=A(1,1)+B(1,1)*P1+G(1,1)*P1^2+A(1,2)+B(1,2)*P1+G(1,2)*P1^2+
A(1,3)+B(1,3)*P1+G(1,3)*P1^2;
disp(CT)
Realizado para el ejemplo en clases
ingrese alfas:[200 180 140]
ingrese betas:[7 6.3 6.8]
ingrese gamas:[8e-3 9e-3 7e-3]