Trying to solve the optimization problem with cvxpy .

 import numpy as np import cvxpy as cvx m = 100 n = 100 A = np.random.randn(m, n) b = cvx.Variable(m) c = cvx.Variable(n) x0 = np.ones(n) x = cvx.Variable(n) obj = cvx.Minimize(c * x) constraints = [b == A * x0, A * x - b, c == -cvx.sum_entries(A)] prob = cvx.Problem(obj, constraints) print "Optimal value", prob.solve() print "Optimal var" print x.value 

The following error appears: line 16, in <module> obj = cvx.Minimize(c * x)

 cvxpy.error.DCPError: Cannot multiply two non-constants. 

How to fix it?

1 answer 1

I am not an expert in the field of this task, but this is just a side view.
Try to check this idea: https://www.quora.com/How-can-I-solve-non-linear-kernel-support-vector-machine-SVM-with-CVX
But as far as I can understand an unfamiliar library at a glance, x and c are set as parameters for optimization, and the optimization problem — minimizing their work — in this case, optimization by both parameters is equivalent from the point of view of mathematics (for my incomplete understanding of the problem) two: when one parameter is infinity and the other is minus infinity, which can make the optimization process difficult.