views:

83

answers:

2

Given a set of points in the 2D Euclidean plane: P={V1,V2,..,Vn}, and we assume that there are K different types of points:T1,T2,..,TK, every point Vi in P belongs to exactly one of the K types.

Definition of KTSP tour:
Given an arbitrary location point V0 in the same 2D Euclidean plane (V0 has no type), a path V0->V'1->V'2->V'3->....->V'K->V0 is called a KTSP tour iff V'i belongs to type i.

A KTSP tour is just an ordinary tour starting and ending in the same given arbitrary point but subject to two more constraints: (1)It passes every type of point one and only once. (2)The type of point the path passes has order. That is, it first starts from point V0, then first passes type T1 point, then type T2 point, then type T3 point, and so on until it passes type TK point, after which it comes back at V0.

Here is my question:
when the point location V0 is given find the shortest KTSP tour.

For example, in the following figure, every color represents one type of point, there are 3 different types of points, we assume blue colored points are type 1, red type 2, black type 3,
and the little triangle with yellow is the given location V0, then the shortest TSKP tour corresponding to this particular V0 is shown with the four blue arrows.

It seems to me this a variant of the classical TSP problem, but i can't think of an algorithm, need help! alt text

A: 

I would recommend backtracking (if the number of points isn't to large).

It's the easiest algorithm out there

Bigbohne
unfortunately the number is very huge.
outlaw
+4  A: 

It's not tsp, but shortest path.

Consider k layers of points :

  • on layer k you only have all points of color k
  • you have a directed edge between every point of a layer and every points of the next layer
  • add an edge between V0 and all points of layer 1
  • create a copy of V0, V0' and add an edge between every point of layer k and V0'

Now what you want is the shortest path between V0 and V0', it will pass at layer 1, 2...k and finally V0', given you your "shortest TSKP tour".

Loïc Février
Beat me to it, +1.
j_random_hacker
me too :) '''''
Nikita Rybak
It seems you are right
outlaw
@outlaw: How big are you data ? How many points ?
Loïc Février
@Loïc Février: tens of thousands
outlaw
How many in each layer ? In fact you can compute the distance layer by layer so the complxity will be O(k*M^2) with M the number of elements in each layer.
Loïc Février
thousands of in one layer, i get your idea, in dynamic programming fashion?
outlaw
Exactly, but you need to compare the complexity with shortest path algorithms.
Loïc Février