Matrix version of quadprog?
Show older comments
I have a standard quadratic programming problem with equality constraint as outlined here, except that instead of vector x, I am optimizing over matrix X, whose each row is a data point. The objective function is tr(X^THX).
quadprog seems to be unable to handle matrix X. Am I missing something, or I have to go find some unofficial packages? If so, can one point me to such a solver?
Accepted Answer
More Answers (1)
John D'Errico
on 30 Jun 2016
This problem is not a form that quadprog can solve. You can write it in a more computationally efficient way though as an objective function, perhaps something that fmincon could use.
f = sum(sum(X.*(H*X),1));
This computes ONLY the diagonal elements that are needed in the trace, then sums them. For example:
X = randn(1000,1000);
H = rand(1000,1000);
timeit(@() trace(X'*H*X))
ans =
0.10347
timeit(@() sum(sum(X.*(H*X),1)))
ans =
0.053614
trace(X'*H*X)
ans =
5.0902e+05
sum(sum(X.*(H*X),1))
ans =
5.0902e+05
As you can see, the two results are the same, but one is a bit faster than the other.
1 Comment
Eric Zhang
on 1 Jul 2016
Categories
Find more on Quadratic Programming and Cone Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!