60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
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
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
|
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];
|