我有一个矩阵如下:
lift
Out[147]:
array([[188, 149, 147, 129, 104],
[104, 168, 197, 114, 119],
[134, 157, 152, 153, 103],
[126, 176, 174, 126, 151],
[137, 146, 168, 183, 121]], dtype=int64)
我试图将其最小化,但条件是行总和应小于以下矩阵:
Constt
Out[148]:
array([[12000],
[18000],
[18000],
[12000],
[12000]])
我使用了以下代码:
res = linprog(lift, A_ub=lift, b_ub=Constt, bounds=list(zip(VminA, VmaxA)), options={"disp": True})
VminA和VmaxA是由(5×5)个边界组成的矩阵。我没有得到解决方案。我收到以下错误:
Traceback (most recent call last):
File "<ipython-input-149-cd1e2b9696bc>", line 1, in <module>
res = linprog(lift, A_ub=lift, b_ub=Constt, bounds=list(zip(VminA, VmaxA)), options={"disp": True})
File "C:\Users\hp1\Anaconda3\lib\site-packages\scipy\optimize\_linprog.py", line 993, in linprog
bounds=bounds, callback=callback, **options)
File "C:\Users\hp1\Anaconda3\lib\site-packages\scipy\optimize\_linprog.py", line 579, in _linprog_simplex
L[i] = bounds[i][0] if bounds[i][0] is not None else -np.inf
ValueError: setting an array element with a sequence.
有人可以帮助我吗?另外请告诉我如何添加关于列求和的另一个约束?