coin-or / qpOASES

Open-source C++ implementation of the recently proposed online active set strategy
GNU Lesser General Public License v2.1
376 stars 127 forks source link

Python interface, nWSR is not written by the solver #32

Closed svigerske closed 4 years ago

svigerske commented 4 years ago

Issue created by migration from Trac.

Original creator: andrea.delprete

Original creation time: 2015-01-07 18:14:17

Assignee: ferreau

Version: 3.0beta

Keywords: nWSR

It seems that when using qpOases through the python interface it is not possible to get the number of working set recalculation (WSR) performed by the solver. The variable nWSR that typically acts both as input and output variable, seems to work only as input. To reproduce the problem you can run the file interfaces/python/examples/example1b.py and see the output:

################# qpOASES -- QP NO. 1 ##################

Iter   |    StepLength    |       Info       |   nFX    

----------+------------------+------------------+--------- 0 | 9.998000e-01 | ADD BND 0 | 1
1 | 1.000000e+00 | QP SOLVED | 1

nWSR = 10

Clearly the solver converged after 2 iterations, but nWSR is 10 (which was the user-defined maximum value of WSR). Additional information:

svigerske commented 4 years ago

Comment by ferreau created at 2015-01-08 09:52:21

Thanks for reporting, we will fix this by release 3.1 within the coming weeks. We aim at providig a quick patch to you earlier than that.

svigerske commented 4 years ago

Comment by ferreau created at 2015-01-08 09:52:21

Changing assignee from ferreau to mkudruss.

svigerske commented 4 years ago

Comment by swalter created at 2015-01-08 11:15:29

Integers are immutable datatypes in Python and therefore it is impossible to change the value of the input variable nWSR.

To solve the issue and remain backward compatible, I recommend the following strategy:

nWSR can be either

1) an integer,

nWSR = 10
example.init(H, g, A, lb, ub, lbA, ubA, nWSR)

2) or a numpy.ndarray(..., dtype=int)

nWSR = numpy.array([10])
example.hotstart(H, g, A, lb, ub, lbA, ubA, nWSR)

In the latter case, nWSR[0] is updated after the function return.

Any opinions on this matter?

svigerske commented 4 years ago

Comment by swalter created at 2015-01-08 11:16:09

sorry double post

svigerske commented 4 years ago

Comment by andrea.delprete created at 2015-01-08 13:10:06

Thanks for the prompt reply! It sounds good to me.

svigerske commented 4 years ago

Comment by swalter created at 2015-01-08 15:25:38

I have implemented the proposed feature in the SVN trunk Rev 97. See https://projects.coin-or.org/qpOASES/browser/trunk/interfaces/python/examples/example1b.py for an example how to use the new API.

The possibility to use an integer for nWSR still works but is marked as deprecated. Support for it will be removed in qpOASES 4.0.

svigerske commented 4 years ago

Comment by swalter created at 2015-01-08 15:26:15

Resolution: fixed