There are n same circles and one square.How can I randomly place the circle inside the square so that the square is fully covered? PS: all the circles should overlap with other circles.
Asked
Active
Viewed 317 times
1 Answers
0
You could try a randomized approach, e.g. some sort of evolutionary algorithm. In its simplest form:
- place your n circles with radius r randomly in the square
- measure the coverage of those circles on the square, e.g. by sampling some (or rather many) points and testing whether they are within r to any of the circles
- repeat until the square is fully covered (or until X generations have passed):
- slightly vary the covering by randomly moving one or more of the circles
- measure the coverage of the new variant
- if the coverage of the new variant is better than the original, keep the variant, otherwise keep the original for the next iteration
Note that this is not guaranteed to find the optimal solution (if there is any) all the time, but it should work rather well in the general case. Also, you might need to sample rather many points in order to prevent early termination (or find a better, deterministic method), or you could dynamically increase the number of points to be sampled once the coverage gets rather high.
PS.: Your PS does not need to be checked. If the circles do not overlap, there is no way that they can cover the entire area of the rectangle without gaps.

tobias_k
- 81,265
- 12
- 120
- 179