Overview
Comment:Compatible with Octave 2.1.57
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 217980763901b91095ac74809f7fb9c0edd8e16d622a40134be2e030ea041678
User & Date: gawthrop@users.sourceforge.net on 2004-08-09 14:44:41
Other Links: branch diff | manifest | tags
Context
2004-08-09
14:47:28
Changed arg to args to avoid strange octave bug check-in: e0b4cd14a7 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
14:44:41
Compatible with Octave 2.1.57 check-in: 2179807639 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
2004-08-05
09:07:51
Sorts by type:name within categories: ports, components, 0, 1 check-in: 649ef6492a user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/lib/control/PPP/ppp_ex15.m from [d1ae59f7c7] to [f570a84dcf].

38
39
40
41
42
43
44

45
46
47
48
49
50
51
52
  x_0 = zeros(n_x,1);		# Initial state


  ## Closed-loop intermittent solution
  Delta_ol = 0.5		# Intermittent time

  disp("Intermittent control simulation");

  [T,y,u] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q, \
			  [],[],[],[], \
			  [],[],[],[],W,x_0,Delta_ol);
size(T)
  ## Exact closed-loop
  disp("Exact closed-loop");
  [k_x,k_w] = ppp_lin (A,B,C,D,A_u,A_w,t,Q)
  [ye,Xe] = ppp_sm2sr(A-B*k_x, B, C, D, T, k_w*W, x_0); # Compute Closed-loop control







>
|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  x_0 = zeros(n_x,1);		# Initial state


  ## Closed-loop intermittent solution
  Delta_ol = 0.5		# Intermittent time

  disp("Intermittent control simulation");
  R=1;P=0;
  [T,y,u] = ppp_qp_sim (A,B,C,D,A_u,A_w,t,Q,R,P, \
			  [],[],[],[], \
			  [],[],[],[],W,x_0,Delta_ol);
size(T)
  ## Exact closed-loop
  disp("Exact closed-loop");
  [k_x,k_w] = ppp_lin (A,B,C,D,A_u,A_w,t,Q)
  [ye,Xe] = ppp_sm2sr(A-B*k_x, B, C, D, T, k_w*W, x_0); # Compute Closed-loop control

Modified mttroot/mtt/lib/control/PPP/ppp_inflate.m from [7743bb793c] to [c4fc3a116e].

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

  if N<M
    error("A_v must have at least as many rows as columns");
  endif
  
  n = N/M;			# Number of matrix elements in A_v

  if round(n)<>n
    error("A_v must be a column vector of square matrices");
  endif
  
  A_m = [];
  for i = 1:n
    A_m = ppp_aug(A_m,ppp_extract(A_v,i));
  endfor

endfunction







|









11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

  if N<M
    error("A_v must have at least as many rows as columns");
  endif
  
  n = N/M;			# Number of matrix elements in A_v

  if round(n)!=n
    error("A_v must be a column vector of square matrices");
  endif
  
  A_m = [];
  for i = 1:n
    A_m = ppp_aug(A_m,ppp_extract(A_v,i));
  endfor

endfunction

Modified mttroot/mtt/lib/control/PPP/ppp_lin.m from [4162496ee0] to [2f56086151].

165
166
167
168
169
170
171
172

