forked from ajinkya-khade/ACC_Vehicle_MPC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wrapper.m
49 lines (35 loc) · 1.66 KB
/
wrapper.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
45
46
47
48
49
clear all;
close all;
setup % Load all input parameters
% All possible input variables over which the code might perform a sweep
inputNames = {'tau', 'ts', 'tsim', 'umin', 'umax', 'Np', 'Nc', 'Q', 'R', 'S', 'e0','sivdMode','ineqMode','eqMode','chkInputBoundFlag','Xref'};
inputArray = {tau, ts, tsim, umin, umax, Np, Nc, Q, R, S, e0, sivdMode, ineqMode,eqMode,chkInputBoundFlag,Xref};
% Find the parameters the code needs to sweep over for given input settings
sweepParamLoc = find(ismember(inputNames, sweepParamName));
fprintf('Starting simulation...\n');
for i = 1:size(sweepParamVals,1)
fprintf('Simulation Case #%i\n', i);
% local variable to store the input values for current case
inputArrayLocal = inputArray;
% assigning values specific to current case for all sweep parameters
for j = 1:length(sweepParamLoc)
inputArrayLocal{sweepParamLoc(j)} = sweepParamVals{i,j};
end
% storing simulation output structure in an array for processing later
simOutputArray(i) = main(inputArrayLocal{:});
if legendMode == 1
simOutputArray(i).displayname = [sweepParamName{:}, ' = ', sweepParamDisp{i}];
elseif legendMode == 2
simOutputArray(i).displayname = sweepParamDisp{i};
end
end
fprintf('Simulation Complete!\n');
fprintf('Generating Plots...\n');
genPlots(simOutputArray,sivdPlotMode);
% Uncomment to plot absolute position and velocity of ACC and target
% vehicle
% plotAbsolute(simOutputArray, Xref);
% Uncomment to plot optimiztion cost at all time steps
% plotCost(simOutputArray);
fprintf('End of program!\n')
beep