shamilmamedov / prde_solver

The Periodic Differential Riccati Equation solver
3 stars 1 forks source link

Python port #1

Closed drewhamiltonasdf closed 1 year ago

drewhamiltonasdf commented 1 year ago

Heya,

Working on a Python, and maybe C++ port of this code, wondering if you would like me to pull-request when I'm done or just attribute to you wherever it shows up. This is purely for research and fiddling around with moving-sections LQR, and lately I prefer Python...

I could also just keep my Pythonified version private, but I thought I'd share it back with you since it will essentially be a line-by-line port of your code.

Best, Drew

shamilmamedov commented 1 year ago

Hey Drew,

I would be happy if pull-request when you are done porting the code into python.

Shamil

drewhamiltonasdf commented 1 year ago

Hey Drew,

I would be happy if pull-request when you are done porting the code into python.

Shamil

Glad to here it! I really don't intend on making any structural changes, though I can see a few bits that might need some cleverness. The aim is to get it to spit out answers identical to Matlab to machine precision.

Thanks again for this work. It's little repositories like this that constantly renew my faith in humanity.

If all goes according to plan, I'll be done pretty soon.

drewhamiltonasdf commented 1 year ago

Hey, so I managed to get results that match your benchmark example in Python to machine precision! I'll polish things up and do a pull-request this weekend. I'm going to see which solvers in CVXPY can handle this. I was doing it with MOSEK, but it would be nice to have some open-source options.

Just curious... after a massive amount of head-scratching (literally hours), I removed the two constraints:

constraints.append(xt >= -dnp.eye(n)) constraints.append(xt <= dnp.eye(n))

Where d=1e+5, and I finally got solves out of MOSEK. Is there an explanation for this?

Either way, this weekend I'll close this gitHub issue and send you something to look over.

Best, Drew

shamilmamedov commented 1 year ago

Hey Drew,

Congratulations, well done!

If I remember correctly, I set those constraints to constrain the values inside matrix coefficients of the polynomial. If the values are too big it might cause some numerical issues in the closed loop simulation of the system.

drewhamiltonasdf commented 1 year ago

Thanks. Appreciate your doing all the hard work. I'll be using it for some things I'm working on, so I'll keep you updated if I add/update/improve anything or port to C++.

Best, Drew