I am not sure if I understand your question well.
If your weights are already defined in terms of percentage, it is directly the definition of quadprog
:
x = quadprog(H, f, [], [], [], [], lb, [])
So H
, e
, and f
should be provided by the matlab description of:
quadprog(H,f)
- returns a vector x
that minimizes 1/2 * x' * H * x + f' * x
. H
must be positive definite for the problem to have a finite minimum."
And lb
is a vector of the constraints. For instance if x
is a vector 3 x 1
, then lb = [0.01; 0.01; 0.01]
in the case of the desired percentage is 0.01
(1%
)
On the other hand, lets assume the sum_{i=1}^{n} w_i
is not equal to 1
. Therefore, w_i
is not defined in terms of percentage.
Therefore, the constraint that you need is p_i (percentage)= w_i / (sum w_i) >= 0.01
(in the case of the lower bound be 1%
).
Note that the constraint in this case is
w_i >= 0.01 * (sum w_i)
Or
-0.01 * (sum_{j=1}^{i-1} w_j) + 0.99 * w_i - 0.01 * (sum_{j=i+1}^{n} w_j) >= 0
Or
0.01 * (sum_{j=1}^{i-1} w_j) - 0.99 w_i + 0.01 * (sum_{j=i+1}^{n} w_j) <= 0
Therefore, this is a constraint of the type Ax <= b
.
So
A_ij = 0.01
when i
is different from j
A_ij = -0.99
when i = j
and b = zeros(n, 1)
In this case you are using
x = quadprog(H, f, A, b)
I hope I helped you!
Daniel