sqpmethod gives error (although ipopt works) for NMPC code

826 views
Skip to first unread message

Işık İlber Sırmatel

unread,
Oct 6, 2016, 5:57:14 AM10/6/16
to CasADi
Hello everyone,

I am using CasADi to write NMPC code. My issue is that, the code works when I use ipopt as solver, but when I want to use sqpmethod (I only change this, everything else is the same), it gives this error:

Error using casadiMEX
qpOASES failed: Premature homotopy
termination because QP is infeasible.

Error in casadi.Function/paren (line 787)
      [varargout{1:nargout}] =
      casadiMEX(775, self, varargin{:});

Error in SwigRef/subsref (line 24)
            [varargout{1:nargout}] =
            builtin('subsref',self,substruct('.','paren','()',s.subs));

Can anyone help me by providing some intuition into why this might happen? Thank you very much.

Best regards,
Isik

Joel Andersson

unread,
Oct 6, 2016, 9:15:04 AM10/6/16
to CasADi
Hi!

"sqpmethod" is a very crude method, not polished like ipopt. It's mainly intended as a boilerplate code for writing your own solver. About the error, sounds like you're losing feasibility. Ipopt switches to a feasibility restoration phase in that case, but there is nothing like that for "sqpmethod", at least not yet.

Joel

Işık İlber Sırmatel

unread,
Oct 6, 2016, 9:37:11 AM10/6/16
to CasADi
Hi Joel,

Thank you very much for the quick reply. Although I get your point about sqpmethod, what confuses me is that, for the same configuration that gives this error with sqpmethod, I am watching the iterations of ipopt from matlab command window, and it just works perfectly fine without any warnings or messages like "entering restoration phase" etc. This lead me to assume that there were no phases taking place with ipopt.

Do you have any suggestion for me to avoid/overcome the problem? (I just want to use an sqp-based solver with CasADi, I don't plan on writing my own). Thanks a lot again.

Best,
Isik

Peter Listov

unread,
Oct 6, 2016, 10:22:01 AM10/6/16
to CasADi
Hi,

I had a chance to play around with 'sqpmethod' in CasADi a little bit. As Joel has mentioned before the code implements a quite basic approach for SQP and appears to be exposed to numerical instabilities. Did you scale your NLP? At least in my case it was the issue. 

Anyway, from my experience, although 'sqpmethod' needs slightly smaller number of iterations to converge, it's still a way slower than IPOPT. Otherwise you could try to use the interface to WORHP, which is another SQP solver. 

Best regards,
Peter  

Işık İlber Sırmatel

unread,
Oct 6, 2016, 10:34:38 AM10/6/16
to CasADi
Hi Peter,

Thank you very much for your input. Yes, I have scaled the problem properly. I'll try worhp.

Best,
Isik

Joel Andersson

unread,
Oct 6, 2016, 12:11:48 PM10/6/16
to CasADi
Hi,

It can also be related to the globalization strategy. The "sqpmethod" class uses an L1 merit function line-search. IPOPT uses a filter line-search method, which is probably the better approach. We're adding a fork of blockSQP ("blocksqp" in the develop branch) to CasADi - which is a filter line-search SQP method with block structure exploitation - but that's still not quite ready for prime-time yet. In the meantime, you can try WORHP (free for academic use) or SNOPT if you want a more polished SQP approach. Out of these two, WORHP might be better if you're problem is very sparse (similar to IPOPT) and SNOPT is probably better if your problem is only block sparse and calculating second order derivatives is very expensive.

Peter's observation above is a very good one. An SQP method might need fewer iterations than a nonlinear interior point method (like IPOPT), but each iteration is much more expensive since you're solving a QP instead of a linear system of equations. That's why an SQP often makes sense if your function evaluations (including derivative calculations) are very expensive, as is often the case with shooting type methods for optimal control. If function evaluations are cheap (typical for direct collocation type methods), an IP method like IPOPT will probably work better. That being said, an SQP method is also easier to hot-start, which is important for NMPC.

Best regards,
Joel
Reply all
Reply to author
Forward
0 new messages