简体   繁体   English

如何判断k-server动态解决方案的最佳路径在数组成本[i] [j] [k] [t]中的位置?

[英]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; 您可以通过动态编程类型参数找到最优策略:如果输入序列是n个请求点long(p1,...,pn),则创建一个n×n×n×n数组; 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. 入口成本[i] [j] [k] [t]是从给定起始位置开始的最便宜的移动序列的成本,并且在时间步骤t之前提供请求,并且最终在pi处以黄色服务器结束,pj的红色服务器和pk的蓝色服务器。 One of ijk must be t, since the last request at pt was served, all other table entries have cost ∞. ijk中的一个必须是t,因为pt的最后一个请求被提供,所有其他表条目的成本为∞。 Any possible table entry must have been reached by moving one of the three servers from a position at step t − 1. 必须通过从步骤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. 现在说我有一个名为position的数组,其中包含点(x,y)坐标值,位置0,1和2的数组分别是服务器1,2,3的初始位置,并且数组中的元素已编入索引在3到数组的末尾是请求点。

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? 如果我使用这个算法并计算所有3个服务器可以采用的所有可能路径,我怎么知道k-server问题的最佳路径在哪里?

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? 如果位置的大小是10,为什么成本[9] [9] [9] [9]不是解决方案,我在哪里可以找到解决方案?

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). 找到最佳组合ijk的终值t (通过简单地尝试所有三胞胎)。

  2. Initialize the current state with (i, j, k, t) . (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. 您还可以存储父数组并在计算cost函数时填充它。

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. 一旦了解了导致最终最优解的状态序列,您就可以通过检查每个转换的哪个服务器移动来轻松获取路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM