# Machine Allocation & optimal Utilization using python

Problem statement: Meet the demand which can be met across 2 facilities each having multiple machines where several components are made. The objective is to find the optimal solution to meet the demand with the lowest utilization of machines.

• Demand is total and can be met by loading on either facility.
• Facility A has to be loaded and only when it is completely utilized, then we load facility B.
• Each machine can make one or more components on it (until its available hours are exhausted).
• Not all machines make all components.
• Each machine has a "run-time" which is the time to produce 1 unit of a component. The lower run-time the better.
• Different components take different time to produce on a machine. We choose the machine which takes the least run-time to produce.

• Each machine has a total "Available-hours" for an entire month which is total runtime available for that machine.

• This "available-hours" constraint is hard.

• Demand for one component cannot be split across different machines.

Given this information, we need to:

1. Pick the machine (which can make a component) with the lowest run time first.
2. See if demand is met by choosing that machine to produce that component or not. (check the available hours of a machine, subtract available hours with the total time to meet demand. the remaining time is now the updated available hours for that machine). the total time to meet demand is simply run-time $$\times$$ demand for that component.
3. Repeat 1 & 2 for all components.
4. If a demand is so high that a machine gets completely utilized, then choose the next best machine where a component can be made(machine with 2nd lowest run-time).
5. All demand should be met(not exceeded) for all components.
6. Try to see that machines should be optimally utilized overall.
7. Evaluation metric to compare results between 2 runs are:
• % demand met
• % utilization overall variance between utilization across machines

I have tried using Google's OR-TOOLS package but the solution never converges. Maybe the model is not right (based on this answer on Stack Overflow.) For machines where a component cannot be made, I have used a really large number (10000000) as part of cost.

Using any other package/approach is fine as long as the solution can scale for large data-sets.

I realize this is a special case of bin-packing problem where the bin sizes vary and also not all bins allow all items to be kept. Any help is appreciated.

• I do not understand why you say it never converges. The code you sent me proves optimality in less than 1s. – Laurent Perron Sep 14 '19 at 17:00
• maybe the way i have modeled is incorrect here (as I'm totally new to or-tools at the moment), when i try to run the model - it allocated everything to a particular machine (which shouldnt be possible as it has a capacity). and irrespective of that, the solution tells that all parts should be made on machine-18 only which definitely is incorrect (as I'm sure that many components cant be made on machine18 at all). – Shankar Pandey Sep 14 '19 at 20:06
• I have submitted a solution of the initial model here: stackoverflow.com/questions/57929840/…. The problem is trivial and solved in 80 ms. – Laurent Perron Sep 15 '19 at 6:39