Problem on a bipartite graph of materials and storage facilities

104 Views Asked by At

There is a mining site that mines different kinds of materials. Then there are storage facilities that can store those materials in warehouses (all warehouses at a given storage facility are identical but two warehouses at two different facilities might be different). If we choose to store material $m$ in storage facility $s$, the warehouses at that storage facility will be $p_{s,m} \in (0,1]$ percent filled. Certain materials can't even be stored in certain storage facilities (the warehouses there are incompatible).

We want to cover all the materials and also all the storage facilities (none of them should receive no material so people there aren't unemployed and all materials should be stored somewhere). How can we do this with a minimum number of warehouses built?

Given the list of materials, list of storage facilities, edges between materials and storage facilities (presence of edge means the storage facility can store that material) and $p_{s,m}$ (proportion of storage facility $s$ that will be filled with material $m$) associated with each of those edges, come up with an algorithm that gives us the minimum number of warehouses to be built and runs in time polynomial in the number of materials, storage facilities and edge connections.


An example

As an example, consider that there are three storage facilities, $s_1, s_2, s_3$ and two materials mined, $m_1, m_2$. The relationship between them is shown in the figure below. $m_1$ can be stored in $s_1$ but will take up 50% of the capacity of a warehouse built there. In this case, we'll need to build three warehouses; one at each of the storage facilities to cover all storage facilities and all materials (shown by the pink lines). We build one warehouse at $s_1$ and store $m_1$ there which takes up 50% of the capacity of that warehouse. Now, we have to cover $s_2$, so we build a warehouse there as well. Since $m_1$ is the only material that can be stored there, we do that and this takes up 90% of the capacity of this second warehouse. Finally, we build a warehouse at $s_3$ and store $m_2$ there which takes up 60% of the storage capacity. At this point, we've covered all three warehouses and both materials, so we're done. And we can be sure the three warehouses we built is minimal since we had to cover all three storage facilities (and all 2 materials). So 3 was always the smallest we could have gotten away with.

If at any site, adding a new material to a warehouse would have exceeded 100% of the storage capacity, we would have had to build another warehouse (which didn't happen in this case). For example, storing $m_1$ at $s_3$ would have been a bad move since $m_2$ can only be stored at $s_3$ and one warehouse there there isn't big enough to store both $m_1$ and $m_2$ (.6+.5>1). So, we'd have to build 2 warehouses at $s_3$ and then one each at $s_1$ and $s_2$ to cover them as well for a total of 4 warehouses which we know is sub-optimal.

enter image description here


My attempt

We can think of the storage facilities and materials as a bi-partite graph. Each edge of the graph has a weight given by $p_{s,m}$. We can do a min-weight edge cover and get the edges that cover all materials and storage facilities in a way that the sum of proportions is minimized. Then, we can loop through each storage facility, get the materials to be stored there (the edges connecting it to each of the materials after doing the edge cover) and build the minimum number of warehouses to house all materials (for example, if $\sum_{m\in S_m} p_{s,m}=1.3$ where $S_m$ is the set of materials connected to storage facility $s$ in the min weighted edge cover we ran; then we'll need to build two warehouses there since one isn't enough).

However, this is just a heuristic and not an optimal algorithm.