How to track the lists generated in each for loop?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!