属于SOCP问题。
$$\max {w'r}$$
st
$$w'\Sigma w < threshold$$
其中$\Sigma = F'F + D$
如果不导入$\Sigma$的结构运算效率极低。但是不知道怎么使用ROI中的ecos导入协方差矩阵结构。
参考python中
import numpy as np
from cvxpy import *
# Generate data for factor model.
n = 3000
m = 50
np.random.seed(1)
mu = np.abs(np.random.randn(n, 1))
Sigma_tilde = np.random.randn(m, m)
Sigma_tilde = Sigma_tilde.T.dot(Sigma_tilde)
D = np.diag(np.random.uniform(0, 0.9, size=n))
F = np.random.randn(n, m)
# Factor model portfolio optimization.
w = Variable(n)
f = F.T*w
gamma = Parameter(nonneg=True)
Lmax = Parameter()
ret = mu.T*w
risk = quad_form(f, Sigma_tilde) + quad_form(w, D)
prob_factor = Problem(Maximize(ret - gamma*risk),
[sum_entries(w) == 1,
norm(w, 1) <= Lmax])
# Solve the factor model problem.
Lmax.value = 2
gamma.value = 0.1
prob_factor.solve(verbose=True)