python 方程组 整数解_用Python语言求解线性整数方程组
我在尋找一種用Python求解線性方程組的方法。
特別是,我在尋找大于所有零的最小整數(shù)向量,并解出給定的方程。
例如,我有以下等式:
想解決
。在
在這種情況下,求解該方程的最小整數(shù)向量為
。在
但是,如何自動確定此解決方案?
如果我使用scipy.optimize.nnls,比如A = np.array([[1,-1,0],[0,2,-1],[2,0,-1]])
b = np.array([0,0,0])
nnls(A,b)
結(jié)果是(array([ 0., 0., 0.]), 0.0)。
這也是正確的,但不是理想的解決方案。。。在
編輯:我很抱歉在某些方面不夠精確。
如果有人對細(xì)節(jié)感興趣,問題就出在報紙上
“數(shù)字信號處理同步數(shù)據(jù)流程序的靜態(tài)調(diào)度”,Edward A.Lee和David G.Messerschmitt,
IEEE計算機(jī)學(xué)報,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.
總結(jié)
以上是生活随笔為你收集整理的python 方程组 整数解_用Python语言求解线性整数方程组的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 声速的测量的实验原理和应用_CEMS烟气
- 下一篇: 在python中是否可以使用if作为变量