Ray Burns Ray Burns - 3 days ago 4
C Question

How can I tell where the optimal path for the k-server dynamic solution is located in array cost[ i ][ j ][ k ][ t ]?

You can find the optimal strategy by a dynamic-programming type argument: If the input sequence was n request points long (p1,...,pn), you create an n × n × n × n array; the entry cost[i][j][k][t] is the cost of the cheapest sequence of moves that starts at the given starting positions and serves the requests up to time step t, and ends up with the yellow server at pi, the red server at pj, and the blue server at pk. One of ijk must be t, since the last request at pt was served, all other table entries have cost ∞. Any possible table entry must have been reached by moving one of the three servers from a position at step t − 1.

Now say I have an array called positions which contains points (x,y) coordinate values and the array at position 0, 1, and 2 are the initial positions of the server 1, 2, 3 respectively, and the elements from the array indexed at 3 to the end of the array are the requests points.

If I use this algorithm and compute all possible path that all 3 servers can take, how can I tell where the optimal path for the k-server problem is located at?

If the size of the positions is 10, why is cost[9][9][9][9] is not a solution and where can I find the solution?

Answer

To find the optimal solution itself once the cost is computed, you can go like this:

  1. Find the optimal combination of i, j and k for the final value of t (by simply trying all triplets).

  2. Initialize the current state with (i, j, k, t).

  3. Keep finding the parent state and going to it until the initial state is reached.

  4. To find the parent, you can iterate over all states that could lead to the current one and make sure that a transition from the previous state to the current state indeed yields the cost of the current state (if there are several options, you can pick any of them).

  5. You could also store the parent array and fill it while computing the cost function.

Once you know the sequence of states that lead to the final optimal solution, you can easily get the path itself by checking which server moves for each transition.

Comments