0

via Google Distance Matrix API I am able to caclulate all driving times in seconds between addresses of each of my personnel and each of my customers (fake data in this example). I put this into a pivoted dataframe after calculating it. So now I have on the x-axis all the customers, on the y-axis all my personnel while the driving time in seconds are the values in the cells (The data is of course also available unpivoted with customers and personnel in a column each and the driving time in another column).

Now I want to calculate the optimal allocation of my personnel to the customers, thus minimizing the seconds of driving time over all. Important requirement: Certain customers need 2, other customers need 3 personnel assigned. 1 Personnel can only ever be allocated to 1 customer tho (that is referenced in the column "Versorgung".)

I am sure there is a mathematic solution to it but I just can't figure out how to solve it. Thank you in advance.

Dataframe (unpivoted)
enter image description here

Pivoted Dataframe with seconds of driving time as values
enter image description here

Pawara Siriwardhane
  • 1,873
  • 10
  • 26
  • 38
Sven
  • 1
  • The best thing to do (IMHO) is to first write down a mathematical model for the problem. That is more precise than a piece of text. After that, the implementation and choosing an appropriate solver is not very difficult. At first sight. this looks to me like an assignment problem. – Erwin Kalvelagen Nov 01 '21 at 19:15
  • Thank you @ErwinKalvelagen! I wrote it down as a mathematical problem and solved it with PULP in Python. – Sven Nov 09 '21 at 14:20

0 Answers0