minimum value is selected always from last iteration
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
summyia qamar
el 16 de Dic. de 2016
Comentada: summyia qamar
el 19 de Dic. de 2016
part_machine=[1 0 0 1 0 1 1;
0 1 1 1 0 0 1;
1 0 0 1 1 0 0;
1 0 0 0 1 0 1;
1 1 0 0 0 1 0;
0 1 0 0 0 1 1];
demand=[600;550;620;500;590;600];
numIterations=3;
for k=1:numIterations
rand_cell_assigntomachines=randi([0,1],7,3);
Part_cell=part_machine*rand_cell_assigntomachines;
Part_cell(Part_cell>=1)=1;
no_of_movements=sum(Part_cell,2)-1;
movement_cost=sum(bsxfun(@times,no_of_movements,demand))
end
minval=min(movement_cost)
the result is
movement_cost =
5110
movement_cost =
6920
movement_cost =
6300
minval =
6300
but in 3 iterations, 6300 is not minimum value.. I checked it and the value which is always picked as min is from the last iteration.. why is this so?
0 comentarios
Respuesta aceptada
Walter Roberson
el 16 de Dic. de 2016
Assign to movement_cost(k) instead of overwriting all of movement_cost
3 comentarios
Walter Roberson
el 16 de Dic. de 2016
Inside the loop,
movement_cost(k)=sum(bsxfun(@times,no_of_movements,demand));
After the loop, stay with your existing
minval=min(movement_cost)
Más respuestas (0)
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!