i want to assign number of tasks to fog nodes randomly son in the matrix i will have different solution and i got the same solution repeated
    6 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    maria alseid
 el 14 de Ag. de 2021
  
    
    
    
    
    Comentada: maria alseid
 el 20 de Ag. de 2021
            lb=250;
ub= 1000;
dim = 5;
pop=5;
offloading =  lb + (ub - lb) .* rand(1,dim); 
         %Initialization
    fognodesnumber = 3;     
for i = 1 : pop  %pop=N, population size
 for task = 1 : dim 
     indices = randperm(length(offloading)); 
         indices2 = randperm(fognodesnumber); 
  for FN=1:fognodesnumber
    x(task,indices2(FN))=offloading(indices(task));
    % Evaluate the fitness of the new solution
    fit(task,FN)=fobj(x(task,indices2(FN)));
  end
 end
end
so the reult i got for x is 
x =
  357.1360  357.1360  357.1360
  520.0463  520.0463  520.0463
  370.7144  370.7144  370.7144
  370.7144  370.7144  370.7144
  663.3892  663.3892  663.3892
 but i need each column the numbers to be distributed differently
0 comentarios
Respuesta aceptada
  Shravan Kumar Vankaramoni
    
 el 17 de Ag. de 2021
        Hi,
for FN=1:fognodesnumber
    x(task,indices2(FN))=offloading(indices(task));
end
In the above loop, task( row number ) is a constant value. Basically you are storing same value in the entire row. To get different values in the columns of the same row, you can try the below code. It is randomizing the value to be stored.
for FN=1:fognodesnumber
    x(task,indices2(FN))=offloading(indices(randi([1,dim])));
end
Más respuestas (0)
Ver también
Categorías
				Más información sobre Get Started with MATLAB 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!

