andreadelprete / expokit-cpp

4 stars 0 forks source link

Computing integral of expm #13

Open andreadelprete opened 4 years ago

andreadelprete commented 4 years ago

Hi @olimexsmart

as I mentioned in #12 , we need the computation of the integral of expm for implementing the QP-based approach to deal with friction cones in consim. Computing this matrix is rather simple, and I had already done it in the python script utils_LDS_integral.py. Basically you just need to compute the expm of a matrix that is twice as big as A, and that contains only A, zeros and ones. Then you take the top-left corner of the resulting expm. Looking at the script should be enough to understand.

Before doing anything else, I think we should provide Bilal with this method, otherwise he's blocked and cannot move forward with the development of consim. Could you implement it (in c++) here in expokit and then tell Bilal how to use it?

After this is done, we'll work on making this computation more efficient using the approach described in the pdf I posted in #12 .

olimexsmart commented 4 years ago

Hi @hammoudbilal the basic usage is the following, taken from run/runIntegralExp.cpp:

    #include "MatExpIntegral.hpp"

    MatrixXd A(2, 2);
    A << 1, 2, 3, 4;

    MatExpIntegral<double> util(2);

    MatrixXd out(2, 2);

    // util.computeExpIntegral(A, out, 5, 0.1);
    util.computeExpIntegral(A, out, 5)

It retains the functionality and usage of the Python version.

To give you an implementation ASAP at the moment it is not switchable between static and dynamic usage. In practical terms it means that at the constructor call it performs unavoidably a lot of memory allocation.

The computing method is clean from memory allocation.

I've rebased all these additions into the master branch of expokit. At the moment the repo is not super clean and tidy but everything should work fine.

hammoudbilal commented 4 years ago

perfect, thanks alot