Efficiency of "quadprog" in MATLAB

조회 수: 28 (최근 30일)
Trym Gabrielsen
Trym Gabrielsen 2024년 6월 27일
편집: Trym Gabrielsen 2024년 11월 7일 9:34
I need to use a QP solver for an NMPC (with SQP) scheme I am writing in MATLAB.
I am mostly writing everything from scratch, both to learn more about NMPC, and to have more control over the implementation when doing research. However, I don't really feel the need to write my own QP solver, which would probably me way less effecient than modern solvers.
Initially i figured I'd just use quadprog for simplicity, but my supervisor says that this used to be a notoriously slow solver back in the day. I was wondering if this is still the case, or if it has been improved and can compare with other solvers today?
Also, what solvers are fairly efficient and are easy to obtain and use from MATLAB? (as alternatives to quadprog, if it does don't perform well enough)
  댓글 수: 2
John D'Errico
John D'Errico 2024년 6월 27일
편집: John D'Errico 2024년 6월 27일
I would not write it yourself. You would surely do no better, and almost certainly significantly worse. Is it acceptable? You should try it out, as if it is sufficient for your problem, then all is good. If you feel it is a bottleneck, then and only then should you worry about alternatives. Never spend effort to pre-optimize your code.
If and only if you decide you need something faster because it becomes a bottleneck, then you might swap something else in, but at that point, the swap would be simple anyway.
Trym Gabrielsen
Trym Gabrielsen 2024년 6월 27일
As I said, I will not write my own. I am more curious about how it performs relative to other solvers, f.ex. From the MPC toolbox? And against other non-MATLAB solvers, that are easily available.
I thought I would ask before spending lots of time testing various solvers.
I see you point though, I’ll probably use quadprog for now.

댓글을 달려면 로그인하십시오.

답변 (1개)

Kaustab Pal
Kaustab Pal 2024년 7월 12일
I did a quick analysis between three MATLAB solvers: "mpcActiveSetSolver", "mpcInteriorPointOptions", and "quadprog". Utilizing these solvers, I solved the same example problem, which you can access here: Example Problem Link.
The results revealed that in terms of speed, "mpcInteriorPointSolver" outperforms "mpcActiveSetSolver", which, in turn, is faster than "quadprog". This ranking may assist you in selecting the most efficient solver for your NMPC scheme. It's important to note that the solver's speed can also vary based on the specific problem you are addressing. For further details, you can explore more about these solvers here.
Hope this helps
  댓글 수: 1
Trym Gabrielsen
Trym Gabrielsen 2024년 11월 7일 9:33
편집: Trym Gabrielsen 2024년 11월 7일 9:34
Hi, again, thanks for your input! (sorry for the late repy)
I have now the following in my NMPC implementation:
I tested them on a CSTR process model, and Cart+Pendulum system, in an NMPC setting with a self-written SQP solver. In my simulations, the mpc-toolbox solvers are actually not very good, and quadprog outperforms them. The quadprog - IP method is very consistent and reliable, and the quadprog - AS method is faster, but also tend to be less consistent (likely due to active set changes). The quadprog - TR method is also very fast, but does not really handle inequality constraints.
The QPALM is a consistent IP solver, and is more than twice as fast as quadprog - IP, but slover than the quadprog - AS method, when the AS method is warm started.
Also, for some problem formulations, the QPALM solver gave an error and MATLAB instantly crashed. I said something about the matrix having a large/small diagonal entry (don't remenber exactly). Didn't figure out what happened, since every time it happened, MATLAB said good night...
Mostly, QPALM is very good, and I'll probably continue with that for now.
All in all, there is no major difference in the build in MATLAB solvers, and even QPALM is within the same order of magnitude, so one can easily use quadprog for development purposes.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Linear Plant Specification에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by