Closed svigerske closed 4 years ago
Comment by ferreau created at 2017-03-28 08:50:21
Please provide more details on the error. Ideally, you could send us a code snippet reproducing the issue. Also any information on Matlab version and operating system may be of help.
Comment by ferreau created at 2017-03-28 08:50:21
Changing status from new to assigned.
Attachment qpoases_support.m by yutaochen created at 2017-03-28 10:35:37
Comment by yutaochen created at 2017-03-28 10:38:01
Thank you for the answer,
The error message is "ERROR (qpOASES): Invalid handle to QP instance! ".
I attached two files for you to reproduce the error.
I'm using Matlab R2016a on Windows 10.
Thank you
Comment by ferreau created at 2017-03-28 12:01:52
The qpoases_sequence function cannot be used like this. In fact, each call of this function (with first argument "h" or "m") will hotstart from the previously solved QP instance. The underlying (global!) QP object data is not thread-safe, so calling it from within a parallel loop will lead to incorrect results. I do not fully understand though, why you get the reported error (instead of just incorrect results), but could imagine that this related to using global variables within the MEX function code.
Comment by yutaochen created at 2017-03-28 13:03:38
I understand that the qpoases_sequence makes use of previous call. However, in my case, there is nothing needed from the previous call (neighter Hessian nor constraint matrix). Therefore, each call depends only on the global QP object. Is there a way to initial the QP object globally and just withdraw info from it in the parfor loop?
Comment by ferreau created at 2017-03-28 13:09:16
The global QP object also contains all internal data structures which get corrupted if multiple calls work on the same memory. One could make copies of this objected internally after initialization, but we are not planning to support this.
Comment by yutaochen created at 2017-03-28 14:18:43
A possible trick for me is to initilize N global QP objects and call qpoases_sequence in parallel on the memory of each object. According to what you said, this should work somehow. However, this results in the same error.
Comment by ferreau created at 2017-03-29 07:05:56
I would indeed expect that calling sequence to work. That's why I still suspect that parfor
and the global memory of qpOASES's mex function do not go well with each other. However, I cannot spent time further investigating this.
On the other hand, initializing many objects and then calling qpOASES_sequence
manually (NOT within a parfor
loop!) a few times for each object does not seem to bring much benefit over simply calling qpOASESE
in a parfor
loop, which you said work fine.
Comment by ferreau created at 2017-03-29 07:05:56
Changing priority from normal to low.
Comment by ferreau created at 2017-03-29 07:05:56
Changing type from user support to feature request.
Comment by ferreau created at 2017-03-31 08:29:33
Resolution: wontFix
Issue created by migration from Trac.
Original creator: yutaochen
Original creation time: 2017-03-23 14:16:03
Assignee: ferreau
Version: 3.2.0
Keywords: qpoases_sequence; parfor
Hi there, I'm using the latest version of qpoases in Matlab. I'd like to use qpoases to solve some small-scale QP problems in parallel. First I have to say that using qpoases function alone is working in a parfor loop. However, when I switch it to qpoases_sequence, there would be an error. I initialize the QP sequence outside the parfor loop, and I try to call qpoases_sequence using hot start in the parfor loop. Only lower/upper bound and the gradient of objective function are changed during the iterative procedure.
I think the problem is that qpoases_sequence is not able to obtain the available information stored outside the parfor loop.
Is there a way to run qpoases_sequence in a parfor loop?