You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"You ended off the post by asking readers for suggestions on how to make your code pick locations on land and avoid those on water. I've not read any literature on constrained optimization, but here are a few suggestions just from the top of my head:
Perhaps you could write your own implementation of Nelder-Mead, but allow it to accept a lambda which can be called to determine if a certain point on the plane is "admissible" or not. Adjust the algorithm so it can only choose a transformation which sends the worst point to an "admissible" point. If none of the five transformations used by N-M generate an admissible point, then terminate.
Invent some transform of the earth's landmass which maps it onto a square plane, perform N-M in that transformed space, then apply the inverse transform to the optimum point to get the actual location on the earth's surface. I thought of two possible transforms off the top of my head:
Out of the 0-2π range of possible longitudes, take all longitudes which intersect with some landmass. Map those to the x-coordinates 0-1. Then for each such longitude, take all latitude intervals for which it intersects with landmass, and map those intervals only to the y-coordinates 0-1 (scaling their size as needed to fit a 0-1 range). My concern here is that the resulting function of (x,y) will have a very jagged, non-continuous surface, and optimization algorithms like N-M work best on relatively smooth surfaces.
Map all possible longitudes to x-coordinates and latitudes to y-coordinates. Then take every point in the (x,y) plane which maps to an ocean point, and instead, map it to the closest land point. Effectively, you are taking all the seacoast points and massively stretching them out to fill in the oceans. The resulting mappings of ocean points to land points would be similar in spirit to a Voronoi diagram. Aside from being discontinuous, this function of (x,y) has another problem... large areas will be "flat", and N-M is useless when the triangle gets onto a flat surface.
Even with the caveats I have mentioned above, I guess that it might still be possible to get the results you want with either of the above schemes"
Etienne Bacher: Where should my family meet?
https://www.etiennebacher.com/posts/2023-01-14-where-should-my-family-meet/
The text was updated successfully, but these errors were encountered: