我在寻找一种用Python求解线性方程组的方法。
特别是,我在寻找大于所有零的最小整数向量,并解出给定的方程。
例如,我有以下等式:
想解决
。在
在这种情况下,求解该方程的最小整数向量为
。在
但是,如何自动确定此解决方案?
如果我使用scipy.optimize.nnls,比如A = np.array([[1,-1,0],[0,2,-1],[2,0,-1]])
b = np.array([0,0,0])
nnls(A,b)
结果是(array([ 0., 0., 0.]), 0.0)。
这也是正确的,但不是理想的解决方案。。。在
编辑:我很抱歉在某些方面不够精确。
如果有人对细节感兴趣,问题就出在报纸上
“数字信号处理同步数据流程序的静态调度”,Edward A.Lee和David G.Messerschmitt,
IEEE计算机学报,C-36卷,第1期,第24-35页,1987年1月。在
定理2说For a connected SDF graph with s nodes and topology matrix A and with rank(A)=s-2, we can find a positive integer vector b != 0 such that Ab = 0 where 0 is the zero vector.
在定理2的证明之后,他们说It may be desirable to solve for the smallest positive integer vector in the nullspace. To do this, reduce each rational entry in u' so that its numerator and denominator are relatively prime. Euclid's algorithm will work for this.