Weiszfeld algo for "highway" distance? [closed] - algorithm

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
The problem is to find the point minimizing the travel distance for around 100 persons in different regions who want to meet in the same place. Travel is by car not by plane.
Assuming that I get access to an API giving me mileage / kilometric distance in terms of highway travel between any two points, how can I find the best place to meet?
On other Stackexchange sites (gis.stackexchange.com/questions/65563/meeting-point-minimizing-travel-distance-for-participants) I got directed to the Weiszfeld algo to solve this problem of geometric median.
I suspect that kilometric distance complexifies the problem, because it becomes possible to get stuck in local minima. I don't know really where to start. Any pointer would be appreciated.

Even though it may suffer from local minima, I would try local search, since road networks aren't adversarially designed. Pick a random starting point and then iterate as follows. Compute directions from the current point to the 100 clients. Evaluate each of the next-to-last stops in the directions and move the point to the best.

If the distances taken into account are Manhattan distances then the optimal meeting point is one of the points which has a x-coordinate equal to the x-coordinate of some input point, and the y-coordinate equal to the y-coordinate of some input point.

Related

Minimum covering radius in n dimensions [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
Is there any known algorithm to solve this ?
There's a related problem that's solvable with a greedy algorithm: given the points and a radius, find the minimum number of circles. This algorithm repeatedly places a circle whose left edge lies on the leftmost uncovered point, running in time O(n) on points sorted by x.
To get an algorithm for the requested problem, sort the points once and then use binary search to find the least radius that will result in at most d circles. Assuming that the x coordinates can be represented by machine words, this should be fine. (If not, there are other algorithms.)

What is the shortest path that touches every tile in a square grid? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
Suppose a ant is placed on the position (0,0) of a chess-board. That ant wants to walk through every single tile of the board, while walking the least it can to do so. What path it must follow? Is there a formula F(i) that returns the position of the ith tile on that path?
Edit: as requested, I've tried the following:
I tried googling for keywords such as "shortest path", "shortest path in square grid", but couldn't find anything relevant.
I then downloaded, configured and used a Traveling Salesman Problem solver in a square grid. Obviously, the solution wasn't satisfactory, but I could gain an insight on the problem. There is an illustration of my results:
I then, intuitively, speculated wether the answer could be something like the Hilbert Curve: . I googled about it and asked on a IRC programming channel, but I couldn't find any actual evidence this is better than spirals and similars, nor a proof this is the best possible solution.
EDIT 2: Further clarifications:
The ant can move diagonally. The distance refers to the euclidean length of the line defined by the path.
Walk in straight line, with the edge of the board on your left, until you either hit the edge of the chess board or a tile you have visited before. If you do, then take a right.
Or a thousand other obvious patterns.
Any path that takes 63 steps is the minimum and just as good as any other path.
This is going to depend on if you're taking the width of each square into consideration or is this just a double array question?
If we're talking a double-array question f(x,y), then the answer is that there is no least path because the ant will need to travel to each square f(x,y) = x*y, so f(8,8) = 64.
If we start taking the width of the tiles themselves into consideration, then the answer is somewhat different because we can use some strategies to get the least amount of distance traveled (such as starting in the center, staying by the grid separators and walking in a roughly spiral pattern r=xy^(theta)).

Computing location based on a list of approximate distances [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have N points in at 3D space (I think I can grasp myself general N-dimensional case) and approximate distances to these points, how can I compute my position relative to these N points?
EDIT
Please note that the distances are approximate, so the more approximate distances I have the more convenient result I should get
Thank you!
I would write down an equation that gives you some measure of the errors associated with a possible location, and then find the location that minimizes this measure. My first attempt would be to minimize the sum of the squares of the difference between the distance measured and the distance worked out from the possible location, for each of your approximate distance, so you are minimizing something like SUM_i((sqrt((X-Ai)^2 + (Y-Bi)^2 + (Z-Ci)^2) - Di)^2) where X,Y,Z is the location co-ordinates you are trying to find, (Ai,Bi,Ci) is the co-ordinates of one of the objects from which you are measuring distances, and Di is the distance measured. It doesn't look very pretty, but you should at least be able to compute derivatives and then find some sort of minimization routine in a math library.
You have distances from given N points in a 3D space and their approximate error values. So, you have a thick sphere for each of the points that you are in. You get all of them, calculate their intersection area, and take that area's center point as your approximate location.

Given a point inside a rectangle, determine the side that's closest to the point [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I was curious if there was an elegant way to do this, aside from just calculating the distance from the point to each side and finding the minimum.
Some things I've thought about:
If it's a square, we can just draw the diagonals and figure out which of the 4 regions the point falls on. Each of these region corresponds to a closest side.
Perhaps we can divide up the rectangle into squares and go somewhere from there?
It seems an alternative solution would be too complicated and not worth looking for.
For rectangle you can use following regions:
I think the rectangle is not orthogonal to the coordinate system. First calculate the middle point of every side. This should be simple depending on how you have define the rectangle.
Then calculate the distance to this middle points. The smallest distance is the nearest side. You need not to calculate the full distance with pytagoras. The sum of the squared is enough.

Implementing Interior Point [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
Besides Boyd's Convex Programming book,
what's the best resource for:
analysis + practical implementation of interior point algorithms?
If you have Boyd's book, you know about CVXOPT. Look inside of it. If you are interested in implementation details, looking at an implementation is invaluable. As with most complex numerical algorithms, you are going to be much better off using previously written code than writing your own, but you probably know that. There are many other interior point implementations available online for linear programing, SOCP, quadratic programming, convex programming, etc. I have also used OOQP, and looked a bit at the insides. It seemed straightforward enough.
I also liked the first edition of Numerical Optimization. I had a good, fairly practical, overview of predictor-corrector methods in the second half. The second edition is no doubt of similar quality.
You can implement it in two ways:
If you have only one point, you'll get the area of the polygon, and then check if the sum of the area of the n triangles with a verticle in the point and the other two in two consecutively points is equal with the area of the polygon. If it's true, the point is inside, otherwise it's outside.
If you have many points (let's say M points) and you have to find if it's inside, you'll find a point inside the polygon, and split the polygon into n triangles, with a verticle in that point and the other two in two consecutively points on the polygon (that form an edge). You will have n lines, with a verticle in the point choosed before and a point in each point of the polygon. You'll sort them by the angle, clockwise. Then, you'll have M lines with a verticle in the point choosed and the other in one of the M points. You'll sort them like the first N. Then, you can find in o(N + M), for each point in the M, the nearest left and right line from the N (let's say the lines are CenterAx and CenterAy. Next, you'll have to find if the point it's in the triangle CenterAxAy. You can do it in o(1) checking if the are a of the triangle CenterAxAy is equal with area(CenterAxP) + area(CenterAyP) + area(AxAyP).
I hope you'll understand what i've written here.

Resources