Why does fmincon using the sqp algorithm need a full matrix to specify linear constraints?
Show older comments
I need to specify that some of the variables in my optimization need to be ordered, so v_i-v_(i+1)<0 for i = N_1 to N_2. This is easy to set up in fmincon, in the form Av<b, but, as you can see, the algorithm can't take a sparse input for A. In a large problem like the one I'm solving, this gives me about a 1000 by 4000 matrix that has only 2000 nonzero entries, which seems crazy to me.
I know I could reformulate the problem so that I use the differences in variables instead (and I will probably have to end up doing this), which gets around the problem but (i) this makes the calculation of the gradient more awkward and (ii) I can see no good reasonnot to allow a sparse A.
So, my question is, is there a good reason for this 'feature'?
Accepted Answer
More Answers (1)
John D'Errico
on 20 Mar 2023
0 votes
This sounds like a good excuse for a feature request to me. However, my gut tells me there is a technical reason in the algorithm itself (possibly in terms of how it was implemented) that precludes a sparse matrix for the linear constraints. And, unfortunately, we cannot look into the code itself, since sqpInterface is p-coded. If I had to make a wild guess, the issue comes down to the fact that QR (used to) behave subtly differently for sparse versus full matrices. I recall that in the past, you could not use QR to get a pivoted economy QR factorization when the matrix was sparse. This is not the case today. So this may possibly be only an issue that was true for past releases, and need not be true today, but someone would need to dive into the fmincon code and make the necessry changes.
Anyway, the best way to get a good answer for this would need to come from TMW directly. And the best way to get that is to contact them directly.
Categories
Find more on Linear Least Squares 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!