-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoSetupKF.m
85 lines (71 loc) · 2.33 KB
/
autoSetupKF.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
function autoSetupKF()
%go to koopman falsification home folder
cdr = pwd; %current folder
filePath = which('setupKF'); %filepath
[kfFolder, ~, ~] = fileparts(filePath);
cd(kfFolder);
% add to path and remove archive and hacky cora files
addpath(genpath(kfFolder))
rmpath(fullfile('external','CORA'))
rmpath(genpath('archive'))
%check installed toolbox
%code taken from CORA installation.
auxInstallToolbox('Symbolic Math Toolbox');
%setup Breach and CORA
InitBreach()
setupBreach()
setupCora()
%setup mpt
mpt_init
%add gurobi to path
addpath(genpath('/opt/gurobi/linux64/matlab'));
% run setup
gurobi_setup
%go back to base folder
cd(cdr);
%save modified path
savepath;
disp('- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -')
disp('Koopman Falsification Successfully Setup!')
end
% -------------------------- Auxiliary Functions --------------------------
function res = auxInstallToolbox(text)
res = auxTestToolboxInstallation(text);
while ~res
auxDisplayInstallPrompt(text);
res = auxTestToolboxInstallation(text);
end
end
function res = auxTestToolboxInstallation(text)
res = any(any(contains(struct2cell(ver),text)));
end
function auxDisplayInstallPrompt(text)
error(['''<strong>%s</strong>'' is missing and requires manual installation. \n' ...
' Please install it via the MATLAB Add-On Explorer. \n'], text)
end
function setupBreach()
%remove conflicting breach files from path
filePath = which('InitBreach');
[breachFolder, ~, ~] = fileparts(filePath);
warning('off', 'MATLAB:rmpath:DirNotFound');
rmpath(genpath(fullfile(breachFolder, 'Ext')))
rmpath(genpath(fullfile(breachFolder, 'Examples')))
warning('on', 'MATLAB:rmpath:DirNotFound');
end
function setupCora()
filePath = which('stl'); %cora stl filepath
[coraStlFolder,~,~] = fileparts(filePath);
%replace CORA stl files to add string representation and abs function
sourceFolder = fullfile('external','CORA');
destinationFolder = coraStlFolder;
files = '*.m'; % all m files
% Construct the full paths for the source and destination files
sourceFiles = fullfile(sourceFolder, files);
% Move the files with the option to overwrite existing files
[success,message]=copyfile(sourceFiles, destinationFolder, 'f');
assert(success, ['File copy failed with message ' message]);
%remove CORA modification files from path
if contains(path, sourceFolder)
rmpath(sourceFolder)
end
end