Escolar Documentos
Profissional Documentos
Cultura Documentos
clc;
close all;
clear all;
format long;
% ----------------------------------------------------------------- %
% Parâmetros do exercício:
G(1) = 20;
n(1) = 2;
P(1) = 0.98;
G(2) = 30;
n(2) = 1;
P(2) = 0.98;
G(3) = 30;
n(3) = 1;
P(3) = 0.985;
G(4) = 40;
n(4) = 1;
P(4) = 0.98;
G(5) = 40;
n(5) = 1;
P(5) = 0.99;
T(1) = 250;
nT(1) = 1;
Pt(1) = 1 - 0.00363967;
T(2) = 350;
nT(2) = 1;
Pt(2) = 1 - 0.00341297;
Grupos = 5;
GruposT = 2;
1
% ----------------------------------------------------------------- %
% Número de Estados (utilizado para as linhas da tabela)
% Numero de estados
Ne = PotGt/mdc;
NeT = PotTt/mdcT;
% ----------------------------------------------------------------- %
% Determinação da Matriz de Probabilidade
k=1;
for z = 1:Grupos
prob(k) = 0;
for k = 1:(n(z)+1)
C = nchoosek(n(z),(k-1));
prob(k) = C*(P(z)^(n(z)-(k-1))*((1-P(z))^(k-1)));
end
probabilidade(:,z) = prob;
end
% ----------------------------------------------------------------- %
pot(z,k+1) = ((G(z)*n(z)))-(G(z)*k);
2
if(pot(z,k+1) < 0)
pot(z,k+1) = 0;
end
end
end
potencia = pot';
for p = 1:(Nmax+1)
for q = 1:(Nmax+1)
end
end
Matriz_Pot_Conf_T(:,:,2) = prob_final;
for i = [0:mdc:maxima_potencia]
linha = linha';
coluna = coluna';
z=1;
aux = zeros(1,7);
if (length(linha) > 1)
for j = 1:Nmax
3
aux(z) = Matriz_Pot_Conf_T(linha(j),coluna(j),2) + aux(z);
end
for j = 1:Nmax
Matriz_Pot_Conf_T(linha(j),coluna(j),2) = aux(z);
end
end
z = z+1;
end
t = 1;
for i = 1:Nmax+1
for j = 1:Nmax
vetor_Matriz_Pot_T(t) = Matriz_Pot_Conf_T(i,j,1);
vetor_Matriz_Conf_T(t) = Matriz_Pot_Conf_T(i,j,2);
t = t + 1;
end
end
for i = 1:(length(vetor_Matriz_Pot_T))
for j = 1:(length(vetor_Matriz_Pot_T))
if(vetor_Matriz_Pot_T(j)<vetor_Matriz_Pot_T(i))
aux = vetor_Matriz_Pot_T(i);
aux1 = vetor_Matriz_Conf_T(i);
vetor_Matriz_Pot_T(i) = vetor_Matriz_Pot_T(j);
vetor_Matriz_Conf_T(i) = vetor_Matriz_Conf_T(j);
vetor_Matriz_Pot_T(j) = aux;
4
vetor_Matriz_Conf_T(j) = aux1;
end
end
end
Vetor_Pot_Conf(:,:,2) = vetor_Matriz_Conf_T;
combinacao_01_02 = Vetor_Pot_Conf;
B = A(diff([0 A])~=0);
C = combinacao_01_02(:,:,2);
D = C(diff([0 A])~=0);
combinacao_final_01_02(:,:,1) = B;
combinacao_final_01_02(:,:,2) = D;
% Combinação 02 - 03
linha = 1;
coluna = 1;
prob_final_01(linha,coluna) = ...
combinacao_final_01_02(1,coluna,2)*probabilidade(linha,3);
pot_final_01(linha,coluna) = ...
combinacao_final_01_02(1,coluna,1) + potencia(linha,3);
coluna = coluna + 1;
end
coluna = 1;
linha = linha + 1;
end
5
% Montagem da matriz com vetores:
Matriz_Pot_Conf_02(:,:,1) = pot_final_01;
Matriz_Pot_Conf_02(:,:,2) = prob_final_01;
maxima_potencia = max(max(Matriz_Pot_Conf_02(:,:,1)));
for i = [0:mdc:maxima_potencia]
linha = linha';
coluna = coluna';
z=1;
aux = zeros(1,7);
if (length(linha) > 1)
for j = 1:Nmax
aux(z) = Matriz_Pot_Conf_02(linha(j),coluna(j),2) +
aux(z);
end
for j = 1:Nmax
Matriz_Pot_Conf_02(linha(j),coluna(j),2) = aux(z);
end
end
z = z+1;
end
Matriz_Pot_Conf_02;
for i = 1:Nmax
for j = 1:length(combinacao_final_01_02)
vetor_Matriz_Pot_02(t) = Matriz_Pot_Conf_02(i,j,1);
vetor_Matriz_Conf_02(t) = Matriz_Pot_Conf_02(i,j,2);
6
t = t + 1;
end
end
for i = 1:(length(vetor_Matriz_Pot_02))
for j = 1:(length(vetor_Matriz_Pot_02))
if(vetor_Matriz_Pot_02(j)<vetor_Matriz_Pot_02(i))
aux = vetor_Matriz_Pot_02(i);
aux1 = vetor_Matriz_Conf_02(i);
vetor_Matriz_Pot_02(i) = vetor_Matriz_Pot_02(j);
vetor_Matriz_Conf_02(i) = vetor_Matriz_Conf_02(j);
vetor_Matriz_Pot_02(j) = aux;
vetor_Matriz_Conf_02(j) = aux1;
end
end
end
Vetor_Pot_Conf_02(:,:,2) = vetor_Matriz_Conf_02;
combinacao_01_02_03 = Vetor_Pot_Conf_02;
B = A(diff([0 A])~=0);
C = combinacao_01_02_03(:,:,2);
D = C(diff([0 A])~=0);
combinacao_final_01_02_03(:,:,1) = B;
combinacao_final_01_02_03(:,:,2) = D;
combinacao_final_01_02_03;
% Combinação 03 - 04
linha = 1;
7
coluna = 1;
prob_final_02(linha,coluna)=combinacao_final_01_02_03(1,coluna,2)...
*probabilidade(linha,4);
pot_final_02(linha,coluna)=combinacao_final_01_02_03(1,coluna,1)...
+ potencia(linha,4);
coluna = coluna + 1;
end
coluna = 1;
linha = linha + 1;
end
Matriz_Pot_Conf_03(:,:,2) = prob_final_02;
maxima_potencia = max(max(Matriz_Pot_Conf_03(:,:,1)));
for i = [0:mdc:maxima_potencia]
linha = linha';
coluna = coluna';
z=1;
aux = zeros(1,7);
if (length(linha) > 1)
for j = 1:Nmax
aux(z) = Matriz_Pot_Conf_03(linha(j),coluna(j),2) +
aux(z);
end
for j = 1:Nmax
8
Matriz_Pot_Conf_03(linha(j),coluna(j),2) = aux(z);
end
end
z = z+1;
end
Matriz_Pot_Conf_03;
t = 1;
for i = 1:Nmax
for j = 1:length(combinacao_final_01_02_03)
vetor_Matriz_Pot_03(t) = Matriz_Pot_Conf_03(i,j,1);
vetor_Matriz_Conf_03(t) = Matriz_Pot_Conf_03(i,j,2);
t = t + 1;
end
end
for i = 1:(length(vetor_Matriz_Pot_03))
for j = 1:(length(vetor_Matriz_Pot_03))
if(vetor_Matriz_Pot_03(j)<vetor_Matriz_Pot_03(i))
aux = vetor_Matriz_Pot_03(i);
aux1 = vetor_Matriz_Conf_03(i);
vetor_Matriz_Pot_03(i) = vetor_Matriz_Pot_03(j);
vetor_Matriz_Conf_03(i) = vetor_Matriz_Conf_03(j);
vetor_Matriz_Pot_03(j) = aux;
vetor_Matriz_Conf_03(j) = aux1;
end
end
end
9
% Montagem da matriz com vetores:
Vetor_Pot_Conf_03(:,:,1) = vetor_Matriz_Pot_03;
Vetor_Pot_Conf_03(:,:,2) = vetor_Matriz_Conf_03;
combinacao_01_02_03_04 = Vetor_Pot_Conf_03;
B = A(diff([0 A])~=0);
C = combinacao_01_02_03_04(:,:,2);
D = C(diff([0 A])~=0);
combinacao_final_01_02_03_04(:,:,1) = B;
combinacao_final_01_02_03_04(:,:,2) = D;
combinacao_final_01_02_03_04;
% Combinação 04 - 05
linha = 1;
coluna = 1;
prob_final_03(linha,coluna)=...
combinacao_final_01_02_03_04(1,coluna,2)*probabilidade(linha,5);
pot_final_03(linha,coluna)=...
combinacao_final_01_02_03_04(1,coluna,1) +
potencia(linha,5);
coluna = coluna + 1;
end
coluna = 1;
linha = linha + 1;
end
10
Matriz_Pot_Conf_04(:,:,2) = prob_final_03;
maxima_potencia = max(max(Matriz_Pot_Conf_04(:,:,1)));
for i = [0:mdc:maxima_potencia]
linha = linha';
coluna = coluna';
z=1;
aux = zeros(1,7);
if (length(linha) > 1)
for j = 1:Nmax
aux(z) = Matriz_Pot_Conf_04(linha(j),coluna(j),2) +
aux(z);
end
for j = 1:Nmax
Matriz_Pot_Conf_04(linha(j),coluna(j),2) = aux(z);
end
end
z = z+1;
end
Matriz_Pot_Conf_04;
for i = 1:Nmax
for j = 1:length(combinacao_final_01_02_03_04)
vetor_Matriz_Pot_04(t) = Matriz_Pot_Conf_04(i,j,1);
vetor_Matriz_Conf_04(t) = Matriz_Pot_Conf_04(i,j,2);
t = t + 1;
end
11
end
for i = 1:(length(vetor_Matriz_Pot_04))
for j = 1:(length(vetor_Matriz_Pot_04))
if(vetor_Matriz_Pot_04(j)<vetor_Matriz_Pot_04(i))
aux = vetor_Matriz_Pot_04(i);
aux1 = vetor_Matriz_Conf_04(i);
vetor_Matriz_Pot_04(i) = vetor_Matriz_Pot_04(j);
vetor_Matriz_Conf_04(i) = vetor_Matriz_Conf_04(j);
vetor_Matriz_Pot_04(j) = aux;
vetor_Matriz_Conf_04(j) = aux1;
end
end
end
Vetor_Pot_Conf_04(:,:,2) = vetor_Matriz_Conf_04;
combinacao_01_02_03_04_05 = Vetor_Pot_Conf_04;
B = A(diff([0 A])~=0);
C = combinacao_01_02_03_04_05(:,:,2);
D = C(diff([0 A])~=0);
combinacao_final_01_02_03_04_05(:,:,1) = B;
combinacao_final_01_02_03_04_05(:,:,2) = D;
combinacao_final_01_02_03_04_05
% ----------------------------------------------------------------- %
% SISTEMA DE TRANSMISSÃO
12
k=1;
prob_T(k) = 0;
C = nchoosek(nT(z),(k-1));
%calcula a combinação da interação do instante
prob_T(k) = C*(Pt(z)^(nT(z)-(k-1))*((1-Pt(z))^(k-1)));
% está alocando cada linha de prob da tabela em um vetor[p1 p2
p3]
end
probabilidade_T(:,z) = prob_T;
%cada linha representa as probabilidades de cada grupo
end
pot_T(z,k+1) = ((T(z)*nT(z)))-(T(z)*k);
if(pot_T(z,k+1) < 0)
pot_T(z,k+1) = 0;
end
end
end
potencia_T = pot_T';
for p = 1:(NmaxT+1)
for q = 1:(NmaxT+1)
13
prob_final_T(p,q) = probabilidade_T(p,1) *
probabilidade_T(q,2);
end
end
Matriz_Pot_Conf_T = zeros(NmaxT+1);
Matriz_Pot_Conf_T(:,:,2) = prob_final_T;
for i = [0:mdc:maxima_potencia_T]
linha = linha';
coluna = coluna';
z=1;
aux = zeros(1,7);
if (length(linha) > 1)
for j = 1:NmaxT
aux_T(z) = Matriz_Pot_Conf_T(linha(j),coluna(j),2) +
aux_T(z);
end
for j = 1:NmaxT
Matriz_Pot_Conf_T(linha(j),coluna(j),2) = aux_T(z);
end
end
z = z+1;
end
14
% Matriz final da confiabilidade de 1 e 2:
Matriz_Pot_Conf_T(:,:,2);
vetor_Matriz_Pot_T = zeros(1,(2^(NmaxT+1)));
vetor_Matriz_Conf_T = zeros(1,(2^(NmaxT+1)));
for i = 1:NmaxT+1
for j = 1:NmaxT+1
vetor_Matriz_Pot_T(t) = Matriz_Pot_Conf_T(i,j,1);
vetor_Matriz_Conf_T(t) = Matriz_Pot_Conf_T(i,j,2);
t = t + 1;
end
end
for i = 1:(length(vetor_Matriz_Pot_T))
for j = 1:(length(vetor_Matriz_Pot_T))
if(vetor_Matriz_Pot_T(j)<vetor_Matriz_Pot_T(i))
aux = vetor_Matriz_Pot_T(i);
aux1 = vetor_Matriz_Conf_T(i);
vetor_Matriz_Pot_T(i) = vetor_Matriz_Pot_T(j);
vetor_Matriz_Conf_T(i) = vetor_Matriz_Conf_T(j);
vetor_Matriz_Pot_T(j) = aux;
vetor_Matriz_Conf_T(j) = aux1;
end
end
end
Vetor_Pot_Conf_T(:,:,2) = zeros(1,(2^(NmaxT+1)));
15
Vetor_Pot_Conf_T(:,:,1) = vetor_Matriz_Pot_T;
Vetor_Pot_Conf_T(:,:,2) = vetor_Matriz_Conf_T;
combinacao_T_01_02 = Vetor_Pot_Conf_T;
B = A(diff([0 A])~=0);
C = combinacao_T_01_02(:,:,2);
D = C(diff([0 A])~=0);
combinacao_final_T_01_02(:,:,1) = B;
combinacao_final_T_01_02(:,:,2) = D;
% ----------------------------------------------------------------- %
% TABELA GERAÇÃO - TRANSMISSÃO
for p = 1:(length(combinacao_final_01_02_03_04_05))
for q = 1:(length(combinacao_final_T_01_02))
pot_GT(p,q) = combinacao_final_01_02_03_04_05(1,p,1);
end
end
Matriz_Pot_Conf_GT(:,:,2) = prob_GT;
for i = [0:mdc:maxima_potencia]
linha = linha';
16
coluna = coluna';
z=1;
aux = zeros(1,7);
if (length(linha) > 1)
for j = 1:NmaxT
aux(z) = Matriz_Pot_Conf_GT(linha(j),coluna(j),2) +
aux(z);
end
for j = 1:NmaxT
Matriz_Pot_Conf_GT(linha(j),coluna(j),2) = aux(z);
end
end
z = z+1;
end
vetor_Matriz_Conf_GT = zeros(1,length(Matriz_Pot_Conf_GT));
for i = 1:length(Matriz_Pot_Conf_GT)
for j = 1:(2^(NmaxT+1))
vetor_Matriz_Pot_GT(t) = Matriz_Pot_Conf_GT(i,j,1);
vetor_Matriz_Conf_GT(t) = Matriz_Pot_Conf_GT(i,j,2);
t = t + 1;
end
end
for i = 1:(length(vetor_Matriz_Pot_GT))
17
for j = 1:(length(vetor_Matriz_Pot_GT))
if(vetor_Matriz_Pot_GT(j)<vetor_Matriz_Pot_GT(i))
aux = vetor_Matriz_Pot_GT(i);
aux1 = vetor_Matriz_Conf_GT(i);
vetor_Matriz_Pot_GT(i) = vetor_Matriz_Pot_GT(j);
vetor_Matriz_Conf_GT(i) = vetor_Matriz_Conf_GT(j);
vetor_Matriz_Pot_GT(j) = aux;
vetor_Matriz_Conf_GT(j) = aux1;
end
end
end
Vetor_Pot_Conf_GT(:,:,2) = vetor_Matriz_Conf_GT;
combinacao_GT = zeros(length(Vetor_Pot_Conf_GT));
combinacao_GT = Vetor_Pot_Conf_GT;
% Tabela geral
for i = 1:(length(Vetor_Pot_Conf_GT))
condicao(i) = i;
end
condicao = condicao';
potencia_gerada = combinacao_GT(:,:,1)';
potencia_fora = wrev(combinacao_GT(:,:,1))';
linhas_funcionando = [1,1,0,2,1,1,0,2,1,1,0,2,1,1,0,2,1,...
1,0,2,1,1,0,2,1,1,0,2,1,1,0,2,1,1,0,2,1,1,0,2,1,1,0,2,...
1,1,0,2,1,1,0,2,1,1,0,2,1,1,0,2,1,1,0,2,1,1,0,2]';
linhas_fora = [1,1,2,0,1,1,2,0,1,1,2,0,1,1,2,0,1,1,2,0,1,...
1,2,0,1,1,2,0,1,1,2,0,1,1,2,0,1,1,2,0,1,1,2,0,1,1,2,...
0,1,1,2,0,1,1,2,0,1,1,2,0,1,1,2,0,1,1,2,0]';
probabilidade = combinacao_GT(:,:,2)';
18
capacidade_disponivel = potencia_gerada;
for j = 1:(length(Vetor_Pot_Conf_GT))
if(linhas_fora(j,1) == 2)
capacidade_disponivel(j,1) = 0;
end
end
for i = 1:length(capacidade_disponivel)
if capacidade_disponivel(i,1) > 97
else tk_horas(i,1) = 0;
end
end
LOLE = tk_horas.*probabilidade;
Table_final = table(condicao,potencia_gerada,potencia_fora,...
linhas_funcionando,linhas_fora,capacidade_disponivel,...
probabilidade,tk_horas,LOLE)
resultado = 1/soma;
% ----------------------------------------------------------------- %
% Item (d)
anos = 20;
potencia_novos_geradores = [ 30 30 40 40 50 50 60 60 70 70];
x = 197;
novos_geradores = 197;
19
taxa = 1.05;
j = 1;
i = 1;
x = x*taxa;
if ( x > novos_geradores )
j = j + 1;
i = i + 1;
else i = i + 1;
end
end
disp(' ')
novos_geradores
combinacao_final_01_02_03_04_05(:,:,1) =
Columns 1 through 13
Columns 14 through 17
40 30 20 0
combinacao_final_01_02_03_04_05(:,:,2) =
Columns 1 through 3
20
Columns 4 through 6
Columns 7 through 9
Columns 10 through 12
Columns 13 through 15
Columns 16 through 17
0.000000002352000 0.000000000024000
combinacao_final_T_01_02(:,:,1) =
combinacao_final_T_01_02(:,:,2) =
Columns 1 through 3
Column 4
0.000012422084520
Table_final =
1 180 0 1
1 180 0.00326251838472142
37.8947368421053 0.123632275631549
2 180 0 1
1 180 0.00305861367926692
37.8947368421053 0.115905360477483
21
3 180 0 0
2 0 1.11730105212211e-05
0 0
4 180 0 2
0 180 0.89311500614949
37.8947368421053 33.8443581277702
5 160 20 1
1 160 0.000133164015702915
101.052631578947 0.0134565742183999
6 160 20 1
1 160 0.000124841374663956
101.052631578947 0.0126155494397261
7 160 20 0
2 0 4.56041245764129e-07
0 0
8 160 20 2
0 160 0.0364536737203874
101.052631578947 3.68373966016546
9 150 30 1
1 150 0.000116265028938586
132.631578947368 0.0154204143644861
10 150 30 1
1 150 0.000108998560620307
132.631578947368 0.0144566511980617
11 150 30 0
2 0 3.98167991225534e-07
0 0
12 150 30 2
0 150 0.0318275729944499
132.631578947368 4.22134126031651
13 140 40 1
1 140 0.000100895555497024
164.210526315789 0.0165681122710903
14 140 40 1
1 140 9.45896665795444e-05
164.210526315789 0.015532618933062
15 140 40 0
2 0 3.45532797115245e-07
0 0
16 140 40 2
0 140 0.0276201768211263
164.210526315789 4.53552377273232
17 130 50 1
1 130 4.74551138524841e-06
195.789473684211 0.000929121176480215
18 130 50 1
1 130 4.44892084164518e-06
195.789473684211 0.000871051870048424
19 130 50 0
2 0 1.62517547438994e-08
0 0
20 130 50 2
0 130 0.00129908461201836
195.789473684211 0.254347092458332
22
21 120 60 1
1 120 5.07666324709486e-06
227.368421052632 0.00115427290670788
22 120 60 1
1 120 4.75937598553083e-06
227.368421052632 0.00108213180302596
23 120 60 0
2 0 1.73858367015243e-08
0 0
24 120 60 2
0 120 0.00138973749493068
227.368421052632 0.315982419900027
25 110 70 1
1 110 3.59557350989085e-06
258.947368421053 0.000931064298350684
26 110 70 1
1 110 3.37085313408923e-06
258.947368421053 0.000872873548406263
27 110 70 0
2 0 1.23136105052983e-08
0 0
28 110 70 2
0 110 0.000984288907745516
258.947368421053 0.254879022426734
29 100 80 1
1 100 7.55387175329375e-07
290.526315789474 0.00021945985304306
30 100 80 1
1 100 7.08176100531769e-07
290.526315789474 0.000205743793417651
31 100 80 0
2 0 2.58694292638332e-09
0 0
32 100 80 2
0 100 0.000206787377781213
290.526315789474 0.0600771750185418
33 90 90 1
1 90 1.44781629564371e-07
0 0
34 90 90 1
1 90 1.3573289725077e-07
0 0
35 90 90 0
2 0 4.95827602988478e-10
0 0
36 90 90 2
0 90 3.9633997645582e-05
0 0
37 80 100 1
1 80 5.88075838422457e-08
0 0
38 80 100 1
1 80 5.51321584046453e-08
0 0
23
39 80 100 0
2 0 2.01395877514147e-10
0 0
40 80 100 2
0 80 1.60985868618756e-05
0 0
41 70 110 1
1 70 2.54445927854097e-08
0 0
42 70 110 1
1 70 2.38543267438095e-08
0 0
43 70 110 0
2 0 8.71390347502503e-11
0 0
44 70 110 2
0 70 6.96546194143605e-06
0 0
45 60 120 1
1 60 1.54274108341199e-09
0 0
46 60 120 1
1 60 1.44632103941198e-09
0 0
47 60 120 0
2 0 5.2833609880038e-12
0 0
48 60 120 2
0 60 4.2232565451619e-07
0 0
49 50 130 1
1 50 9.7825425381332e-10
0 0
50 50 130 1
1 50 9.17114170613313e-10
0 0
51 50 130 0
2 0 3.35018650667891e-12
0 0
52 50 130 2
0 50 2.67797281389068e-07
0 0
53 40 140 1
1 40 2.2190051847741e-10
0 0
54 40 140 1
1 40 2.08031919277409e-10
0 0
55 40 140 0
2 0 7.59933442589393e-13
0 0
56 40 140 2
0 40 6.07453076288028e-08
0 0
24
57 30 150 1
1 30 9.98218626340123e-12
0 0
58 30 150 1
1 30 9.35830786340117e-12
0 0
59 30 150 0
2 0 3.41855765987644e-14
0 0
60 30 150 2
0 30 2.73262532029661e-09
0 0
61 20 160 1
1 20 8.53128709720919e-12
0 0
62 20 160 1
1 20 7.99808869720914e-12
0 0
63 20 160 0
2 0 2.92167427908045e-14
0 0
64 20 160 2
0 20 2.3354414074628e-09
0 0
65 0 180 1
1 0 2.38310347700286e-11
0 0
66 0 180 1
1 0 8.70539499715225e-14
0 0
67 0 180 0
2 0 8.16131499715219e-14
0 0
68 0 180 2
0 0 2.98130028477597e-16
0 0
novos_geradores =
557
25