I'm trying to solve the optimisation problem $\mathbf x^\top\mathbf A\mathbf x$ such that $x_1 + \ldots + x_n = 1$, where $\mathbf x$ is the vector of variables to be optimised and $\mathbf A$ is some arbitrary matrix.
This is of course easy to do when $x$ is of small dimension using
Minimize[{f, cons}, {x1, x2, ...}]
But when $\mathbf x$ is arbitrarily large, this does not scale up in an obvious way. I was looking for some sort of built-in quadratic optimiser similar to quadprog
in MATLAB, but there does not seem to be such a thing.
n = 5; A = RandomReal[{-1, 1}, {n, n}]; A = [email protected]; Eigenvalues@A x = Array[xc, n]; f = x.A.x; cons = Total@x == 1; NMinimize[{f, cons}, x]
$\endgroup$#/Total[#] &@LinearSolve[A + Transpose@A, Table[1, {Length@A}]]
. $\endgroup$FindMinimum
supportsMethod -> "QuadraticProgramming"
. $\endgroup$