Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/verivital/nnv
Browse files Browse the repository at this point in the history
  • Loading branch information
ttj committed Jan 28, 2020
2 parents 1cd32b4 + 97c9529 commit 1d3bc39
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
% Plot reachable sets for Discrete Linear ACC model
% Dung Tran: 10/22/2019

path_out = [path_results(), filesep, 'ACC', filesep];

%% System model
% x1 = lead_car position
Expand Down Expand Up @@ -116,17 +117,12 @@
end

ncs.reach(init_set(1), ref_input, numSteps, 'approx-star', numCores);
if is_codeocean()
path_results = '/results/';
else
path_results = '';
end

save([path_results, 'linear_ACC_ncs_1.mat'], 'ncs');
save([path_out, 'linear_ACC_ncs_1.mat'], 'ncs');

ncs.reach(init_set(6), ref_input, numSteps, 'approx-star', numCores);

save([path_results, 'linear_ACC_ncs_6.mat'], 'ncs');
save([path_out, 'linear_ACC_ncs_6.mat'], 'ncs');

%% Plot output reach sets: actual distance vs. safe distance

Expand All @@ -135,7 +131,7 @@

figure;
h1 = subplot(2,1,1);
load([path_results, 'linear_ACC_ncs_1.mat']);
load([path_out, 'linear_ACC_ncs_1.mat']);
map_mat = [1 0 0 -1 0 0 0];
map_vec = [];
ncs.plotOutputReachSets('blue', map_mat, map_vec);
Expand All @@ -153,7 +149,7 @@
xticks(h1, [0:5:50])

h2 = subplot(2,1,2);
load([path_results, 'linear_ACC_ncs_6.mat']);
load([path_out, 'linear_ACC_ncs_6.mat']);
map_mat = [1 0 0 -1 0 0 0];
map_vec = [];
ncs.plotOutputReachSets('blue', map_mat, map_vec);
Expand All @@ -170,6 +166,6 @@
ylabel(h2, 'Distance');
xticks(h2, [0:5:50])

saveas(gcf, [path_results, 'plot_linear_ACC_reachSets.png']);
saveas(gcf, [path_out, 'figure4_plot_linear_ACC_reachSets.png']);

%% END OF SCRIPT
2 changes: 2 additions & 0 deletions code/nnv/examples/Submission/CAV2020/ACC/reproduce.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

cd(path_reproduce);

mkdir([path_results(), filesep, 'ACC']);

% set number of cores based on system availability, up to a maximum of 16
config_parallelism(16);

Expand Down
10 changes: 3 additions & 7 deletions code/nnv/examples/Submission/CAV2020/ACC/verify_linear_ACC.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
% Reachability analysis for Discrete Linear ACC model
% Dung Tran: 9/30/2019

path_out = [path_results(), filesep, 'ACC', filesep];


%% System model
Expand Down Expand Up @@ -131,12 +132,7 @@


%% Save verification results
if is_codeocean()
path_results = '/results/';
else
path_results = '';
end
save([path_results, 'linear_ACC.mat'], 'safe_approx', 'VT_approx', 'counterExamples_approx');
save([path_out, 'linear_ACC.mat'], 'safe_approx', 'VT_approx', 'counterExamples_approx');

%% Print verification results to screen
fprintf('\n======================================================');
Expand All @@ -152,7 +148,7 @@

%% Print verification results to a file

fid = fopen([path_results, 'linear_ACC.txt'], 'wt');
fid = fopen([path_out, 'table3_linear_ACC.txt'], 'wt');

fprintf(fid,'\n======================================================');
fprintf(fid,'\nVERIFICATION RESULTS FOR ACC WITH DISCRETE PLANT MODEL');
Expand Down
14 changes: 5 additions & 9 deletions code/nnv/examples/Submission/CAV2020/ACC/verify_nonlinear_ACC.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
load controller_5_20.mat;

path_out = [path_results(), filesep, 'ACC', filesep];

weights = network.weights;
bias = network.bias;
n = length(weights);
Expand Down Expand Up @@ -115,13 +117,7 @@
VT(i) = toc(t);
end

%% Safe verification results
if is_codeocean()
path_results = '/results/';
else
path_results = '';
end
save([path_results, 'verify_nonlinear_ACC.mat'], 'safe', 'VT', 'counterExamples');
save([path_out, 'verify_nonlinear_ACC.mat'], 'safe', 'VT', 'counterExamples');


%% Print verification results to screen
Expand All @@ -138,7 +134,7 @@

%% Print verification results to a file

fid = fopen([path_results, 'nonlinear_ACC.txt'], 'wt');
fid = fopen([path_out, 'table3_nonlinear_ACC.txt'], 'wt');
fprintf(fid,'\n=======================================================');
fprintf(fid,'\nVERIFICATION RESULTS FOR ACC WITH NONLINEAR PLANT MODEL');
fprintf(fid,'\n=======================================================');
Expand Down Expand Up @@ -168,4 +164,4 @@
xticks([0:5:50]);
title('Actual Distance (blue) vs. Safe Distance (red)');

saveas(gcf, [path_results, 'verify_nonlinear_acc_cex.png']);
saveas(gcf, [path_out, 'verify_nonlinear_acc_cex.png']);
2 changes: 1 addition & 1 deletion code/run_codeocean.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
% run all closed-loop CPS examples
reproduce % will take ~32.5 minutes (see run 140515 or 152224)

return; % stop here, comment/remove this to run all tests, other examples, etc.
%return; % stop here, comment/remove this to run all tests, other examples, etc.
% if you run all these, it will add another ~15 minutes of runtime

cd /code/nnv/tests/set/zono
Expand Down
2 changes: 2 additions & 0 deletions environment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ RUN mkdir -p /deps
RUN ls /codeocean-true

WORKDIR /deps
# these ls commands are just to force a new build so that the cloned repo is latest and not the cached one in the prior docker container image
RUN ls
RUN ls
RUN ls
RUN ls
Expand Down

0 comments on commit 1d3bc39

Please sign in to comment.