QBSolv没有为BIP提供可行的解决方案

时间:2018-05-28 05:48:46

标签: pyomo

我在python的dwave_qbsolv库中使用QBSolv函数来解决二进制整数规划问题(BIP)。我设法根据原始问题的qubo公式提出了Qubo矩阵。有两个约束,增加了松弛变量,只有一个等式约束。问题是最大化问题。下面是python语句和输入python命令的Qubo字典(上三角形)。我为每个约束添加了8个松弛,并且有4个决策变量。

Qubo = [[-2098.0, 198.5, 98.5, 197.5, 7.5, 17.5, 37.5, 77.5, 157.5, 317.5, 637.5, 1277.5, -1.5, -0.5, 1.5, 5.5, 13.5, 29.5, 61.5, 125.5], [198.5, -4001.0, 197.5, 398.5, 17.5, 37.5, 77.5, 157.5, 317.5, 637.5, 1277.5, 2557.5, -1.5, -0.5, 1.5, 5.5, 13.5, 29.5, 61.5, 125.5], [98.5, 197.5, -2100.0, 198.5, 7.5, 17.5, 37.5, 77.5, 157.5, 317.5, 637.5, 1277.5, -1.5, -0.5, 1.5, 5.5, 13.5, 29.5, 61.5, 125.5], [197.5, 398.5, 198.5, -4003.0, 17.5, 37.5, 77.5, 157.5, 317.5, 637.5, 1277.5, 2557.5, -1.5, -0.5, 1.5, 5.5, 13.5, 29.5, 61.5, 125.5], [7.5, 17.5, 7.5, 17.5, -214.0, -0.5, 1.5, 5.5, 13.5, 29.5, 61.5, 125.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5], [17.5, 37.5, 17.5, 37.5, -0.5, -431.0, 5.5, 13.5, 29.5, 61.5, 125.5, 253.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5], [37.5, 77.5, 37.5, 77.5, 1.5, 5.5, -859.0, 29.5, 61.5, 125.5, 253.5, 509.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5], [77.5, 157.5, 77.5, 157.5, 5.5, 13.5, 29.5, -1691.0, 125.5, 253.5, 509.5, 1021.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5], [157.5, 317.5, 157.5, 317.5, 13.5, 29.5, 61.5, 125.5, -3259.0, 509.5, 1021.5, 2045.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5], [317.5, 637.5, 317.5, 637.5, 29.5, 61.5, 125.5, 253.5, 509.5, -6011.0, 2045.5, 4093.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5], [637.5, 1277.5, 637.5, 1277.5, 61.5, 125.5, 253.5, 509.5, 1021.5, 2045.5, -9979.0, 8189.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5], [1277.5, 2557.5, 1277.5, 2557.5, 125.5, 253.5, 509.5, 1021.5, 2045.5, 4093.5, 8189.5, -11771.0, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5], [-1.5, -1.5, -1.5, -1.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, 1.0, 1.5, 5.5, 13.5, 29.5, 61.5, 125.5, 253.5], [-0.5, -0.5, -0.5, -0.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, 1.5, 1.0, 13.5, 29.5, 61.5, 125.5, 253.5, 509.5], [1.5, 1.5, 1.5, 1.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, 5.5, 13.5, 13.0, 61.5, 125.5, 253.5, 509.5, 1021.5], [5.5, 5.5, 5.5, 5.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, 13.5, 29.5, 61.5, 85.0, 253.5, 509.5, 1021.5, 2045.5], [13.5, 13.5, 13.5, 13.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, 29.5, 61.5, 125.5, 253.5, 421.0, 1021.5, 2045.5, 4093.5], [29.5, 29.5, 29.5, 29.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, 61.5, 125.5, 253.5, 509.5, 1021.5, 1861.0, 4093.5, 8189.5], [61.5, 61.5, 61.5, 61.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, 125.5, 253.5, 509.5, 1021.5, 2045.5, 4093.5, 7813.0, 16381.5], [125.5, 125.5, 125.5, 125.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, -2.5, 253.5, 509.5, 1021.5, 2045.5, 4093.5, 8189.5, 16381.5, 32005.0]]

用于解决Qubo的python函数。

response = QBSolv().sample_qubo(Qubo)

list(response.samples()) #Get the resulting allocation

我得到的结果集。

[{0: 1, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1, 10: 1, 11: 0, 12: 1, 13: 1, 14: 0, 15: 0, 16: 0, 17: 0, 18: 0, 19: 0}]

这违反了我最初的问题限制。

我很感激,如果你们中的任何人都可以帮助我解决这个问题。

0 个答案:

没有答案