Given connected line segments A->B->C->D (A->B is a line segment, then B->C is another and so on), how to find the minimum cost of traveling from A->D given the following options?
- You can follow the line segments to travel, which costs you $1/unit_distance
- You can ‘jump’ from some point on any line segment to some other point on some other line segment, which costs you $2/unit_distance covered in that ‘jump’ and then again choose between option #1 and option #2 for remaining journey.
The line segments are lines in 2D.
e.g. Suppose that you need to travel from (0,0)->(2,2)->(2,-2). There are many options to do this. I am listing 3 below:
- If you follow option #1 entirely, the cost is 2√2 (from (0,0) to (2,2)) + 4 (from (2,2) to (2,-2))
- If you jump from (0,0) to (2,-2), the distance covered is 2√2, and hence the cost is 4√2 ($2/unit for a jump).
- However, a better minimum cost would result if you jump from (0,0) to (2,-1) and then follow option #1 from (2,-1) to (2,-2) which costs you 2√5 (for the jump) + 1 (for following option #1).
The number of line segments might vary. I was thinking about formulating some LPP for this, but unable to proceed any further. Can someone please help me in finding the minima for such problems?
I don’t thing LPP can be used directly to solve the problem, because the distances are nonlinear, i.e. if you use as a distance measure for any point P on any of the line segments the distance from A following the line segments only, then the “hop” distance function that measures the cost of moving from a point P at distance x from A to another point P’ at distance x’ from A by “hopping”, say Hop(x, x’), is nonlinear in both x and x’ because the Euclidean distance metric is nonlinear.
However, let’s assume first that there are only two segments (i.e. the path is A-B-C). The only possible pattern for a hop is to jump from the segment A-B to segment B-C, as it doesn’t make sense to hop within a single segment. Let the three points be at coordinates A=(ax,ay), B=(bx,by) and C=(cx,cy). Consider then a point P on segment A-B and point P’ on segment B-C so that the distance of P from A is d and the distance of P’ from B is d’. The distance from P to P’ through the segments is
where AB is the (constant) distance from A to B, and by hopping it is
where
where BC is the distance from B to C.
The difference between the two distances is then
and I’m sure it can be solved for local minima by any standard techniques for such. The minima represent those pairs (P, P’) where the benefit of the hop over following the segments can’t be improved, and based on the geometry of the problem I’d really expect there to be only a finite number of such minimal pairs.
This same approach can be used on any pair of two segments on the path as the fact that the segments are connected was not used, so in this fashion you can build up an equivalent network with finite branching (as suggested in one of the comments above), and then use simple path-finding algorithm to calculate the optimal result.