Skip to content

Commit a6289bd

Browse files
committed
Fix some bugs
1 parent 2d65a26 commit a6289bd

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

script_generate_feasible_region_brute_force.m

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,22 @@
7373
disp('');
7474

7575

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
7777

7878
%% Simulation parameters
7979

8080
ksteps=1;fprintf('For the feasible region just %d step is needed\n',ksteps);
8181

8282
umax=1;
83-
xmax=3; % xmax=1.5;
83+
xmax=1.5; % xmax=1.5;
8484
if flagc ==1
8585
fprintf('Maximum allowed control input = %g\n',umax);
8686
elseif flagc == 2
8787
fprintf('Maximum allowed control input = %g\n',umax);
8888
fprintf('Maximum vale for the state = %g\n',xmax);
8989
end
9090

91-
nrep=2000;fprintf('Number of replications = %d\n',nrep);
91+
nrep=200;fprintf('Number of replications = %d\n',nrep);
9292

9393

9494
%% Predicted Control Strategy
@@ -123,7 +123,7 @@
123123
% I have just added the following in case I need to change the matrix B in
124124
% the example. parb=[0.0] which is the value in the paper.
125125

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
127127

128128
%% Main Loop
129129

@@ -135,11 +135,11 @@
135135
fprintf('Simulation for B{2,1}=[%g;1]\n',parb(iparb));
136136
disp(' ');
137137

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
139139

140-
x_jianbo=[];
140+
x_orig=[];
141141

142-
u_jianbo=[];
142+
u_orig=[];
143143

144144
mc=1;
145145

@@ -159,7 +159,7 @@
159159

160160
% Save solver info
161161

162-
infoSolver_jianbo{1,mc}='Initial';
162+
infoSolver_orig{1,mc}='Initial';
163163

164164
% Just to be sure that uk is not feasible and it is the replication is
165165
% not taken into account
@@ -201,9 +201,9 @@
201201
% If there is no problem with the solution do
202202

203203
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'];
207207
mc=mc+1;
208208
else
209209
mc_failure=[mc_failure mcseed];
@@ -217,33 +217,33 @@
217217

218218
%% Mean and Standard deviation for the states
219219

220-
x_jianbo_mean=[];
220+
x_orig_mean=[];
221221

222-
x_jianbo_std=[];
222+
x_orig_std=[];
223223

224224
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))')'];
227227
end
228228

229229
%% Mean and Standard deviation for the input
230230

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')';
233233

234234
%% Save the results of the simulation
235235

236-
fcost_jianbo{iparb}=mean(ccontrol_jianbo);
236+
fcost_orig{iparb}=mean(ccontrol_orig);
237237

238-
finfoSolver_jianbo{iparb}=infoSolver_jianbo;
238+
finfoSolver_orig{iparb}=infoSolver_orig;
239239

240-
fx_jianbo_mean{iparb}=x_jianbo_mean;
240+
fx_orig_mean{iparb}=x_orig_mean;
241241

242-
fx_jianbo_std{iparb}=x_jianbo_std;
242+
fx_orig_std{iparb}=x_orig_std;
243243

244-
fu_jianbo_mean{iparb}=u_jianbo_mean;
244+
fu_orig_mean{iparb}=u_orig_mean;
245245

246-
fu_jianbo_std{iparb}=u_jianbo_std;
246+
fu_orig_std{iparb}=u_orig_std;
247247

248248
end
249249

@@ -259,7 +259,7 @@
259259
if flagx > 0
260260
tfig=tfig+1;
261261
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),'*');
263263
if flagc == 1
264264
title(sprintf('Valid initial conditions over %g replications for N = %d - Input constraint',nrep,N));
265265
else
@@ -278,21 +278,21 @@
278278
for i=1:tfig
279279
if flagc == 1
280280
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);
282282
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);
284284
end
285285
elseif flagc == 2
286286
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);
288288
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);
290290
end
291291
else
292292
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);
294294
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);
296296
end
297297
end
298298
figure(i);
@@ -307,21 +307,21 @@
307307

308308
if flagc == 1
309309
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);
311311
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);
313313
end
314314
elseif flagc == 2
315315
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);
317317
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);
319319
end
320320
else
321321
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);
323323
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);
325325
end
326326
end
327327

0 commit comments

Comments
 (0)