1
2
3
4
5
6
7
8
|
function [u,U,iterations] = ppp_qp (x,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma,mu,test)
## usage: [u,U] = ppp_qp (x,W,J_uu,J_ux,J_uw,Gamma,gamma)
## INPUTS:
## x: system state
## W: Setpoint vector
## J_uu,J_ux,J_uw: Cost derivatives (see ppp_lin)
## Us0: value of U* at tau=0 (see ppp_lin)
|
|
|
1
2
3
4
5
6
7
8
|
function [u,U,n_active] = ppp_qp (x,W,J_uu,J_ux,J_uw,Us0,Gamma,gamma,mu,test)
## usage: [u,U] = ppp_qp (x,W,J_uu,J_ux,J_uw,Gamma,gamma)
## INPUTS:
## x: system state
## W: Setpoint vector
## J_uu,J_ux,J_uw: Cost derivatives (see ppp_lin)
## Us0: value of U* at tau=0 (see ppp_lin)
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
if (n != n_U)||(m != n_x)
error("J_ux should be %ix%i not %ix%i",n_U,n_x,n,m);
endif
if length(gamma)>0 # Constraints exist: do the QP algorithm
## QP solution for weights U
[U,iterations] = qp_mu(J_uu,(J_ux*x - J_uw*W),Gamma,gamma,mu,[],[],0,test);
##U = qp(J_uu,(J_ux*x - J_uw*W),Gamma,gamma); # QP solution for weights U
##U = pd_lcp04(J_uu,(J_ux*x - J_uw*W),Gamma,gamma); # QP solution for weights U
u = Us0*U; # Control signal
else # Do the unconstrained solution
## Compute the open-loop gains
iterations = 0;
K_w = J_uu\J_uw;
K_x = J_uu\J_ux;
## Closed-loop control
U = K_w*W - K_x*x; # Basis functions weights - U(t)
u = Us0*U; # Control u(t)
endif
endfunction
|
>
|
>
|
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
if (n != n_U)||(m != n_x)
error("J_ux should be %ix%i not %ix%i",n_U,n_x,n,m);
endif
if length(gamma)>0 # Constraints exist: do the QP algorithm
## QP solution for weights U
## [U,iterations] = qp_mu(J_uu,(J_ux*x-J_uw*W),Gamma,gamma,mu,[],[],0,test);
[U,n_active] = qp_hild(J_uu,(J_ux*x - J_uw*W),Gamma,gamma); #
## iterations = 0;
##U = qp(J_uu,(J_ux*x - J_uw*W),Gamma,gamma); # QP solution for weights U
##U = pd_lcp04(J_uu,(J_ux*x - J_uw*W),Gamma,gamma); # QP solution for weights U
u = Us0*U; # Control signal
else # Do the unconstrained solution
## Compute the open-loop gains
n_active = 0;
K_w = J_uu\J_uw;
K_x = J_uu\J_ux;
## Closed-loop control
U = K_w*W - K_x*x; # Basis functions weights - U(t)
u = Us0*U; # Control u(t)
endif
endfunction
|