This is a geometric special case of a weighted maximum coverage problem . The general MCP is NP-hard, and I suspect that this particular case is also, although unlike the general case, it probably has an effective polynomial time approximation scheme. However, you want an optimal solution, so the first thing I would recommend is to combine the integer formulation of linear programming in a related Wikipedia article with an LP solver.
maximize sum_j (w_j * y_j) subject to for all i, sum_i x_i <= U for all j, sum_{i : j in S_i} x_i - y_j >= 0 for all i, x_i in {0, 1} for all j, 0 <= y_j <= 1
The mass w_j each point j , and the sets S_i are all the possibilities for covering points with a square of width L The value of x_i is whether the set S_i selected. The value of y_j is whether point j covered. The simplest cubic algorithm for constructing S_i is to list all the squares whose lower left vertex has an x โโcoordinate equal to the coordinate of some point and y equal to the coordinate of some (possibly another) point, since each other square can be moved up and / or to the right without sacrificing insurance.
David Eisenstat
source share