|
73 | 73 | disp('');
|
74 | 74 |
|
75 | 75 |
|
76 |
| -% Obs.: Flagc will be active in the file procedure_jianbo_esp.m |
| 76 | +% Obs.: Flagc will be active in the file procedure_orig_esp.m |
77 | 77 |
|
78 | 78 | %% Simulation parameters
|
79 | 79 |
|
80 | 80 | ksteps=1;fprintf('For the feasible region just %d step is needed\n',ksteps);
|
81 | 81 |
|
82 | 82 | umax=1;
|
83 |
| -xmax=3; % xmax=1.5; |
| 83 | +xmax=1.5; % xmax=1.5; |
84 | 84 | if flagc ==1
|
85 | 85 | fprintf('Maximum allowed control input = %g\n',umax);
|
86 | 86 | elseif flagc == 2
|
87 | 87 | fprintf('Maximum allowed control input = %g\n',umax);
|
88 | 88 | fprintf('Maximum vale for the state = %g\n',xmax);
|
89 | 89 | end
|
90 | 90 |
|
91 |
| -nrep=2000;fprintf('Number of replications = %d\n',nrep); |
| 91 | +nrep=200;fprintf('Number of replications = %d\n',nrep); |
92 | 92 |
|
93 | 93 |
|
94 | 94 | %% Predicted Control Strategy
|
|
123 | 123 | % I have just added the following in case I need to change the matrix B in
|
124 | 124 | % the example. parb=[0.0] which is the value in the paper.
|
125 | 125 |
|
126 |
| -parb=[0.0];% 0.4 0.45 0.46 0.47 0.475 0.476 0.477 0.478 0.478 0.479 0.48 0.49 0.5 0.6 0.7 0.8 0.9 1.0]; % values of the parameter b |
| 126 | +parb=[0.4];% 0.4 0.45 0.46 0.47 0.475 0.476 0.477 0.478 0.478 0.479 0.48 0.49 0.5 0.6 0.7 0.8 0.9 1.0]; % values of the parameter b |
127 | 127 |
|
128 | 128 | %% Main Loop
|
129 | 129 |
|
|
135 | 135 | fprintf('Simulation for B{2,1}=[%g;1]\n',parb(iparb));
|
136 | 136 | disp(' ');
|
137 | 137 |
|
138 |
| - ccontrol_jianbo = zeros(nrep,1); % Total Control Cost of the original method |
| 138 | + ccontrol_orig = zeros(nrep,1); % Total Control Cost of the original method |
139 | 139 |
|
140 |
| - x_jianbo=[]; |
| 140 | + x_orig=[]; |
141 | 141 |
|
142 |
| - u_jianbo=[]; |
| 142 | + u_orig=[]; |
143 | 143 |
|
144 | 144 | mc=1;
|
145 | 145 |
|
|
159 | 159 |
|
160 | 160 | % Save solver info
|
161 | 161 |
|
162 |
| - infoSolver_jianbo{1,mc}='Initial'; |
| 162 | + infoSolver_orig{1,mc}='Initial'; |
163 | 163 |
|
164 | 164 | % Just to be sure that uk is not feasible and it is the replication is
|
165 | 165 | % not taken into account
|
|
201 | 201 | % If there is no problem with the solution do
|
202 | 202 |
|
203 | 203 | if flagfeas
|
204 |
| - ccontrol_jianbo(mc)=cc_jianbo; |
205 |
| - x_jianbo=[x_jianbo x']; |
206 |
| - u_jianbo=[u_jianbo u']; |
| 204 | + ccontrol_orig(mc)=cc_orig; |
| 205 | + x_orig=[x_orig x']; |
| 206 | + u_orig=[u_orig u']; |
207 | 207 | mc=mc+1;
|
208 | 208 | else
|
209 | 209 | mc_failure=[mc_failure mcseed];
|
|
217 | 217 |
|
218 | 218 | %% Mean and Standard deviation for the states
|
219 | 219 |
|
220 |
| - x_jianbo_mean=[]; |
| 220 | + x_orig_mean=[]; |
221 | 221 |
|
222 |
| - x_jianbo_std=[]; |
| 222 | + x_orig_std=[]; |
223 | 223 |
|
224 | 224 | for i=1:nx
|
225 |
| - x_jianbo_mean=[x_jianbo_mean mean(x_jianbo(:,i:nx:size(x_jianbo,2)),2)]; |
226 |
| - x_jianbo_std=[x_jianbo_std 2*std(x_jianbo(:,i:nx:size(x_jianbo,2))')']; |
| 225 | + x_orig_mean=[x_orig_mean mean(x_orig(:,i:nx:size(x_orig,2)),2)]; |
| 226 | + x_orig_std=[x_orig_std 2*std(x_orig(:,i:nx:size(x_orig,2))')']; |
227 | 227 | end
|
228 | 228 |
|
229 | 229 | %% Mean and Standard deviation for the input
|
230 | 230 |
|
231 |
| - u_jianbo_mean=mean(u_jianbo,2); |
232 |
| - u_jianbo_std=2*std(u_jianbo')'; |
| 231 | + u_orig_mean=mean(u_orig,2); |
| 232 | + u_orig_std=2*std(u_orig')'; |
233 | 233 |
|
234 | 234 | %% Save the results of the simulation
|
235 | 235 |
|
236 |
| - fcost_jianbo{iparb}=mean(ccontrol_jianbo); |
| 236 | + fcost_orig{iparb}=mean(ccontrol_orig); |
237 | 237 |
|
238 |
| - finfoSolver_jianbo{iparb}=infoSolver_jianbo; |
| 238 | + finfoSolver_orig{iparb}=infoSolver_orig; |
239 | 239 |
|
240 |
| - fx_jianbo_mean{iparb}=x_jianbo_mean; |
| 240 | + fx_orig_mean{iparb}=x_orig_mean; |
241 | 241 |
|
242 |
| - fx_jianbo_std{iparb}=x_jianbo_std; |
| 242 | + fx_orig_std{iparb}=x_orig_std; |
243 | 243 |
|
244 |
| - fu_jianbo_mean{iparb}=u_jianbo_mean; |
| 244 | + fu_orig_mean{iparb}=u_orig_mean; |
245 | 245 |
|
246 |
| - fu_jianbo_std{iparb}=u_jianbo_std; |
| 246 | + fu_orig_std{iparb}=u_orig_std; |
247 | 247 |
|
248 | 248 | end
|
249 | 249 |
|
|
259 | 259 | if flagx > 0
|
260 | 260 | tfig=tfig+1;
|
261 | 261 | figure(tfig);
|
262 |
| - plot(x_jianbo(1,1:nx:end),x_jianbo(1,2:nx:end),'*'); |
| 262 | + plot(x_orig(1,1:nx:end),x_orig(1,2:nx:end),'*'); |
263 | 263 | if flagc == 1
|
264 | 264 | title(sprintf('Valid initial conditions over %g replications for N = %d - Input constraint',nrep,N));
|
265 | 265 | else
|
|
278 | 278 | for i=1:tfig
|
279 | 279 | if flagc == 1
|
280 | 280 | if flagx
|
281 |
| - s=sprintf('images/feasreg_jianbo_%d_u_constraint_N_%d_nrep_%d_random.png',i,N,nrep); |
| 281 | + s=sprintf('images/feasreg_orig_%d_u_constraint_N_%d_nrep_%d_random.png',i,N,nrep); |
282 | 282 | else
|
283 |
| - s=sprintf('images/feasreg_jianbo_%d_u_constraint_N_%d_nrep_%d.png',i,N,nrep); |
| 283 | + s=sprintf('images/feasreg_orig_%d_u_constraint_N_%d_nrep_%d.png',i,N,nrep); |
284 | 284 | end
|
285 | 285 | elseif flagc == 2
|
286 | 286 | if flagx
|
287 |
| - s=sprintf('images/feasreg_jianbo_%d_u_and_x_constraints_N_%d_nrep_%d_random.png',i,N,nrep); |
| 287 | + s=sprintf('images/feasreg_orig_%d_u_and_x_constraints_N_%d_nrep_%d_random.png',i,N,nrep); |
288 | 288 | else
|
289 |
| - s=sprintf('images/feasreg_jianbo_%d_u_and_x_constraints_N_%d_nrep_%d.png',i,N,nrep); |
| 289 | + s=sprintf('images/feasreg_orig_%d_u_and_x_constraints_N_%d_nrep_%d.png',i,N,nrep); |
290 | 290 | end
|
291 | 291 | else
|
292 | 292 | if flagx
|
293 |
| - s=sprintf('images/feasreg_jianbo_%d_no_constraints_N_%d_nrep_%d_random.png',i,N,nrep); |
| 293 | + s=sprintf('images/feasreg_orig_%d_no_constraints_N_%d_nrep_%d_random.png',i,N,nrep); |
294 | 294 | else
|
295 |
| - s=sprintf('images/feasreg_jianbo_%d_no_constraints_N_%d_nrep_%d.png',i,N,nrep); |
| 295 | + s=sprintf('images/feasreg_orig_%d_no_constraints_N_%d_nrep_%d.png',i,N,nrep); |
296 | 296 | end
|
297 | 297 | end
|
298 | 298 | figure(i);
|
|
307 | 307 |
|
308 | 308 | if flagc == 1
|
309 | 309 | if flagx
|
310 |
| - s=sprintf('data/feasreg_jianbo_%d_u_constraint_N_%d_nrep_%d_random.mat',i,N,nrep); |
| 310 | + s=sprintf('data/feasreg_orig_%d_u_constraint_N_%d_nrep_%d_random.mat',i,N,nrep); |
311 | 311 | else
|
312 |
| - s=sprintf('data/feasreg_jianbo_%d_u_constraint_N_%d_nrep_%d.mat',i,N,nrep); |
| 312 | + s=sprintf('data/feasreg_orig_%d_u_constraint_N_%d_nrep_%d.mat',i,N,nrep); |
313 | 313 | end
|
314 | 314 | elseif flagc == 2
|
315 | 315 | if flagx
|
316 |
| - s=sprintf('data/feasreg_jianbo_%d_u_and_x_constraints_N_%d_nrep_%d_random.mat',i,N,nrep); |
| 316 | + s=sprintf('data/feasreg_orig_%d_u_and_x_constraints_N_%d_nrep_%d_random.mat',i,N,nrep); |
317 | 317 | else
|
318 |
| - s=sprintf('data/feasreg_jianbo_%d_u_and_x_constraints_N_%d_nrep_%d.mat',i,N,nrep); |
| 318 | + s=sprintf('data/feasreg_orig_%d_u_and_x_constraints_N_%d_nrep_%d.mat',i,N,nrep); |
319 | 319 | end
|
320 | 320 | else
|
321 | 321 | if flagx
|
322 |
| - s=sprintf('data/feasreg_jianbo_%d_no_constraints_N_%d_nrep_%d_random.mat',i,N,nrep); |
| 322 | + s=sprintf('data/feasreg_orig_%d_no_constraints_N_%d_nrep_%d_random.mat',i,N,nrep); |
323 | 323 | else
|
324 |
| - s=sprintf('data/feasreg_jianbo_%d_no_constraints_N_%d_nrep_%d.mat',i,N,nrep); |
| 324 | + s=sprintf('data/feasreg_orig_%d_no_constraints_N_%d_nrep_%d.mat',i,N,nrep); |
325 | 325 | end
|
326 | 326 | end
|
327 | 327 |
|
|
0 commit comments