谢谢大家的回复。我会在这里解释。假设有一个给定的矩阵
x y B = [5,-4,5,-6]
[[0,0,0,0], [[0,1,0,1],
[0,0,0,0], [0,0,0,0],
[0,0,0,0], [0,0,0,1],
[0,0,0,0]] [0,0,0,0]]
例如一个可行的解决方案是 [[0,4,0,1],[0,0,0,0],[0,0,0,5],[0,0,0,0]] 4+1 -0 == 5 0-4 == -4 5-0 == 5 0 - 5-1 == -6
我想更新 x 以确保:
(1) if y[i][j] == 0:
x[i][j] = 0
(2) x[0][0]+x[0][1]+x[0][2]+x[0][3]-x[0][0]-x[1][0]-x[2][0]-x[3][0] = B[0]
x[1][0]+x[1][1]+x[1][2]+x[1][3]-x[0][1]-x[1][1]-x[2][1]-x[3][1] = B[1]
...
如何编程找到可行的x?