-
Notifications
You must be signed in to change notification settings - Fork 0
/
Slossmul.m
63 lines (55 loc) · 2.2 KB
/
Slossmul.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function [slosstong, powerdataout] = Slossmul(dscat, nguon, Udm, linedatamultiloop, linedata, powerdata)
slosstong = 0;
%Input dscat: danh sach cac nhanh se cat
% Udm la dien ap dinh muc
% linedata
% Powerdata
%Output nhanhcat:danhsach cac nhanh cat toi uu
% sloss ton that khi cat cac nhanh
banSauCuaLinedataMultiloop = linedatamultiloop;
%xac dinh nut mot
for i = 1:length(dscat)
vitriLinedata = dscat(i) == banSauCuaLinedataMultiloop(:, 1);
banSauCuaLinedataMultiloop(vitriLinedata, :) = [];
end
A = 1;
while A == 1
nutCuoiTrenNhanhHinhTia = timDanhSachNutCoMotLienKetVoiNutKhac(banSauCuaLinedataMultiloop);
vitriNut = nutCuoiTrenNhanhHinhTia == 1;
if sum(vitriNut) ~= 0
nutCuoiTrenNhanhHinhTia(vitriNut) = [];
end
vitriNut = nutCuoiTrenNhanhHinhTia == nguon;
if sum(vitriNut) ~= 0
nutCuoiTrenNhanhHinhTia(vitriNut) = [];
end
%Tinh cong suat
if numel(nutCuoiTrenNhanhHinhTia) > 0
%Tim duong di
for i = 1:length(nutCuoiTrenNhanhHinhTia)
nutrun = timDuongDiNganNhatGiuaHaiNut(banSauCuaLinedataMultiloop, nguon, nutCuoiTrenNhanhHinhTia(i));
danhSachNutTrenCungMotNhanh = timDanhSachNutCungMotNhanh(banSauCuaLinedataMultiloop, nutCuoiTrenNhanhHinhTia(i));
nutCuoiCungTrongDanhSach = danhSachNutTrenCungMotNhanh(numel(danhSachNutTrenCungMotNhanh));
m = nutCuoiCungTrongDanhSach == nutrun;
if sum(m) ~= 0
vitriNut = find(nutCuoiCungTrongDanhSach == nutrun);
nutrun(vitriNut + 1:length(nutrun)) = [];
end
%tinh cong suat
for vitriNut = 1:length(nutrun)-1
nutA = nutrun(vitriNut);
nutB = nutrun(vitriNut + 1);
[sloss1, powerdata] = Slossab(nutA, nutB, Udm, powerdata, linedata);
slosstong = slosstong + sloss1;
banSauCuaLinedataMultiloop = xoaCacLinedataChuaHaiNutLienKe(nutA, nutB, banSauCuaLinedataMultiloop);
end
end
else
A = 0;
end
if isempty(banSauCuaLinedataMultiloop)
break
end
end
powerdataout = powerdata;
end