这不完全是套索,因为我增加了一个额外的约束,但我不确定我应该如何用cvxpy来解决下面这样的问题
import cvxpy as cp
import numpy as np
A = np.random.rand(5000,1000)
v0 = np.random.rand(1000,1)
v = cp.Variable(v0.shape)
iota = np.ones(v0.shape)
lam = 1
objective = cp.Minimize( (A@(v-v0)).T@(A@(v-v0)) + lam * cp.abs(v).T @ iota )
constraints = [v >= 0]
prob = cp.Problem(objective, constraints)
res = prob.solve()
我尝试了不同的版本,但这是最清楚地显示我想做什么的一个版本。我得到的是错误。
DCPError: Problem does not follow DCP rules. Specifically: The objective is not DCP. Its following subexpressions are not: ....
然后是一个我不明白的错误,哈哈。