With regards to a quadratic programme, how would I set up an objective function like
min ∑a_i (x_i )^2
in the matrix form for packages “quadprog” or “limSolve” (for this package I'm not sure if it needs to be in matrix form)?
From the discussion I have seen so far, there has been no multiplication of the quadratic term.
Let's consider a simple linearly constrained quadratic program of the form you have mentioned:
Solution with the
quadprog
packageThe
quadprog
package accepts models of the following form:To get our problem into this form, we need to construct a matrix
D
with(2*0.5 2*0.7)
as the main diagonal, as well as a matrixA
with our three constraints and a right hand sideb0
:Now we can feed this to
solve.QP
:Solution with the
limSolve
packageThe
limSolve
package'slsei
function accepts models of the following form:To obtain our objective function we need to construct matrix
A
with(sqrt(0.5) sqrt(0.7))
as the main diagonal, setb
to be the 0 vector, as well as matrices and vectors encoding the other information:Now we can feed this information to
lsei
: