Skip to content

Commit

Permalink
1.11.4
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdecyphir committed May 28, 2024
1 parent 1da2957 commit 1f8a495
Show file tree
Hide file tree
Showing 52 changed files with 6,631 additions and 437 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Ext/ModelsData
fileServerFolder
docrun_backup.mat
*.exe
!wordgen.exe
*.r2015a
*_ert_rtw
*.7z
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Release 1.11.4
- BreachProblemGui improvements
- Added SDToolbox (Sigma-Delta) and example
- Reorganized and fixed wordgen support
- Set_t0 method for BreachRequirement

## Minor
- param_gen now checks output parameters when they are changed
- BreachRequirement display requirements names
- BreachRequirement checks if STL file exists when reading from a file
- fixed bug with traj.time when reading from disk cache
- waitbar for parSim

# Release 1.11.3
- Fix BreachSamplesPlot data tip 3D bug
- Improved BreachProblemGui
Expand Down
445 changes: 242 additions & 203 deletions Core/Algos/@BreachProblem/BreachProblem.m

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Core/Algos/@BreachProblem/solve_snobfit.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
clear x
clear f

if isfield(this.BrSys.Sys, 'use_parallel') && this.BrSys.Sys.use_parallel
if isfield(this.BrSys, 'Sys') && isfield(this.BrSys.Sys, 'use_parallel') && this.BrSys.Sys.use_parallel
% Parallel computation
this.use_parallel = 1;
x = request(:, 1:n);
Expand Down
49 changes: 37 additions & 12 deletions Core/BreachRequirement.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,22 @@
this.AddRandReq();
end

elseif ischar(req_monitors)&&exist(req_monitors, 'file')
phis = STL_ReadFile(req_monitors);
elseif ischar(req_monitors)&&~isempty(regexp(req_monitors,'\.stl$','once'))
% req_monitors looks like .stl file
if exist(req_monitors,'file')==2
phis = STL_ReadFile(req_monitors);

if nargin==1
reqs= phis;
if nargin==1
reqs= phis;
else
reqs = postprocess_signal_gens;
postprocess_signal_gens = {};
end
this.AddReq(reqs);
else
reqs = postprocess_signal_gens;
postprocess_signal_gens = {};
error('BreachRequirement:STLFileNotFound','STL file not found: %s', req_monitors);
end
this.AddReq(reqs);

else
else
this.AddReq(req_monitors);
end
else
Expand Down Expand Up @@ -153,6 +157,20 @@ function ResetSigMap(this)
end

%% Evaluation
function Set_t0(this, t0)
% set initial time for requirements evaluation
for i_req = 1:numel(this.req_monitors)
r = this.req_monitors{i_req};
r.t0 = t0;
end

for i_req = 1:numel(this.precond_monitors)
r = this.req_monitors{i_req};
r.t0 = t0;
end
end


function ResetEval(this)
this.BrSet = [];
this.SetParam('data_trace_idx_', 0);
Expand All @@ -168,7 +186,8 @@ function ResetEval(this)
this.traces_vals = [];
this.val = [];
end



function [val_precond, traj_req] = evalTracePrecond(this,traj_req)
% evalTracePrecond eval satisfaction of requirements for one trace.

Expand Down Expand Up @@ -1150,11 +1169,17 @@ function Concat(this,other,fast)
%% Display

function varargout = disp(this)
reqs = '';
for ifo = 1:numel(this.req_monitors)
reqs = [reqs this.req_monitors{ifo}.name ', ' ];
end
reqs = reqs(1:end-2);

