Open SteveZhangBit opened 1 year ago
Breach should have control of these parameters, i.e., if you change them in the matlab workspace, it will indeed not work for the model interfaced by Breach. More precisely, the way it works is as follows:
>> B = BreachSimulinkSystem(mdl_name, {'a', 'b'}); % Creates a Breach interface object to mdl_name, with control over a and b
>> B.SetParam('a', 5); % Set parameter a to 5 for Breach model
>> B.Sim(T); Simulate for some time
>> B.PlotSignals(); % Plots resulting signals
Then you can easily simulate many different values if you assign several values for a and b
>> B.SetParam('b', 0:.2:1); % Set parameter b to multiple values between 0 and 1
>> B.Sim(T); Simulate for some time (will do 6 simulations)
>> B.PlotSignals(); % Plots resulting signals
You can look into BrDemo.AFC1_Interface
and BrDemo.AFC2_Simulation
for some more details and examples. Hope this helps.
Thank you very much! This works!
Hi Alex, I have a follow-up question about this.
Suppose I have a Simulink model with input a
. I have something like:
lower = 0;
higher = 10;
B = BreachSimulinkSystem(name);
B.SetParamRanges({'a'}, [lower, higher]);
lower
and higher
are meta parameters that I set in the Matlab workspace. They are not system parameters.
Now, is it possible to set ranges for lower
and higher
, and let Breach to search for concrete values for them to falsify the system.
For example, lower_range = [0 5]; higher_range = [6 10]
. Now I want Breach to first sample a value for lower and higher, e.g., lower = 3; higher = 7
. Then, given this value, it will update the range of input a
to be [3 7]
. Finally, Breach uses this dynamically generated input range to falsify the system.
Is this possible to do with Breach? Thank you very much!
Hi,
Not directly I think, but you can certainly wrap a small script around easily for this purpose. Note that you can create simple BreachSet to sample sets, e.g.,
B = BreachSet({'low', 'high'});
B.SetParamRanges({'low','high'},[ 0 5; 6 10]);
B.QuasiRandomSample(10); % get 10 samples, i.e., pair of values for low and high in specified ranges
samples = B.GetParam({'low', 'high'}); % extract the 10 samples
... % use samples values next
I'm not sure if that is something like that that you have in mind though. For your particular example, I'm also not sure why you would do this rather than directly looking for false input in the full range [0 10]... ?
Thank you, this is really helpful!
And I also agree I have to rethink the nuance of those parameters :)
Given a Simulink model, I initialize its parameters like
before interfacing with Breach. It seems like Breach will create a new model with _breach.slx suffix. However, if I change the value of these parameters, Breach seems to use the previously generated model with the old values.
So how can I let Breach simulate the model with the new parameter assignments?
Thank you!