When I run this using cvxpy (cost
is my objective function):
x = cp.Variable((4,4), integer=False)
for i in range(0,4):
for j in range(0,3):
cost += (x[i][j] / x[i][j+1] + 5)**2
It gets error:
cvxpy.error.DCPError: Problem does not follow DCP rules. Specifically:
The objective is not DCP. Its following subexpressions are not:
var3[0, 0:2][0] / var3[0, 0:2][1]
var3[1, 0:2][0] / var3[1, 0:2][1]
Why does this appear? I have checked the DCP ruleset as it said: http://cvxr.com/cvx/doc/dcp.html#quadforms . But i'm also not sure.
BTW, if i turn the division to log, like cost += (log(x[i][j]) - log(x[i][j+1]) + 5)**2
, it will also give a error:NameError: name 'log' is not defined var1
, seems the content in log can't be a variable.
So is there a solution to address this? Or how can i transform my objective function in cvxpy to do this?