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)
## 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,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)
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
## Copyright (C) 1999 by Peter J. Gawthrop
## $Id$
if nargin<9
mu = 0
endif
## Check the sizes
n_x = length(x);
[n_U,m_U] = size(J_uu);
if n_U != m_U
error("J_uu must be square");
endif
[n,m] = size(J_ux);
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);
##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;
|
>
>
>
>
|
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
## Copyright (C) 1999 by Peter J. Gawthrop
## $Id$
if nargin<9
mu = 0
endif
if nargin<10
test=0;
endif
## Check the sizes
n_x = length(x);
[n_U,m_U] = size(J_uu);
if n_U != m_U
error("J_uu must be square");
endif
[n,m] = size(J_ux);
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;
|