How do you go about solving the following problem that tries to match the greatest number of clients with servers with constraints? I'm trying to identify an algorithm or simulation that could help me solve this problem as optimally as possible.

Assume you are given a 2d map of servers and clients randomly scattered. Each server can handle a certain radius of clients but never two clients that are near each other (this is the constraint). While it makes sense for a server to handle all the clients near it, some clients may need to be handled by another server nearby. Picking which of those clients should be handled by another server (potentially farther but still in reach) such that the maximum number of clients can be handled is the objective.

Not all clients necessarily can be handled, but the problem should be able to match the most number of clients with servers possible, and the constraint must be upheld.

  • $\begingroup$ I think linear programming should do pretty well in this case: you can introduce variable $x_{ps}$ for each person $p$ and reachable server $s$. You want to maximize $\sum_{ps}x_{ps}$. The constraints are $x_{ps} \in [0,1]$ and $x_{p_1s}+x_{p_1s} \le 1$ if $p_1$ and $p_2$ are close. This is not exact reformulation (you need $x_{ps} \in \{0,1\}$), but I expect solutions to be close to integral (or can be converted to integral). If you have more information about distribution of people (e.g. how likely two persons to be nearby and whether they form clusters), simpler solutions are possible. $\endgroup$ – Dmitry Feb 25 at 6:30
  • $\begingroup$ First, formalise and name near each other - $l$ - and in reach - $u$. Go for low-hanging fruit first: weed out clients too far from any server - how about keeping for every client the number of servers in reach? (Weeding out server is more difficult - jot down why/how.) What are difficult cases, what about a line of client positions at a distance of $\frac{2l}{5}$? $\endgroup$ – greybeard Feb 25 at 6:35
  • $\begingroup$ I'm confused by "never two clients that are near each other" and "makes sense to handle all the clients near it". If a server handles all clients near it, then presumably it will be handling clients that are near each other. So I'm lost. $\endgroup$ – D.W. Feb 25 at 7:18

The problem is NP-hard. Consider the following special case: there is only one server, and its radius is infinite (or very large). Then your problem becomes the problem of finding an independent set in a planar graph. That problem is known to be NP-hard. Since a special case of your problem is NP-hard, then your problem must be at least as hard in the general case.

There are many ways to deal with NP-hard problems. Probably one reasonable approach is to formulate your problem as integer linear programming, and then solve with an off-the-shelf ILP solver. Another approach is to formulate it as an instance of SAT (with a pseudoboolean constraint/cardinality constraint for counting the number of clients that are serviced), and solve with an off-the-shelf SAT solver, like Z3 (which has good support for pseudoboolean constraints).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.