I am trying to create an expression of a constrain in cvxpy to solve an optimization problem. The following image shows the left side of constrain:
And t
,a
is the type of Variable. Therefore, I hope to know how to express ∑tlog(1+omega*a/t)
, I tried use the function of numpy.divide()
in below, but it didn't satisfy the DCP, the error is:
cons = [B*cp.sum (cp.multiply (t, cp.log( np.add( 1, a*np.divide(omega, t)))/cp.log(2))) <=constant]
cvxpy.error.DCPError: Problem does not follow DCP rules. Specifically:
The following constraints are not DCP:
1.0 @ Sum(var2 @ (log(Promote(1.0, (2,)) + Promote(var1, (2,)) @ ([1. 2.] / var2)) / Promote(log(2.0), (2,))), None, False) <= 10.523561956057012 , because the following subexpressions are not:
|-- [1. 2.] / var2
Any help/insight will be appreciated. Thanks!
I am trying change the expression. But the function of cvxpy may be not enough.
t * log(1+u/t)
can be written in cvxpy as -rel_entr(t, u+t)
.