173
174
175
176
177
178
179
    J_ux = J_ux + (QQ .* y_u(:,i:n_y:n_yu)') * y_x(:,i:n_y:n_yx);
    QQ = ones(n_x,1)*Q(i,:);	# Resize Q
    J_xx = J_xx + (QQ .* y_x(:,i:n_y:n_yx)') * y_x(:,i:n_y:n_yx);
  endfor

  ## Input weighting (scalar for the moment)
  if (n_u>1)
    warning("Sorry, cant do n_u>1 just now");

  endif

  ## Scale R
  R = R*dt;			# Scale to give correct units
  for i = 1:m_t
    Ust = Us(i,:);
    J_uu = J_uu + Ust'*R*Ust;







|
>







165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
    J_ux = J_ux + (QQ .* y_u(:,i:n_y:n_yu)') * y_x(:,i:n_y:n_yx);
    QQ = ones(n_x,1)*Q(i,:);	# Resize Q
    J_xx = J_xx + (QQ .* y_x(:,i:n_y:n_yx)') * y_x(:,i:n_y:n_yx);
  endfor

  ## Input weighting (scalar for the moment)
  if (n_u>1)
    warning("Sorry, cant do n_u>1 just now: exiting");
    return
  endif

  ## Scale R
  R = R*dt;			# Scale to give correct units
  for i = 1:m_t
    Ust = Us(i,:);
    J_uu = J_uu + Ust'*R*Ust;

Modified mttroot/mtt/lib/control/PPP/ppp_lin_quad.m from [b791777adb] to [56182147a4].

1
2
3
4
5
6
7
8
9
10





11


12
13
14
15
16
17
18
function [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,A_u] = \
      ppp_lin_quad (A,B,C,D,tau,Q,R)

  ## usage:[k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,A_u] =
  ## ppp_lin_quad (A,B,C,D,tau,Q,R)
  ##
  ## 

  ## Steady-state Linear Quadratic solution
  ## using Algebraic Riccati equation (ARE)





  [P,A_u,A_w] = ppp_are (A,B,C,D,Q,R);



  ## PPP solution
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww] = \
      ppp_lin(A,B,C,D,A_u,A_w,tau,Q,R,P);


endfunction

|


|





>
>
>
>
>

>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,A_u] = \
      ppp_lin_quad (A,B,C,D,tau,Q,R,A_e)

  ## usage:[k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww,A_u] =
  ## ppp_lin_quad (A,B,C,D,tau,Q,R[,A_e])
  ##
  ## 

  ## Steady-state Linear Quadratic solution
  ## using Algebraic Riccati equation (ARE)

  if nargin<8
    A_e = [];
  endif
  
  [P,A_u,A_w] = ppp_are (A,B,C,D,Q,R);

  A_u = ppp_aug(A_u,A_e);

  ## PPP solution
  [k_x,k_w,K_x,K_w,Us0,J_uu,J_ux,J_uw,J_xx,J_xw,J_ww] = \
      ppp_lin(A,B,C,D,A_u,A_w,tau,Q,R,P);


endfunction

Modified mttroot/mtt/lib/control/PPP/ppp_open2closed.m from [f6b3aefde7] to [06ac18219c].

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  ## 	$Id$	


  ## Check sizes
  n_o = is_square(A_u);
  n_c = is_square(A_c);

  if (n_o==0)||(n_c==0)||(n_o<>n_c)
    error("A_u and A_c must be square and of the same dimension");
  endif

  [n_u,n_x] = size(k_x);

  ## Defaults
  if nargin<4







|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  ## 	$Id$	


  ## Check sizes
  n_o = is_square(A_u);
  n_c = is_square(A_c);

  if (n_o==0)||(n_c==0)||(n_o!=n_c)
    error("A_u and A_c must be square and of the same dimension");
  endif

  [n_u,n_x] = size(k_x);

  ## Defaults
  if nargin<4

Modified mttroot/mtt/lib/control/PPP/ppp_qp_sim.m from [3bd70b9dea] to [6333ae0d35].

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  if Delta_ol>0			# Intermittent control
    T_ol = 0:dt:Delta_ol;	# Create the open-loop time vector
  else
    T_ol = [0,dt];
    Delta_ol = dt;
  endif
  t_last = t(length(t));
  T_cl = 0:Delta_ol:t_last-Delta_ol; # Closed-loop time vector
  T = 0:dt:t_last;		# Overall time vector
 
  ## Lengths thereof
  n_Tcl = length(T_cl);
  n_ol = length(T_ol);
  n_T = length(T);

  ## Expand W with constant last value or truncate







|
|







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  if Delta_ol>0			# Intermittent control
    T_ol = 0:dt:Delta_ol;	# Create the open-loop time vector
  else
    T_ol = [0,dt];
    Delta_ol = dt;
  endif
  t_last = t(length(t));
  T_cl = 0:Delta_ol:2*t_last-Delta_ol; # Closed-loop time vector
  T = 0:dt:2*t_last;		# Overall time vector
 
  ## Lengths thereof
  n_Tcl = length(T_cl);
  n_ol = length(T_ol);
  n_T = length(T);

  ## Expand W with constant last value or truncate
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
  Iterations = [];
  du = [];
  J = [];
  tick= time;

  ## disp("Simulating ...");
  for t=T_cl			# Outer loop at Delta_ol

    ##disp(sprintf("Time %g", t));
    ## Output constraints
    [Gamma_y,gamma_y] = ppp_output_constraints  (A,B,C,D,x,A_u,Tau_y,Min_y,Max_y,Order_y);
    
    ## Composite constraints 
    Gamma = [Gamma_u; Gamma_y];
    gamma = [gamma_u; gamma_y];







|







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
  Iterations = [];
  du = [];
  J = [];
  tick= time;

  ## disp("Simulating ...");
  for t=T_cl			# Outer loop at Delta_ol
    printf("%g\r",t);
    ##disp(sprintf("Time %g", t));
    ## Output constraints
    [Gamma_y,gamma_y] = ppp_output_constraints  (A,B,C,D,x,A_u,Tau_y,Min_y,Max_y,Order_y);
    
    ## Composite constraints 
    Gamma = [Gamma_u; Gamma_y];
    gamma = [gamma_u; gamma_y];

Modified mttroot/mtt/lib/control/PPP/ppp_ystar.m from [34d0435ae4] to [17c1b7c256].

20
21
22
23
24
25
26
27
28






29
30
31
32
33
34
35
  ## xs          x*, one column for each time tau 
  ## xu          x_u, one column for each time tau 
  ## AA          The composite system matrix
  
  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	


  [n_x,n_u,n_y] = abcddim(A,B,C,D); # System dimensions






  no_system = n_x==0;

  [n,m] = size(A_u);		# Size of composite A_u matrix
  square = (n==m);		# Is A_u square?
  n_U = m;			# functions per input

  







|
|
>
>
>
>
>
>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  ## xs          x*, one column for each time tau 
  ## xu          x_u, one column for each time tau 
  ## AA          The composite system matrix
  
  ## Copyright (C) 1999 by Peter J. Gawthrop
  ## 	$Id$	

  if (size(A)>0)
    [n_x,n_u,n_y] = abcddim(A,B,C,D); # System dimensions
  else
    n_x = 0;
    n_y = 0;
    n_u = 0;
  endif
  
  no_system = n_x==0;

  [n,m] = size(A_u);		# Size of composite A_u matrix
  square = (n==m);		# Is A_u square?
  n_U = m;			# functions per input

  
113
114
115
116
117
118
119

120




121
122
123
124
125
126
127
128
129
  n_xx = length(xx_0);		# Length of composite state

  ## Compute the star variables
  for t=tau
    xxt = expm(AA*t)*xx_0;	# Composite state
    xst = xxt(1:n_x);		# x star
    xut = xxt(n_x+1:n_xx);	# x star

    yst = C*xst;		# y star




    ust = Utilde*xut;		# u star

    xs = [xs xst];		# x star
    xu = [xu xut];		# x star
    ys = [ys yst];		# y star
    us = [us ust];		# u star
  endfor

endfunction







>
|
>
>
>
>









119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
  n_xx = length(xx_0);		# Length of composite state

  ## Compute the star variables
  for t=tau
    xxt = expm(AA*t)*xx_0;	# Composite state
    xst = xxt(1:n_x);		# x star
    xut = xxt(n_x+1:n_xx);	# x star
    if length(C)>0
      yst = C*xst;		# y star
    else
      yst = [];
    endif
    
    ust = Utilde*xut;		# u star

    xs = [xs xst];		# x star
    xu = [xu xut];		# x star
    ys = [ys yst];		# y star
    us = [us ust];		# u star
  endfor

endfunction


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]