title: Delivery optimization with limits
body: <p>I have the following problem to solve:</p>
  
  <ol>
  <li>There are N cities. Each of them has some count of test samples which are needed to be processed in laboratories (labs).</li>
  <li>There are M labs. They process samples, but each has limits.</li>
  <li>We need to process all the samples.</li>
  <li>Optimization by the distance should be used - try to process city's samples in the nearest lab.</li>
  </ol>
  
  <p>If there will be no limits, it's easy - for each city we determine the nearest lab and use for processing samples. But if there are capacity limits, there is a possibility of overflow in certain lab, so we need to find another lab to process samples of this city (of course, this lab will be a little bit farther).</p>
  
  <p>So, <strong>the question is</strong>: how to distribute samples flows in optimal way by distance and without overflows?</p>
  
  <p>I believe this is some well-known algorithm. Could you, please, tell me at least how it's called?</p>
  
  <p>Thanks!</p>