Search code examples
python-3.xconvex-optimizationcvxoptcvxpy

Convex Optimization problem labeled as non convex


I'm using cvxpy (1.0.11) to solve a convex optimization problem.

The convex problem I have is being labelled as non-convex I think because it does not know that the parameter alpha is bounded between [0, 1].

I know this from this line fails... loss = mse + (1-alpha) * lam * (penalty_1 + penalty_2) + alpha * lam * penalty_3

while this line succeeds... loss = mse + lam * (penalty_1 + penalty_2) + lam * penalty_3

Right now the hyperparameters are parameterized this way. If there is a way to bound them I haven't found it in anywhere in the API

alpha = cvx.Parameter(nonneg=True)
alpha.value = 0.5
lam = cvx.Parameter(nonneg=True)
lam.value = 10**(2)

How do I tell cvxpy that alpha is a number between [0, 1]?


Solution

  • I found a solution that that is trivially simple. Instead of setting alpha as a parameter simply set it as a normal float.

    alpha = 0.5
    lam = cvx.Paramter(nonneg=True)
    lam.value = 1e2