How to track the lists generated in each for loop?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Aswin Sandirakumaran
el 28 de Jun. de 2018
Editada: Aswin Sandirakumaran
el 28 de Jun. de 2018
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 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!