|
-
June 1st, 2013, 05:20 AM
#2
Re: Help with algorithm - Delivery problem with LIFO loading
 Originally Posted by logicsheep
For example, you could say that a smart move is to first completely satisfy a specific location: that is, deliver all its in-bound items and load all
out-bound items, so you don't have to visit this location again. But, I can't be sure that this will always be the least costly decision.
Or you could make two roundtrips to all locations. During the first roundtrip you push all items on the LIFO as you find them. Afterwards you pop all items and immediately push them back on again in visiting order so the appropriate items become available for delivery at each location during the second roundtrip.
The roundtrips are linear in the number of locations and the LIFO handling including the re-ordering is linear in the number of items so all in all this is an O(N) algorithm. I cannot say if it gives the lowest cost but at least it's an upper bound (if the re-ordering which requires an additional data structure is legal),
Cost = 2 roundtrips * N locations * 3 points + (4 push/pop + 1 ordering) * M items * 1 point = 6*N + 5*M;
If you want help to improve on this you need to be more specific about the nature of the items and the delivety list. At least I don't fully get it. I guess initially there are items at each location. Is each item labelled with the target location as if it were a post parcel?
Last edited by nuzzle; June 1st, 2013 at 06:14 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|