我尝试创建程序生成线性规划问题,如
min cx
s.t. Ax=b
x>=0
但它出现了程序警告消息的问题
"File"/tmp/tmpgX7_hI/___code___.py", line 3, in <module> class LP:" "File"/tmp/tmpgX7_hI/___code___.py", line 4, in LP c=matrix()" "TypeError: _new_() take at least 2 arguments (1 given)"
这是我的错误,我应该如何解决?请!!!
Program
class LP:
c=matrix()
A=matrix()
b=matrix()
def__init__(self,cvector,Amatrix,bvector):
self.c=cvector
self.A=Amatrix
self.b=bvector
#----------------------------------------------------------------------
import random
colc=[]colAmatrix=[]
colb=[]
LP_GEN=[]
for m in range(2,5):
for n in range(2,5):
for k in range(2):
c=matrix(1,n)
for i in range(n):
c[0,i]=random.randint(-50,50)
b[0,i]=random.randint(-50,50)
A[0,i]=random.randint(-50,50)
LP_GEN.append(LP(c,A,b))