ChaoII
ChaoII

Reputation: 1

How to implement non-zero count constraint for cvxpy in integer programming

I want to implement the constraint that the number of non-zero elements per row in x is less than 2.

constraint2 = cp.sum( x >= 0, 1) <= 2

but get the error TypeError: float() argument must be a string or a number, not 'Inequality' what to do ?

I had try constraint2.append(cp.log(cp.sum(cp.pos(-(x[i, :] - epsilon)) / epsilon)) >= 13) but get cvxpy.error.DCPError: Problem does not follow DCP rules. Specifically:. What should I do?

Upvotes: 0

Views: 273

Answers (0)

Related Questions