I’m trying to solve a problem which is Minimize log2(1 + 1/x). 1<=x<=3
Because cvxpy can’t use the log2 function, I use cp.log (1 + x) / np.log (2) instead.
This is my code.
x = cp.Variable()
obj = cp.Minimize(cp.log(1 + 1 / x) / cp.log(2))
constraints = [x >= 1, x <=3]
prob = cp.Problem(obj, constraints)
prob.solve()
error------------------------------------
The objective is not DCP. Its following subexpressions are not:
1.0 / var0
Thanks a lot for your replay, but solver told me that constraints are not DCP.
This is my code
obj = cp.Minimize(t)
constraints = [ ]
constraints.append(x <= 3)
constraints.append(x >= 1)
constraints.append(t >= cp.logistic(u))
constraints.append(cp.exp(u) >= 1 / x)
exp(var2) <= 1.0 / var0 , because the following subexpressions are not:
Thank you so much! You already helped me a lot. The last problem, Generally speaking,does the base number of logarithmic function affect the concavity and convexity of function? For example, log2(1 + 1/ x) is convex for x. what about loge(1 + 1/x)?