cvxopt TypeError: unsupported operand type(s) for -: '_function' and 'cvxopt.base.matrix' when using Sparse Matrix

24 Views Asked by At

I got this error when i try to use Sparse Matrix instead of Dense Matrix when modelling linear programming problem. Call Stack: File "C:\Users\d.udin\AppData\Roaming\Python\Python39\site-packages\cvxopt\modeling.py", line 895, in le return constraint(self-other, '<') TypeError: unsupported operand type(s) for -: '_function' and 'cvxopt.base.matrix'

# A_lt_sparse if of type cvxopt.base.spmatrix
# b_lt is of type cvxopt.base.matrix
x = variable(var_count)
c = matrix(np_obj_coefs)
ineq = ( A_lt_sparse * x <= b_lt ) # this line throws the error
eq = ( A_eq_sparse * x == b_eq )
lp = op(dot(c, x), [ineq, eq])
lp.solve(solver='glpk')

When contraint matrix A is og type cvxopt.base.matrix i. e. Dense Matrix everything works filne. But moddelling takes huge space of memory. So I decided to use Sparse Matrices instead. Without any success yet.

I tried to convert Sparse Matrix back to Dense Matrix without success though

0

There are 0 best solutions below