How to track the lists generated in each for loop?

23 ビュー (過去 30 日間)
Aswin Sandirakumaran
Aswin Sandirakumaran 2018 年 6 月 28 日
編集済み: Aswin Sandirakumaran 2018 年 6 月 28 日
Gv = graph({'s1' 's_1' 's2' 's_2' },{'s2' 's_2','s3' 's_3'});
Gv.Nodes.Memory = [8,8,7,7,8,7]';
Gv.Nodes.Service = {'s1','s2','s_1','s_2','s3','s_3'}';
Application = Gv.Nodes;
Gp = graph({'n1' 'n1' 'n2' 'n2' 'n3' 'n4'},{'n2' 'n4' 'n3' 'n4' 'n5' 'n5'});
Gp.Nodes.Memory = [15,15,15,15,15]';
Gvsub = graph();
for i = 1:numnodes(Gv)
for j = 1:numnodes(Gp)
List = find(Gv.Nodes.Memory(i) <= Gp.Nodes.Memory); % WE MUST ALSO ADD AVAILABILITY
end
disp(List);
first_element = List(1);
disp(Gv.Nodes.Service(i)); %SELECTED SERVICE FOR ALLOCATION
if isempty(Gvsub.Nodes)
Gp.Nodes.Memory(first_element) = Gp.Nodes.Memory(first_element) - Gv.Nodes.Memory(i);
Gp.Nodes
else
Gp.Nodes.Memory(first_element) = Gp.Nodes.Memory(first_element) - Gv.Nodes.Memory(i);
Gp.Nodes
end
Application(1,:) = []; % REMOVING THE USED ROW AFTER BEING USED
end
In the OUTPUT we can see that s1 and s_1 generates the same list 1,2,3,4,5 and both of them gets allocated in 1.
How to check say during allocation of s_1 that 1 was already used by any other service( in this case s1 was already allocated in 1) or not?

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by