필터 지우기
필터 지우기

How to track the lists generated in each for loop?

조회 수: 1 (최근 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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by