hpipm icon indicating copy to clipboard operation
hpipm copied to clipboard

d_cond.c: Condensed hessian seems to be lower triangular + is there an option to condense x0? + what is the purpose of not condensing the last stage?

Open githubNu opened this issue 2 years ago • 2 comments

I tried out hpipm's condensing routines and it seems as if the output only contains the lower triangular and diagonal elements of the overall hessian. So I had to manually copy the elements below the diagonal to the upper part. Is this intended?

I did not want to create too many issues concerning the same function, so I just post my additional questions here, too.

The vector of optimization variables of the resulting dense QP apparently has the form [uN-1, ... u0, x0]. Since I have a large state space, eliminating x0 should give a significant speed up in the following dense QP solve. Would it make sense to create an option for this? Is there one already?

And could anyone give a hint as to what the benefits are of not condensing the last stage?

githubNu avatar Oct 18 '21 11:10 githubNu

Hi, here is the answer to your questions:

  • Yes it is intended that only the lower triangular is filled in. Actually in general in HPIPM, in case of symmetric matrices (e.g. the Hessian matrix) always only the lower triangular part is referenced too.
  • Yes you are correct about the variables order after the condensing step. The initial state removal has been implemented "recently" in a dedicated routine, you can see an example here https://github.com/giaf/hpipm/blob/master/test_problems/test_d_cond_qcqp.c (this is for QCQPs but the same functionality is available for QPs too, just this example should be more clear, I'm still in the process of updating all examples; in the example please check for the macro REMOVE_X0 to see all the steps that need to be done, such as setting the number nbxe and the index idxbxe of the states to be removed). The idea is to call this routine to eliminate x0 before the condensing step, by creating a new QP where x0 is not an optimization variable, and that is then passed as an input to condensing in a following step.
  • The condensing routines are used as building blocks to implement the partial condensing algorithm, and in that case for all blocks except the last one there is not a "last stage" to be condensed.

giaf avatar Oct 19 '21 07:10 giaf

  • Thank you, that clears things up :)
  • Another thank you for the pointer, works like a charm! Implementation only required quite some concentration to keep the overview over nbx, nbxe, idxbx and idxbxe. In the example, all of them had to be set. I thought maybe nbxe overrides nbx or something similar. Nevertheless, it works (also interfacing it via MATLAB's Simulink).
  • Ah okay, that makes sense now, too!

githubNu avatar Oct 25 '21 07:10 githubNu