-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_simulink.m
44 lines (36 loc) · 1014 Bytes
/
run_simulink.m
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function funcc = run_simulink(vars)
Ts = vars.opt_Ts/100; % make the time interval as 0.01
N = vars.opt_N; % prediction horizon
wd = vars.opt_wd;
wv = vars.opt_wv;
wa = vars.opt_wa;
wu = vars.opt_wu;
wdu = vars.opt_wdu;
save bayes_param.mat
Load_BestRun_Parameters2;
w1 = 1; % weight for the TEI
w2 = 1/48.388; % weight for the FE
mdl = "BestRun_VehicleModel_pntwo";
in = Simulink.SimulationInput(mdl);
in = in.loadVariablesFromMATFile('bayes_param.mat');
out = sim(in);
%FE.Data(end)+TEI.Data(end)
TEI = out.TEI;
FE = out.FE;
plot(TEI)
plot(FE)
hold on;
legend()
xlabel('Time')
TEI_obj = TEI.data(end);
FE_obj = FE.data(end);
funcc = w1*TEI_obj+w2*FE_obj;
% FE high -> better solution
% TEI low -> better solution
% Therefore, Maximum FE, minimum TEI
disp(funcc)
delete bayes_param.mat
clear TEI_obj
clear FE_obj
clear N
end