forked from decyphir/breach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InitBreach.m
160 lines (132 loc) · 5.18 KB
/
InitBreach.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
function InitBreach(br_dir, force_init, varargin)
% InitBreach initializes Breach, in particular adding paths to Breach directories
%% checks if global configuration variable is defined
global BreachGlobOpt
if nargin<2
force_init = false;
end
if ~exist('br_dir', 'var')||isempty(br_dir)
br_dir = which('InstallBreach');
br_dir = fileparts(br_dir);
end
if ~force_init && isfield(BreachGlobOpt, 'breach_dir')
if isequal(BreachGlobOpt.breach_dir, br_dir)
return; % OK InitBreach has been run before
end
end
addpath([br_dir filesep 'Core' filesep 'm_src']);
opt.verbose = 1;
opt.init_from_breachflows= false;
opt = varargin2struct_breach(opt, varargin{:});
addpath([br_dir filesep 'Core' filesep 'm_src']);
opt.verbose = 1;
opt.init_from_breachflows= false;
opt = varargin2struct_breach(opt, varargin{:});
%% remove old path, if any
br_all_dir = which('InstallBreach', '-all');
nb_dir = numel(br_all_dir);
if nb_dir>1
for idir = 2: nb_dir
br_old_dir = fileparts(br_all_dir{idir});
all_paths = strsplit(path,pathsep);
nb_paths = numel(all_paths);
rm_path_list = {};
for ii = 1:nb_paths
if regexp(all_paths{ii},br_old_dir)
%disp([' ' all_paths{ii}]);
rm_path_list = [rm_path_list all_paths{ii}];
end
end
if ~isempty(rm_path_list)&&opt.verbose>=1
disp(['Warning: removing paths in ' br_old_dir]);
rmpath(rm_path_list{:});
disp(' ');
end
end
end
%% Make sure ModelsData exist
if ~exist( [br_dir filesep 'Ext' filesep 'ModelsData'], 'dir')
mkdir([br_dir filesep 'Ext' filesep 'ModelsData']);
end
%% Make sure ModelsData/ParallelTemp exist for parallel computing
if ~exist( [br_dir filesep 'Ext' filesep 'ModelsData' filesep 'ParallelTemp'], 'dir')
mkdir([br_dir filesep 'Ext' filesep 'ModelsData' filesep 'ParallelTemp']);
end
%% Init
if opt.verbose>=1
disp(['Initializing Breach from folder ' br_dir '...']);
end
id = 'MATLAB:dispatcher:nameConflict';
warning('off',id);
cdr = pwd;
cd(br_dir);
list_path = { ...
br_dir, ...
[br_dir filesep 'Core'], ...
[br_dir filesep 'Core' filesep 'Init'], ...
[br_dir filesep 'Core' filesep 'm_src'], ...
[br_dir filesep 'Core' filesep 'Algos'], ...
[br_dir filesep 'Core' filesep 'SignalGen'], ...
[br_dir filesep 'Core' filesep 'OutputGen'], ...
[br_dir filesep 'Core' filesep 'ParamGen'], ...
[br_dir filesep 'Core' filesep 'Diagnostics'], ...
[br_dir filesep 'Core' filesep 'Gui'], ...
[br_dir filesep 'Core' filesep 'Gui' filesep 'elems'], ...
[br_dir filesep 'Params'], ...
[br_dir filesep 'Params' filesep 'm_src'], ...
[br_dir filesep 'Params' filesep 'm_src' filesep 'sobolqr'], ...
[br_dir filesep 'Params' filesep 'm_src' filesep 'niederreiter2'], ...
[br_dir filesep 'Plots'], ...
[br_dir filesep 'Plots' filesep 'm_src'], ...
[br_dir filesep 'Online' filesep 'm_src'], ...
[br_dir filesep 'Online' filesep 'bin'], ...
[br_dir filesep 'Online' filesep 'simulink_stlib'], ...
[br_dir filesep 'Examples'], ...
[br_dir filesep 'Ext' filesep 'Models'], ...
[br_dir filesep 'Ext' filesep 'ModelsData'], ...
[br_dir filesep 'Ext' filesep 'Specs'], ...
[br_dir filesep 'Ext' filesep 'Classes'], ...
[br_dir filesep 'Ext' filesep 'Specs' filesep 'STLib'], ...
[br_dir filesep 'Ext' filesep 'Toolboxes'], ...
[br_dir filesep 'Ext' filesep 'Toolboxes' filesep 'optimize'], ...
[br_dir filesep 'Ext' filesep 'Toolboxes' filesep 'DataHash'], ...
[br_dir filesep 'Ext' filesep 'Toolboxes' filesep 'simulink_custom'], ...
[br_dir filesep 'Ext' filesep 'Toolboxes' filesep 'sundials' filesep 'sundialsTB' ], ...
[br_dir filesep 'Ext' filesep 'Toolboxes' filesep 'sundials' filesep 'sundialsTB' filesep 'cvodes'], ...
[br_dir filesep 'Ext' filesep 'Toolboxes' filesep 'jsonlab'], ...
[br_dir filesep 'Ext' filesep 'Toolboxes' filesep 'YAMLmatlab'], ...
[br_dir filesep 'Ext' filesep 'Toolboxes' filesep 'YAMLmatlab' filesep 'external'], ...
[br_dir filesep 'Ext' filesep 'Toolboxes' filesep 'YAMLmatlab' filesep 'extras'], ...
[br_dir filesep 'Ext' filesep 'Toolboxes' filesep 'snobfit'], ...
[br_dir filesep 'Ext' filesep 'Toolboxes' filesep 'minq'], ...
};
addpath(list_path{:});
cd(cdr);
%% Lookfor extensions
if exist('InitBreachFlows', 'file')&&~opt.init_from_breachflows
InitBreachFlows;
end
%% Init BreachGlobOpt global configuration variable
% Some global constants
if ~isfield(BreachGlobOpt, 'MaxNumSamples')
BreachGlobOpt.MaxNumSamples=100000;
end
% STL Initialization
BreachGlobOpt.disable_robust_linear_interpolation = 1;
if ~isfield(BreachGlobOpt,'RobustSemantics')
BreachGlobOpt.RobustSemantics = 0;
end
if isfield(BreachGlobOpt, 'STLDB')
if ~strcmp(class(BreachGlobOpt.STLDB), 'containers.Map')
BreachGlobOpt.STLDB = containers.Map();
end
else
BreachGlobOpt.STLDB = containers.Map();
end
%% Store path list
BreachGlobOpt.breach_dir = br_dir;
BreachGlobOpt.list_path = list_path;
%% Force refreshing sl_customization menu % disabled fixed/proven useful
%sl_refresh_customizations;
warning('on',id);
end