I am using MATLAB to do an optimisation. The QP minimisation problem is set up in the standard form shown below. The optimisation is used to calculate the weights (x vector in the equation below) of a portfolio.
Min 0.5 (x'Fx) + c'x
x
st
x_low <= x <= x_up
b_low <= Ax <= b_up
where
c is a n x 1 vector in the objective function
x is a n x 1 vector (weights of the stocks in the portfolio)
F is a n x n matrix in the objective function
A is the linear constraint matrix
b_low & up are the lower and upper bounds for the linear constraints
Trying to follow an example but have two issues. Firstly say the portfolio has 500 stocks the x vector passed into the optimiser (x here is our initial guess) will have the dimension of 1000 x 1. The second 500 will have the opposite sign of the first 500, I do not understand why this is?
Also the F matrix does something similar. Say I have a matrix R which contains some risk factors, which is 500 x 500.
Then F is set to the following (sorry not sure how to show matrices on this site properly)
F = R -R
-R R
Again why would you do this?
Update
The solver is actually Tomlab (user guide of the solve is here link).
Further Info
Just stepping through the code.
x0 is passed as an intial guess vector 1000 x 1. The first 500 weights are the previous weights. The next 500 weights are all set to zero.
x_up is obviously also a 1000 x 1 vector to. Looking further into the code. The first 500 weights are the upper bounds on the buys the next 500 are the upper bounds on the sells.
x_low is the same but for the lower bounds. First 500 weights are the lower bounds on the buys the next 500 are the lower bounds for the sales.