title: Algorithm for stacked orders in food delivery (Pick up and deliveries)
body: <p>I am trying to implement stacking orders</p>
  <p>While the most optimal solution would be to consider picking up orders from nearby restaurants that have similar food prep time AND nearby delivery locations.</p>
  <p>I'd like to start off with something slightly easier - that is stacking orders only from the SAME restaurants that have similar food prep time to multiple deliver points.
  (Deliveroo example: <a href="https://riders.deliveroo.com.sg/en/tech-round-up-stacking-orders" rel="nofollow noreferrer">https://riders.deliveroo.com.sg/en/tech-round-up-stacking-orders</a>)</p>
  <p>The scale is about 200k orders hourly and 5000 riders, 5000 restaurants. Run time is important here ~ ideally less than 1 minute (on demand service)</p>
  <p>What I have in mind is this:</p>
  <p>(1) Collect orders per few minutes interval and sort all orders by their prep time O(nlogn)</p>
  <p>(2) group orders by restaurant O(n)</p>
  <p>(3) Starting from the order that has the smallest remaining prep time, look for any orders in the same restaurant within the time window (let's say 3-5 mins), if exists group them as a stack. O(1).</p>
  <ul>
  <li>locations of delivery points are not considered here to reduce computations - most delivery points are within 3km in a given zone.</li>
  <li>not so interested in global optima for computational time. Picking the order that has the smallest remaining prep time is to avoid considering all combinations for rider - orders permutation matching.</li>
  </ul>
  <p>(4) Run simulated annealing for semi-optimal TSP for vehicle routing. (ex. Pickup order A, B, C from the same restaurants -&gt; deliver C to A to B)</p>
  <p>I understand for multiple PICKUP and Dropoff the problem would translate into VRPTW - a hard problem to solve in real-time.</p>
  <p>A somewhat easier problem - single Pickup and multiple Drop off would there be any better way than what I have in mind right now?</p>
  <p>Many thanks in advance.</p>