rsLQR
0.1
|
This page provides some details on how to use the rsLQR solver to solve an LQR problem.
First, create a new LQRProblem with ndlqr_NewLQRProblem
Next, fill in the LQRProblem data. You can choose to define an array of LQRData structs and use ndlqr_InitializeLQRProblem(), or loop over time steps and do it yourself
Initialize a new solver
Then copy in the data from the LQRProblem
Optionally, you can also set the number of threads.
Note that this just requests the number of threads from OpenMP, but doesn't provide a guarantee that this number of threads will be provided. Check the actual number of threads afterwards with ndlqr_GetNumThreads();
Call the ndlqr_Solve() method to solve the system:
Right now the solve can't be separated between the factorization step and the solve step.
You can print the summary using
For retrieving the solution vector, you can use one of two methods:
or
Note that the second method return a Matrix whose data is still owned by the solver (avoids a memory allocation or copy). Do not free this memory and be aware that editing it will edit the data stored in the solver.
Don't forget to free the solver!