signals_in_st = cell2mat(cellfun(@(c) (['''' c ''', ']), this.signals_in, 'UniformOutput', false));
signals_in_st = ['{' signals_in_st(1:end-2) '}'];
signals_in_st = signals_in_st(1:end-2);
summary = this.GetStatement();

st = sprintf('BreachRequirement object for signal(s): %s. %s\n', signals_in_st, summary.statement);
st = sprintf('BreachRequirement object with requirement(s) {%s} involving signal(s) {%s}. %s\n', reqs, signals_in_st, summary.statement);

if nargout == 0
varargout = {};
Expand Down
72 changes: 45 additions & 27 deletions Core/BreachSet.m
Original file line number Diff line number Diff line change
Expand Up @@ -446,32 +446,40 @@ function SetParamGen(this, pg)
end

function SetParamGenItem(this, pg)
this.ParamGens{end+1} = pg;
% set a new param_gen. If new parameter is introduced, sets them to pg.p0

% create/update domain of input parameters
this.SetParam(pg.params, pg.p0, true);
if ~isempty(pg.domain)
this.SetDomain(pg.params, pg.domain);
all_pg_params = [pg.params pg.params_out];
all_pg_p0 = [pg.p0; nan(numel(pg.params_out),1)];

% We need to split between existing parameters
exist_params = this.GetParamList();

% checks for new parameters
[new_params, idx_new] = setdiff(all_pg_params, exist_params);
new_p0 = all_pg_p0(idx_new);

% adds param_gen, and execute it (!)
this.ParamGens{end+1} = pg;
if ~isempty(new_params)
this.SetParam(new_params,new_p0, true); % Note: this is what creates the new parameters
else
domain = repmat(BreachDomain, 1, numel(pg.params));
this.SetDomain(pg.params, domain);
this.ApplyParamGens(pg.params);
end


% this.SetParam(pg.params_out, nan, true); % why ?
params_nan = setdiff(pg.params_out, pg.params);
if ~isempty(params_nan)
this.SetParam(params_nan, nan, true);
% if domain is specified we should set it
if ~isempty(pg.domain)
for ip =1:numel(pg.params_in)
this.SetDomain(pg.params{ip}, pg.domain{ip});
end
end

% update domain of output parameters
if ~isempty(pg.domain_out)
for ip =1:numel(pg.params_out)
this.SetDomain(pg.params_out{ip}, pg.domain_out(ip));
end
end

this.ApplyParamGens();
end

function ApplyParamGens(this, params)
Expand All @@ -487,14 +495,28 @@ function ApplyParamGens(this, params)
ip = params;
params = this.P.ParamList{ip};
end

% loop over list of param_gen and apply them
for ig = 1:numel(this.ParamGens)
pg = this.ParamGens{ig};
params_in= pg.params;
if ~isempty(intersect(params, params_in))
p_in = this.GetParam(params_in);
p_out = pg.computeParams(p_in);
ip_out = FindParam(this.P, pg.params_out);
this.P.pts(ip_out,:) = p_out;
params_out = pg.params_out;
if ~isempty(intersect(params, [params_in params_out])) % if empty, this param_gen is not concerned
if isempty(params_out)&&isempty(params_in)
pg.computeParams(); % pure callback
elseif isempty(params_out)&&~isempty(params_in)
p_in = this.GetParam(params_in);
pg.computeParams(p_in)
elseif ~isempty(params_out)&&isempty(params_in)
p_out = pg.computeParams();
ip_out = FindParam(this.P, pg.params_out);
this.P.pts(ip_out,:) = p_out;
else
p_in = this.GetParam(params_in);
p_out = pg.computeParams(p_in);
ip_out = FindParam(this.P, pg.params_out);
this.P.pts(ip_out,:) = p_out;
end
end
end
if ~isempty(ig)
Expand Down Expand Up @@ -1087,12 +1109,6 @@ function SaveSignals(this, signals, folder, name,i_trajs)
SplotTraj(this.P, varargin{:});
end

function h= PlotSurf(this)


end


%% Sampling
function SampleDomain(this, params, num_samples, method, opt_multi, max_num_samples)
% BreachSet.SampleDomain generic sampling function
Expand Down Expand Up @@ -1385,7 +1401,7 @@ function SavedTrajectorySample(this, paramValues)
end

function PlotParams(this, varargin)
% Plot parameters
% Plot parameters legacy version
gca;
%P = DiscrimPropValues(this.P);
params = SplotPts(this.P, varargin{:});
Expand Down Expand Up @@ -2923,6 +2939,8 @@ function plotydomain(dom, x0)

end


%% Plotting coverage
function h = plot_cover_stats(this)
% Plots coverage results in all projections as percentage bars
if ~isempty(this.CoverRes)
Expand Down Expand Up @@ -3373,7 +3391,7 @@ function plotydomain(dom, x0)

end


%% Requirements - sort of deprecated per BreachRequirement class
function SortbyRob(this)
sat_values = this.GetSatValues();
Expand Down
Loading

0 comments on commit 1f8a495

Please sign in to comment.