rsLQR  0.1
solver.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 #include "binary_tree.h"
16 #include "cholesky_factors.h"
17 #include "linalg.h"
18 #include "lqr_problem.h"
19 #include "nddata.h"
20 
31 typedef struct {
32  double t_total_ms;
33  double t_leaves_ms;
34  double t_products_ms;
35  double t_cholesky_ms;
36  double t_cholsolve_ms;
37  double t_shur_ms;
38  int num_threads;
39 } NdLqrProfile;
40 
45 
52 
60 
66 void ndlqr_PrintProfile(NdLqrProfile* profile);
67 
75 
114 typedef struct {
115  int nstates;
116  int ninputs;
117  int nhorizon;
118  int depth;
119  int nvars;
120  OrderedBinaryTree tree;
125  NdLqrCholeskyFactors* cholfacts;
126  double solve_time_ms;
127  double linalg_time_ms;
128  NdLqrProfile profile;
130 } NdLqrSolver;
131 
142 NdLqrSolver* ndlqr_NewNdLqrSolver(int nstates, int ninputs, int nhorizon);
143 
152 
161 int ndlqr_InitializeWithLQRProblem(const LQRProblem* lqrprob, NdLqrSolver* solver);
162 
170 void ndlqr_ResetSolver(NdLqrSolver* solver);
171 
181 
187 int ndlqr_GetNumVars(NdLqrSolver* solver);
188 
200 int ndlqr_SetNumThreads(NdLqrSolver* solver, int num_threads);
201 
208 int ndlqr_GetNumThreads(NdLqrSolver* solver);
209 
218 
227 
ndlqr_GetNumVars
int ndlqr_GetNumVars(NdLqrSolver *solver)
Gets the total number of decision variables for the problem.
Definition: solver.c:211
NdLqrSolver::diagonals
Matrix * diagonals
(nhorizon,2) array of diagonal blocks (Q,R)
Definition: solver.h:121
ndlqr_NewNdLqrProfile
NdLqrProfile ndlqr_NewNdLqrProfile()
Create a profile initialized with zeros.
Definition: solver.c:11
ndlqr_CompareProfile
void ndlqr_CompareProfile(NdLqrProfile *base, NdLqrProfile *prof)
Compare two profiles, printing the comparison to stdout.
Definition: solver.c:49
ndlqr_ResetSolver
void ndlqr_ResetSolver(NdLqrSolver *solver)
Resets the rsLQR solver.
Definition: solver.c:98
NdLqrSolver::solve_time_ms
double solve_time_ms
total solve time in milliseconds.
Definition: solver.h:126
NdLqrSolver::nhorizon
int nhorizon
length of the time horizon
Definition: solver.h:117
ndlqr_PrintSolveProfile
int ndlqr_PrintSolveProfile(NdLqrSolver *solver)
Prints a summary of how long individual components took.
Definition: solver.c:224
ndlqr_CopyProfile
void ndlqr_CopyProfile(NdLqrProfile *dest, NdLqrProfile *src)
Copy the profile information to a new profile.
Definition: solver.c:25
NdLqrSolver::fact
NdData * fact
factorization
Definition: solver.h:123
NdLqrProfile
A struct describing how long each part of the solve took, in milliseconds.
Definition: solver.h:31
lqr_problem.h
Defines the LQRProblem type.
binary_tree.h
Binary tree for rsLQR algorithm.
NdLqrSolver::data
NdData * data
original matrix data
Definition: solver.h:122
NdLqrSolver::ninputs
int ninputs
number of control inputs
Definition: solver.h:116
NdLqrSolver::depth
int depth
depth of the binary tree
Definition: solver.h:118
NdLqrSolver::num_threads
int num_threads
Number of threads used by the solver.
Definition: solver.h:129
ndlqr_GetNumThreads
int ndlqr_GetNumThreads(NdLqrSolver *solver)
Get the number of threads used during the rsLQR solve.
Definition: solver.c:219
OrderedBinaryTree
The binary tree for the rsLQR solver.
Definition: binary_tree.h:64
Matrix
Represents a matrix of double-precision data.
Definition: matrix.h:71
linalg.h
Defines core linear algebra routines needed by the solvers.
NdLqrSolver::nvars
int nvars
number of decision variables (size of the linear system)
Definition: solver.h:119
NdLqrSolver
Main solver for rsLQR.
Definition: solver.h:114
ndlqr_PrintProfile
void ndlqr_PrintProfile(NdLqrProfile *profile)
Print a summary fo the profile.
Definition: solver.c:35
cholesky_factors.h
A struct for storing all of the info for the Cholesky factorization of the rsLQR solver.
ndlqr_GetProfile
NdLqrProfile ndlqr_GetProfile(NdLqrSolver *solver)
Ge the internal profile data from a solve.
Definition: solver.c:230
NdLqrSolver::nstates
int nstates
size of state vector
Definition: solver.h:115
NdLqrSolver::soln
NdData * soln
solution vector (also the initial RHS)
Definition: solver.h:124
NdData
Core storage container for the rsLQR solver.
Definition: nddata.h:83
ndlqr_SetNumThreads
int ndlqr_SetNumThreads(NdLqrSolver *solver, int num_threads)
Set the number of threads to be used during the solve.
Definition: solver.c:213
ndlqr_InitializeWithLQRProblem
int ndlqr_InitializeWithLQRProblem(const LQRProblem *lqrprob, NdLqrSolver *solver)
Initialize the solver with data from an LQR Problem.
Definition: solver.c:122
ndlqr_PrintSolveSummary
void ndlqr_PrintSolveSummary(NdLqrSolver *solver)
Prints a summary of the solve.
Definition: solver.c:196
ndlqr_NewNdLqrSolver
NdLqrSolver * ndlqr_NewNdLqrSolver(int nstates, int ninputs, int nhorizon)
Create a new solver, allocating all the required memory.
Definition: solver.c:61
ndlqr_ResetProfile
void ndlqr_ResetProfile(NdLqrProfile *prof)
Reset the profile to its initialized state.
Definition: solver.c:16
LQRProblem
Describes an LQR problem with affine terms.
Definition: lqr_problem.h:31
ndlqr_FreeNdLqrSolver
int ndlqr_FreeNdLqrSolver(NdLqrSolver *solver)
Deallocates the memory for the solver.
Definition: solver.c:108
NdLqrCholeskyFactors
Stores a list of CholeskyInfo structs for the rsLQR solver.
Definition: cholesky_factors.h:30
nddata.h
Defines the core storage types used by the rsLQR solver.