2

I am using minizinc and gecode to solve a minimization problem in a distributed fashion. I have multiple distributed servers that solve the same model with identical input and I want all the servers to get the same solution.

The problem is that model has multiple solutions, which periodically causes servers to come up with different solutions independently. It is not significant which solution will be chosen, as long as it is identical among all servers. I am also using "-p" arguments with gecode to use multiple threads (if it is relevant).

Is there a way that I could address this issue?

For example, I was thinking about outputting all the solutions and then sort them alphanumerically on each server.

Thanks!

4

1 回答 1

5

如果模型中的搜索策略不包含随机化,那么,假设所有版本控制都是相同的,执行 Gecode 的单个线程应该总是为相同的模型和实例数据返回相同的答案。如果它在不同的节点上并不重要。使用单线程执行是确保在所有节点上找到相同解决方案的最简单方法。

但是,如果您想使用多个线程,则无法做出此类保证。由于程序的并发性,每次运行的执行路径可能不同,每次可能会找到不同的解决方案。

您对解决方案进行排序的建议是可能的,但需要付出代价。有两种方法可以做到这一点。您可以使用标志找到所有解决方案-a,然后对其进行排序,或者您可以更改模型以强制解决方案成为第一个解决方案(如果您对它们进行排序)。第二个选项可以通过改变搜索策略来实现。这两种解决方案都可能非常昂贵,并且可能(超过)成倍地增加运行时间。

如果您完全关心运行时,那么我建议您采纳 Patrick Trentin 的建议,在主节点上运行模型并分发解决方案。这将是计算时间最有效的,并且最有可能在运行时同样有效。

于 2017-08-29T09:44:12.260 回答