This image shows a made-up trail with a restroom (cyan point). I would like to add 2 more restrooms where the maximum distance along trail from anywhere on the trail to the closest of the 3 restrooms is minimized.
# Data
# trail is a list of segments between the magenta and/or cyan points (in the image).
# Each of the segments in turn is a list of endpoints.
trail = [[[0, 0], [1, 0]], [[2, 0], [3, 0]], [[3, 0], [4, 0]], [[4, 0], [5, 0]], [[6, 0], [7, 0]], [[5, 1], [6, 1]], [[1, 2], [2, 2]], [[4, 2], [5, 2]], [[1, -1], [2, -1]], [[3, -1], [4, -1]], [[5, -1], [6, -1]], [[4, -2], [5, -2]], [[1, 2], [1, 0]], [[1, 0], [1, -1]], [[2, 2], [2, 0]], [[2, 0], [2, -1]], [[3, 2], [3, 0]], [[4, 2], [4, 0]], [[4, 0], [4, -1]], [[4, -1], [4, -2]], [[5, 2], [5, 1]], [[5, 1], [5, 0]], [[5, 0], [5, -1]], [[5, -1], [5, -2]], [[6, 1], [6, 0]], [[6, 0], [6, -1]], [[3, -1], [4, 0]]]
restroom = [0, 0]
This is a simplified version of this question.
Hints will be appreciated as well. Thanks.
I think this could be effectively tackled with a relaxation approach.
The fidelity of the solution will be improved by adding further degenerate nodes such that the maximum distance between nodes is below some threshold.
I wouldn't be at all surprised if there were some local-minima problems with some graphs that meant you wouldn't always get the same solution from different random starting placements, but this technique would at least refine an initial guess at a solution.