I have no idea how to do this. I can set up the Lagrangian, but I don't know how to translate it into solve.qp()
inputs.
The inputs are Dmat, dvec, amat, bvec, meq.
I don't know LaTeX so excuse my notation here. My problem is a global minimum variance portfolio optimization subject to the constraints x1+x2+x3 = 1, as well as 0 < x1 < w1, etc. Essentially, the weights must equal one, and the weights have a min/max condition.
So the matrix notation is (where Sigma is the covariance matrix of 3 assets)
[2*Sigma [x1 = [0
2*Sigma x2 = 0
2*Sigma x3 = 0
1 1 1 L1 = 1
-1 0 0 L2 = 0
0 -1 0 L3 = 0
0 0 -1 L4 = 0
1 0 0 L5 = w1
0 1 0 L6 = w2
0 0 1] L7] = w3]
I know meq=1, as there is only one equality constraint. How do I translate the rest of the matrices into inputs for solve.qp()
?
Sigma
, dvec is[0,0,0]
, Amat is the constraints below Sigma, somatrix(rbind(rep(1,NumAsset),-diag(NumAsset), diag(NumAsset)), ncol=NumAsset)
, and bvec is the vector of targets, so[1, 0, 0, 0, w1, w2, w3]
. The problem is now I'm getting "constraints are inconsistent, no solution" $\endgroup$