#include <lq_oc_single_shooting.h>
Public Types | |
typedef qpOASES::real_t | real_t |
typedef dlib::matrix< real_t, N, N > | t_Ad |
number of linear system constraints in QP: upper and lower bounds for x and u separately due to slack More... | |
typedef dlib::matrix< real_t, N, R > | t_Bd |
discrete time system matrix future version: one Ad,Bd per time step More... | |
typedef adore::mad::LLinearPiecewiseFunctionM< double, N+R > | t_resultfun |
discrete time input matrix More... | |
typedef dlib::matrix< real_t, N, 1 > | t_wx |
function for result interpolation More... | |
typedef dlib::matrix< real_t, N, 1 > | t_wx_end |
weights for states (will be put on main diagonal of Hx) More... | |
typedef dlib::matrix< real_t, R, 1 > | t_wu |
weights for states at endpoint More... | |
typedef dlib::matrix< real_t, R, 1 > | t_wu_end |
weights for inputs (will be put on main diagonal of Hu) More... | |
typedef dlib::matrix< real_t, N, 1 > | t_weps |
weights for inputs at endpoint More... | |
typedef dlib::matrix< real_t, N, 1 > | t_geps |
quadratic weights for slack (will be put in Heps) More... | |
typedef dlib::matrix< real_t, N, K > | t_lbx |
linear weights for slack More... | |
typedef dlib::matrix< real_t, N, K > | t_ubx |
lower bound on state trace More... | |
typedef dlib::matrix< real_t, R, K > | t_lbu |
upper bound on state trace More... | |
typedef dlib::matrix< real_t, R, K > | t_ubu |
lower bound on input trace More... | |
typedef dlib::matrix< real_t, R, K > | t_lbu_hard |
upper bound on input trace More... | |
typedef dlib::matrix< real_t, R, K > | t_ubu_hard |
lower bound on input trace, hard constraint going to lb More... | |
typedef dlib::matrix< real_t, N, 1 > | t_ubeps |
upper bound on input trace, hard constraint going to ub More... | |
typedef dlib::matrix< real_t, N, 1 > | t_x0 |
lbeps==0, softconstraints for x and/or u if ubeps>0 More... | |
typedef dlib::matrix< real_t, N, K > | t_y |
initial state More... | |
typedef dlib::matrix< real_t, N *K, 1 > | t_y_flat |
desired states (reference) y=[y_0(t_1);y_1(t_1);y_2(t_1);y_0(t_2);y_1(t_2);y_2(t_2);...;y_0(t_K);y_1(t_K);y_2(t_K)] (for N=3) More... | |
typedef dlib::matrix< real_t, R, K > | t_uset |
desired states (reference) y=[y_0(t_1);y_1(t_1);y_2(t_1);y_0(t_2);y_1(t_2);y_2(t_2);...;y_0(t_K);y_1(t_K);y_2(t_K)] (for N=3) More... | |
typedef dlib::matrix< real_t, R *K, 1 > | t_uset_flat |
set point More... | |
typedef dlib::matrix< real_t, R, K > | t_U |
set point More... | |
typedef dlib::matrix< real_t, R *K, 1 > | t_U_flat |
the computed control [u(t_0),...,u(t_K-1)] More... | |
typedef dlib::matrix< real_t, N, K+1 > | t_X |
the computed control [u(t_0),...,u(t_K-1)] More... | |
typedef dlib::matrix< real_t, N *(K+1), 1 > | t_X_flat |
the computed states [x(t_1),..., x(t_K)] More... | |
typedef dlib::matrix< real_t, N, 1 > | t_eps |
the computed states [x(t_1),..., x(t_K)] More... | |
Public Member Functions | |
LQ_OC_single_shooting () | |
virtual | ~LQ_OC_single_shooting () |
void | compute () |
bool | isFeasible () const |
bool | isSolved () const |
void | updateSystem (const t_Ad &Ad, const t_Bd &Bd, const t_wx &wx, const t_wu &wu) |
void | updateSystem (const t_Ad &Ad, const t_Bd &Bd, const t_wx &wx, const t_wu &wu, const t_weps &weps) |
void | updateSystem (const t_Ad &Ad, const t_Bd &Bd, const t_wx &wx, const t_wu &wu, const t_weps &weps, const t_geps &geps) |
void | update (const t_x0 &x0, const t_y &y, const t_lbx &lbx, const t_ubx &ubx, const t_lbu_hard &lbu_hard, const t_ubu_hard &ubu_hard, const t_ubeps &ubeps) |
void | update (const t_x0 &x0, const t_y &y, const t_lbx &lbx, const t_ubx &ubx) |
void | setSystemChanged (bool value) |
void | setEndTime (double Tend) |
t_Ad & | Ad () |
t_Bd & | Bd () |
t_Ad & | Ad_p () |
t_Bd & | Bd_p () |
t_resultfun & | result_fun () |
t_wx & | wx () |
t_wu & | wu () |
t_wx_end & | wx_end () |
t_wu_end & | wu_end () |
t_weps & | weps () |
t_geps & | geps () |
t_lbx & | lbx () |
t_ubx & | ubx () |
t_lbu_hard & | lbu_hard () |
t_ubu_hard & | ubu_hard () |
t_ubeps & | ubeps () |
t_x0 & | x0 () |
t_y & | y () |
t_uset & | uset () |
t_X & | X () |
t_U & | U () |
t_eps & | eps () |
real_t | getCPUTime () |
int | getnWSR () |
qpOASES::QProblem * | getQProblem () |
void | setMaxCPUTime (real_t value) |
void | setMaxnWSR (int value) |
int | getnV () |
int | getnC () |
Static Public Attributes | |
static const int | nV = R*K + N |
static const int | nC = 2*N*K |
number of variables in the QP: var=[u;eps] More... | |
Private Member Functions | |
void | initialize_userdata_matrices () |
qpOASES: "If cputime is not the null pointer, it contains the maximum allowed CPU time in seconds for the whole initialisation (and the actually required one on output)." More... | |
void | initialize_memory () |
void | delete_memory () |
void | initialize_interface_variables () |
void | initialize_intermediate_matrices () |
void | updateAd () |
void | updateE () |
void | updateF () |
void | updateHx () |
Hx:=diag(wx) More... | |
void | updateHu () |
Hu:=diag(wu) More... | |
void | updateHeps () |
Heps:=diag(weps);. More... | |
void | updateg1 () |
void | updateH11 () |
void | updateA1 () |
void | updateA2 () |
int | idx (int row, int col, int nrows, int ncols) const |
void | updateqpH () |
void | updateqpg () |
void | updateqpA () |
void | updateqplb () |
void | updateqpub () |
void | updateqpubA () |
void | compute_init () |
void | compute_hotstart () |
void | retrieveSolution () |
void | interpolateSolution () |
Private Attributes | |
bool | m_system_changed |
the slack More... | |
t_Ad | m_Ad |
t_Bd | m_Bd |
discrete time system matrix future version: one Ad,Bd per time step More... | |
t_Ad | m_Ad_p |
discrete time input matrix More... | |
t_Bd | m_Bd_p |
system matrix for interpolation More... | |
std::vector< t_Ad * > | m_Ad_powers |
input matrix for interpolation More... | |
t_resultfun | m_resultfun |
powers of Ad, so these don't have to be recomputed online More... | |
t_wx | m_wx |
t_wx_end | m_wx_end |
weights for states (will be put on main diagonal of Hx) More... | |
t_wu | m_wu |
weights for states at endpoint More... | |
t_wu_end | m_wu_end |
weights for inputs (will be put on main diagonal of Hu) More... | |
t_weps | m_weps |
weights for inputs at endpoint More... | |
t_geps | m_geps |
quadratic weights for slack (will be put in Heps) More... | |
t_lbx | m_lbx |
linear weights for slack More... | |
t_ubx | m_ubx |
lower bound on state trace More... | |
t_lbu_hard | m_lbu_hard |
upper bound on state trace More... | |
t_ubu_hard | m_ubu_hard |
lower bound on input trace, hard constraint going to lb More... | |
t_ubeps | m_ubeps |
upper bound on input trace, hard constraint going to ub More... | |
t_x0 | m_x0 |
lbeps==0, softconstraints for x and/or u if ubeps>0 More... | |
t_y | m_y |
initial state More... | |
t_y_flat | m_y_flat |
desired states (reference) y=[y_0(t_1);y_1(t_1);y_2(t_1);y_0(t_2);y_1(t_2);y_2(t_2);...;y_0(t_K);y_1(t_K);y_2(t_K)] (for N=3) More... | |
t_U | m_U |
desired states (reference) y=[y_0(t_1);y_1(t_1);y_2(t_1);y_0(t_2);y_1(t_2);y_2(t_2);...;y_0(t_K);y_1(t_K);y_2(t_K)] (for N=3) More... | |
t_U_flat | m_U_flat |
the computed control [u(t_0),...,u(t_K-1)] More... | |
t_X | m_X |
t_X_flat | m_X_flat |
the computed states [x(t_1),..., x(t_K)] More... | |
t_eps | m_eps |
t_uset | m_uset |
t_uset_flat | m_uset_flat |
set point More... | |
dlib::matrix< real_t, N *K, 1 > | m_E |
set point More... | |
dlib::matrix< real_t, N *K, R *K > | m_F |
[pow(Ad,1);pow(Ad,2);...;pow(Ad,k)]*x0 More... | |
dlib::matrix< real_t, N *K, N *K > | m_Hx |
[B,0,0,..0;AB,B,0,...0;AAB,AB,B,...,0;...;pow(A,k-1)B,pow(A,k-2)B,pow(A,k-3),B,...,B] More... | |
dlib::matrix< real_t, R *K, R *K > | m_Hu |
dlib::matrix< real_t, N, N > | m_Heps |
dlib::matrix< real_t, R *K, 1 > | m_g1 |
dlib::matrix< real_t, R *K, R *K > | m_H11 |
first part of overall linear cost term, g=[F^T Hx E - F^T Hx y; geps]=[g1;geps] More... | |
dlib::matrix< real_t, N *K, nV > | m_A1 |
upper left part of overal quadratic cost term H=[Hu + F^T Hx F, 0; 0, Heps]=[H11,0;0,Heps] More... | |
dlib::matrix< real_t, N *K, nV > | m_A2 |
state soft constraints equation upper bound More... | |
qpOASES::QProblem * | m_qproblem |
state soft constraints equation lower bound More... | |
real_t | m_qpH [nV *nV] |
real_t | m_qpg [nV] |
real_t | m_qpA [nC *nV] |
real_t | m_qplb [nV] |
real_t | m_qpub [nV] |
real_t | m_qplbA [nC] |
real_t | m_qpubA [nC] |
real_t | m_qpxOpt [nV] |
qpOASES::int_t | m_qpnWSR_in |
qpOASES::int_t | m_qpnWSR_out |
qpOASES: "The integer argument nWSR species the maximum number of working set recalculations to be performed during the initial homotopy" More... | |
real_t | m_qpcputime_in |
qpOASES: "The integer argument nWSR species the maximum number of working set recalculations to be performed during the initial homotopy" More... | |
real_t | m_qpcputime_out |
qpOASES: "If cputime is not the null pointer, it contains the maximum allowed CPU time in seconds for the whole initialisation (and the actually required one on output)." More... | |
LQ_OC_single_shooting - solves finite horizon linear quadratic optimal control problem with qpOASES and single shooting approach. The optimization variable [u0,u1,u2,...,u(k-1), eps] is used, with eps the slack in x dimensions used for soft-constraints. J= 1/2 (x-y)^T H(wx) (x-y) + 1/2 u^T H(wu) u + 1/2 eps^T H(weps) eps + eps^T geps N is the number of states, R is the number of inputs, K is the number of time steps during optimization and P is the number of interpolation steps.
typedef qpOASES::real_t adore::mad::LQ_OC_single_shooting< N, R, K, P >::real_t |
typedef dlib::matrix<real_t,N,N> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_Ad |
number of linear system constraints in QP: upper and lower bounds for x and u separately due to slack
typedef dlib::matrix<real_t,N,R> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_Bd |
discrete time system matrix future version: one Ad,Bd per time step
typedef dlib::matrix<real_t,N,1> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_eps |
the computed states [x(t_1),..., x(t_K)]
typedef dlib::matrix<real_t,N,1> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_geps |
quadratic weights for slack (will be put in Heps)
typedef dlib::matrix<real_t,R,K> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_lbu |
upper bound on state trace
typedef dlib::matrix<real_t,R,K> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_lbu_hard |
upper bound on input trace
typedef dlib::matrix<real_t,N,K> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_lbx |
linear weights for slack
typedef adore::mad::LLinearPiecewiseFunctionM<double,N+R> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_resultfun |
discrete time input matrix
typedef dlib::matrix<real_t,R,K> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_U |
set point
typedef dlib::matrix<real_t,R*K,1> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_U_flat |
the computed control [u(t_0),...,u(t_K-1)]
typedef dlib::matrix<real_t,N,1> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_ubeps |
upper bound on input trace, hard constraint going to ub
typedef dlib::matrix<real_t,R,K> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_ubu |
lower bound on input trace
typedef dlib::matrix<real_t,R,K> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_ubu_hard |
lower bound on input trace, hard constraint going to lb
typedef dlib::matrix<real_t,N,K> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_ubx |
lower bound on state trace
typedef dlib::matrix<real_t,R,K> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_uset |
desired states (reference) y=[y_0(t_1);y_1(t_1);y_2(t_1);y_0(t_2);y_1(t_2);y_2(t_2);...;y_0(t_K);y_1(t_K);y_2(t_K)] (for N=3)
typedef dlib::matrix<real_t,R*K,1> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_uset_flat |
set point
typedef dlib::matrix<real_t,N,1> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_weps |
weights for inputs at endpoint
typedef dlib::matrix<real_t,R,1> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_wu |
weights for states at endpoint
typedef dlib::matrix<real_t,R,1> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_wu_end |
weights for inputs (will be put on main diagonal of Hu)
typedef dlib::matrix<real_t,N,1> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_wx |
function for result interpolation
typedef dlib::matrix<real_t,N,1> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_wx_end |
weights for states (will be put on main diagonal of Hx)
typedef dlib::matrix<real_t,N,K+1> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_X |
the computed control [u(t_0),...,u(t_K-1)]
typedef dlib::matrix<real_t,N,1> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_x0 |
lbeps==0, softconstraints for x and/or u if ubeps>0
typedef dlib::matrix<real_t,N*(K+1),1> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_X_flat |
the computed states [x(t_1),..., x(t_K)]
typedef dlib::matrix<real_t,N,K> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_y |
initial state
typedef dlib::matrix<real_t,N*K,1> adore::mad::LQ_OC_single_shooting< N, R, K, P >::t_y_flat |
desired states (reference) y=[y_0(t_1);y_1(t_1);y_2(t_1);y_0(t_2);y_1(t_2);y_2(t_2);...;y_0(t_K);y_1(t_K);y_2(t_K)] (for N=3)
|
inline |
constructor
|
inlinevirtual |
destructor
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
execute optimization for given constraints and reference
|
inlineprivate |
compute_hotstart - hotstart call to the qp solver: can only be used, if the quadratic term and the system dynamics have not changed. lower and upper bound values, linear cost terms, initial state may be modified before re-computing with hotstart. a reduced set of variables has to be provided to the qp solver, under the assumption that the other variables have not changed.
|
inlineprivate |
compute_init - initial call to the qp solver: all information for description of the qp has to be provided
|
inlineprivate |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
initialize intermediate matrices with constants 0,1,-1, especially parts which are constant and not modified by updates
A1 := [F [-I;-I;-I;...-I] 0] --> x upper bound soft constraint
A2 := [F [I;I;I;...I] 0] --> x lower bound soft constraint
|
inlineprivate |
|
inlineprivate |
qpOASES: "If cputime is not the null pointer, it contains the maximum allowed CPU time in seconds for the whole initialisation (and the actually required one on output)."
|
inlineprivate |
interpolate the solution using Ad_p and Bd_p
|
inline |
determine whether qpOASES deems problem feasible
|
inline |
determine whether qpOASES deems problem solved to given precision
|
inline |
|
inline |
|
inline |
|
inlineprivate |
retrieve solution from qpOASES
|
inline |
redefine time steps according to supplied end time Tend
|
inline |
|
inline |
|
inline |
recompute without hotstart
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
change initial value, reference and bounds
|
inline |
change initial value, reference and bounds
|
inlineprivate |
A1 := [F [-I;-I;-I;...-I] 0] --> x upper bound soft constraint (set F part here)
|
inlineprivate |
A2 := [F [I;I;I;...I] 0] --> x lower bound soft constraint
(set F part here)
|
inlineprivate |
|
inlineprivate |
E:=[pow(Ad,1) pow(Ad,2) : pow(Ad,k)]*x0
|
inlineprivate |
F:=[ B, 0, 0,... 0 AB, B, 0,... 0; AAB,AB, B,...,0; : pow(A,k-1)B,pow(A,k-2)B,pow(A,k-3),B,...,B], so that X=E+F*U
|
inlineprivate |
g1:= F^T Hx E - F^T Hx y
|
inlineprivate |
H11 := Hu + F^T Hx F
|
inlineprivate |
Heps:=diag(weps);.
|
inlineprivate |
Hu:=diag(wu)
|
inlineprivate |
Hx:=diag(wx)
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inline |
change the system
|
inline |
change the system
|
inline |
change the system
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
upper left part of overal quadratic cost term H=[Hu + F^T Hx F, 0; 0, Heps]=[H11,0;0,Heps]
|
private |
state soft constraints equation upper bound
|
private |
|
private |
discrete time input matrix
|
private |
input matrix for interpolation
|
private |
discrete time system matrix future version: one Ad,Bd per time step
|
private |
system matrix for interpolation
|
private |
set point
|
private |
|
private |
[pow(Ad,1);pow(Ad,2);...;pow(Ad,k)]*x0
|
private |
|
private |
quadratic weights for slack (will be put in Heps)
|
private |
first part of overall linear cost term, g=[F^T Hx E - F^T Hx y; geps]=[g1;geps]
|
private |
|
private |
|
private |
[B,0,0,..0;AB,B,0,...0;AAB,AB,B,...,0;...;pow(A,k-1)B,pow(A,k-2)B,pow(A,k-3),B,...,B]
|
private |
upper bound on state trace
|
private |
linear weights for slack
|
private |
|
private |
qpOASES: "The integer argument nWSR species the maximum number of working set recalculations to be performed during the initial homotopy"
|
private |
qpOASES: "If cputime is not the null pointer, it contains the maximum allowed CPU time in seconds for the whole initialisation (and the actually required one on output)."
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
qpOASES: "The integer argument nWSR species the maximum number of working set recalculations to be performed during the initial homotopy"
|
private |
state soft constraints equation lower bound
|
private |
|
private |
|
private |
|
private |
powers of Ad, so these don't have to be recomputed online
|
private |
the slack
|
private |
desired states (reference) y=[y_0(t_1);y_1(t_1);y_2(t_1);y_0(t_2);y_1(t_2);y_2(t_2);...;y_0(t_K);y_1(t_K);y_2(t_K)] (for N=3)
|
private |
the computed control [u(t_0),...,u(t_K-1)]
|
private |
upper bound on input trace, hard constraint going to ub
|
private |
lower bound on input trace, hard constraint going to lb
|
private |
lower bound on state trace
|
private |
|
private |
set point
|
private |
weights for inputs at endpoint
|
private |
weights for states at endpoint
|
private |
weights for inputs (will be put on main diagonal of Hu)
|
private |
|
private |
weights for states (will be put on main diagonal of Hx)
|
private |
|
private |
lbeps==0, softconstraints for x and/or u if ubeps>0
|
private |
the computed states [x(t_1),..., x(t_K)]
|
private |
initial state
|
private |
desired states (reference) y=[y_0(t_1);y_1(t_1);y_2(t_1);y_0(t_2);y_1(t_2);y_2(t_2);...;y_0(t_K);y_1(t_K);y_2(t_K)] (for N=3)
|
static |
number of variables in the QP: var=[u;eps]
|
static |