How to create a distance matrix in matlab

13 vues (au cours des 30 derniers jours)
Lisa de Boer
Lisa de Boer le 13 Déc 2018
Commenté : Image Analyst le 14 Déc 2018
Hello,
I want to determine what the shortest route is to pick multiple items in a warehouse. However, I do not want to use a standard distance matrix, but I want to compute the distances between two items myself. Does anyone know how to create an distance matrix with the shortest distances between items in the same picking order?

Réponses (2)

Bob Thompson
Bob Thompson le 14 Déc 2018
What do you mean by 'picking order'?
I have no experience actually doing this, but my first thought would be to create a matrix of ordered pairs which represents all pickup locations within the warehouse. For making the distance matrix itself you could then use a for loop to loop through all locations and identify the distance required to reach any other point.
A sample code of what I'm thinking is below. I literally threw it together right here, so no testing or thurough thinking has gone into it.
pickups = [7,1;14,1;4,2;9,3;13,7;4,8;7,8;5,9;11,9;8,11;5,12;13,12];
np = length(pickups);
distancemat = zeros(np);
for i = 1:np;
for j = 1:np;
if pickup(i,2)==pickup(j,2); % Same columns READ NOTE AT END
distancemat(i,j) = abs(pickup(i,1)-pickup(j,1));
else % Different columns
% Account for rows
if pickup(i,1)<=15 & pickup(j,1)<=15
distancemat(i,j) = min([abs(pickup(i,1)-pickup(j,1)),30-(pickup(i,1)+pickup(j,1))]);
elseif pickup(i,1)>15 & pickup(j,1)>15
distancemat(i,j) = min([30-abs(pickup(i,1)-pickup(j,1)),60-(pickup(i,1)+pickup(j,1))]);
else
distancemat(i,j) = abs(pickup(i,1)-pickup(j,1));
end % Row check
% Account for columns
distancemat(i,j) = distancemat(i,j) + 2*abs(pickup(i,2)-pickup(j,2));
end % Column check
end % Columns loop
end % Rows loop
Note: As I have this currently written, it does not account for two columns being accessible at once. I do not have a good solution for this off the top of my head, but it should at least get you started.
  2 commentaires
Lisa de Boer
Lisa de Boer le 14 Déc 2018
Thank you bob for your help. It helps me a lot.
Image Analyst
Image Analyst le 14 Déc 2018
It's sort of like the traveling salesman problem, but not quite - it has a twist. Once you go down an aisle, you must stay in that aisle.
I don't see how the circles in diagram (b) correspond to the black squares in column (a), so I can't refer to them.
But, since you're committed to going down a aisle, if you were in aisle 4 and just got the black item in the third row, since you have to stay in that aisle, you can't then next grab the item in aisle 5, 4th row down, even though just looking at (x,y) coordinates, the one in aisle 5 is closest.
Another twist is that you can backup. For example you might head down a row but if there is only one item to be picked up in it, and it's close to the beginning of the aisle, it might be best to go in and grab it, then back out the same way you came in if there are no other items deeper into that aisle.

Connectez-vous pour commenter.


Image Analyst
Image Analyst le 14 Déc 2018

Community Treasure Hunt

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

Start Hunting!

Translated by