I am trying to solve the following problem using CVXPY:
# Define the variable
x = cp.Variable()
# Define the objective function
objective = cp.Minimize(1/x)
# Define the constraints
constraints = [x >= 1, x <= 10]
# Formulate the problem
problem = cp.Problem(objective, constraints)
# Solve the problem
problem.solve()
# Print the results
print("Optimal value of x:", x.value)
print("Optimal minimum value:", 1/x.value)
It gives me the following error:
DCPError: Problem does not follow DCP rules. Specifically:
The objective is not DCP. Its following subexpressions are not:
1.0 / var8856
Now I know that 1/x is not convex but it is convex in the interval [1, 10] so why does CVXPY raise a DCP error.