0

Currently, if a customer orders 2 products, suppose, 1 product is present in Store 1 which is 20 miles away from customer location and both the products are present in Store 2 which is 30miles away from customer's location,1 product available at Store 1 is being picked up, and then second product is picked up from Store 2.

This is because I am filtering and assigning the nearest store to each order item in a particular Order.

What I want to do instead is, even if Store 2 is 30miles away(which is farther from Store 1) from the customer location, it contains both the order items. So, both the items should be picked up from Store 2 and delivered to the respective customer.

What according to you is the right approach to focus on picking up maximum/all order items of a single/multiple orders from single store?

  • Without code and samples of your data we can't be too specific, but generally speaking it sounds like what you want is to iterate all the stores from nearest to farest and stop at the first store which has all the parts of the order. – Aryerez Oct 29 '19 at 12:32
  • I have just done this: df1.loc[df1.groupby(["OrderLineItemId"])["RouteDistance"].idxmin()], where df1 is the df that contains all the stores that contains a particular item(order line item) and then whichever store is the nearest, I am assigning that store as the pickup location. – Gayatri Padhi Oct 29 '19 at 13:27
  • But, as mentioned in the explanation above, taking the nearest store is my second priority. Choosing the store which has all/almost all the products in an order and is near, is my priority. – Gayatri Padhi Oct 29 '19 at 13:47

1 Answers1

1

I may not be able to give you code but algorithm should be that.

  1. Filter stores which has at least one item of what u need.
  2. Filter store which has all or max items.
  3. Short those store in terms of distance, pick the nearest.
ashok gupta
  • 162
  • 3