I have been struggling with this problem from quite a while. Here's how it goes:
- There are N assembly lines having capacity C1, C2, ... CN.
- There are M products P1, P2, ... PM.
- Each product P is a set of Items {I1, I2, I3, ... Ik} which are finite.
- Products can share items.
We need to assign the products on the assembly lines such that following constraints are met:
- Every product is assigned to exactly one of the lines.
- Every line is able to accommodate all products assigned so that number of items on it never exceed it's capacity.
Some approaches I tried but didn't reach a satisfactory solution:
- Started with pair of products with high Jaccard similarity assigned to each line and continued assigning more products on line.
- Tried using LSH min hash to generate buckets of products with high similarity.
Both the approaches didn't generate a feasible solution. Meaning there were some products left at the end which would not fit on the assembly lines.
I'm only looking for a feasible solution (sub-optimal is fine) in this case and not the most optimised one.
Hoping someone give me more insights into solving this problem.
This problem can be formulated as an integer, linear program, and then solved with any commercial or public-domain ILP solver.
Givens
We are given the following:
The formulation of the ILP model is as follows.
Variables
We define the following variables.
xpa equals 1 if product p is assigned to assembly line a, else 0, 1 ≤ p ≤ P, 1 ≤ a ≤ A
yai equals 1 if item i is processed on assembly line a, else 0, 1 ≤ a ≤ A, 1 ≤ i ≤ I
Constraints
The constraints are as follows:
Each product must be produced
∑axpa = 1, 1 ≤ p ≤ P
Prevent production of a product on a given assembly line if it contains an item that is not permitted on that line
xpa ≤ yai for each i in Si, 1 ≤ a ≤ A, 1 ≤ i ≤ I
The capacity of each assembly line cannot be exceeded
∑iyai ≤ Ca, for a = 1,...,A
Objective function
There is no objective function to be maximized or minimized as only a feasible solution is required. If the solver does require an objective function, something artificial could be used, such as
min 0x11
Optimizing
Suppose now we wish to maximize or minimize some function, not just identify a feasible solution.
As an example, suppose it costs ca to operate assembly line a and we now want to determine which assembly lines to open to minimize cost. We could do that as follows.
We define the following additional variables.
za equals 1 if assembly line is to operate, else 0, 1 ≤ a ≤ A
The revised formulation follows.
min ∑acaza
subject to:
∑axpa = 1, 1 ≤ p ≤ P
xpa ≤ yai for each i in Si, 1 ≤ a ≤ A, 1 ≤ i ≤ I
∑iyai - Caza ≤ 0, for a = 1,...,A