Skip to content

Commit 15d1e2a

Browse files
committed
Add BlackBoxChallenge problem for reliability
Add computeReliabilityIndex in FailureProbability Add beta value in the display Add support for parameter in RandomVariable Gumbel distribution Fix bug in ProbabilisticModel with Performance function but empty Evaluator Add Cinputnames in PerformanceFunction Fix but in Mio where Liomatrix and Lstructure where both were required
1 parent 6f00f86 commit 15d1e2a

18 files changed

+1157
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
%% Problem Definition for the Reliability Problem 14
2+
3+
% Get file name of this script
4+
Sfilename=mfilename;
5+
6+
% Define random variables
7+
RV1=RandomVariable('Sdistribution','uniform', 'lowerbound',70,'upperbound',80);
8+
RV2=RandomVariable('Sdistribution','normal', 'mean',39, 'std',0.1);
9+
RV3=RandomVariable('Sdistribution','gumbel', 'parameter1',1342, 'parameter2',272.9);
10+
RV4=RandomVariable('Sdistribution','normal', 'mean',400, 'std',0.1);
11+
RV5=RandomVariable('Sdistribution','normal', 'mean',250000,'std',35000);
12+
13+
% Define the RVset
14+
Xrvs = RandomVariableSet(...
15+
'Cmembers',{'RV1','RV2','RV3','RV4','RV5'},...
16+
'CXrv',{RV1 RV2 RV3 RV4 RV5}); %% Define the evaluator
17+
18+
% Define Input object
19+
Xin = Input('Sdescription','Blackbox reliability challenge',...
20+
'CSmembers',{'Xrvs'},'CXmembers',{Xrvs});
21+
22+
% Define a Model
23+
Xmdl=Model('Xevaluator',Evaluator,'Xinput',Xin);
24+
25+
Xmio=Mio('Sdescription', 'Performance function', ...
26+
'Spath',pwd,'Sfile',strcat('g',Sfilename),...
27+
'Coutputnames',{'out'},...
28+
'Cinputnames',{'RV1','RV2','RV3','RV4','RV5'},...
29+
'Liomatrix',true,'Lfunction',true); % This flag specify if the .m file is a script or a function.
30+
31+
% Construct a Mio object
32+
Xperfun=PerformanceFunction('Xmio',Xmio); % This flag specify if the .m file is a script or a function.
33+
34+
% Construct the reliability model
35+
Xpm=ProbabilisticModel('Xmodel',Xmdl,'XperformanceFunction',Xperfun);
36+
% Define a Monte Carlo object
37+
% The montecarlo object defines the number of simulations to be used, the number of batches
38+
39+
%assert(exists(Xsimilator),'No Simulator defined file: %s',mfilename('Fullpath'))
40+
41+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function Moutput=gRP14(Minput)
2+
% This function defines the problem RP14.
3+
% Requires 5 inputs and provides 1 output
4+
5+
% Performance function for reliability problem 14
6+
%
7+
% Parameters
8+
% ----------
9+
% Minput : Values of independent variables: columns are the
10+
% different parameters/random variables (x1, x2,...xn) and rows are
11+
% different parameter/random variables sets for different calls.
12+
%
13+
% Returns
14+
% -------
15+
% Moutput : Performance function value for the system.
16+
%
17+
% Reference: https://rprepo.readthedocs.io/en/latest/reliability_problems.html#sec-rp-14
18+
19+
20+
Moutput = Minput(:,1) - ...
21+
32./(pi.*Minput(:,2).^3) .* ...
22+
sqrt( (Minput(:,3).^2 .* Minput(:,4).^2)/16 + Minput(:,5).^2 );
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
%% Problem Definition
2+
% Define random variables
3+
RV1=RandomVariable('Sdistribution','normal', 'mean',10, 'std',3.0);
4+
RV2=RandomVariable('Sdistribution','normal', 'mean',10, 'std',3.0);
5+
6+
% Define the RVset
7+
Xrvs = RandomVariableSet(...
8+
'Cmembers',{'RV1','RV2'},...
9+
'CXrv',{RV1 RV2}); %% Define the evaluator
10+
% Construct a Mio object
11+
Xm=Mio( 'Sdescription', 'Performance function', ...
12+
...'Sscript','for j=1:length(Tinput), Toutput(j).out1=sqrt(Tinput(j).RV1^2+Tinput(j).RV2^2); end', ...
13+
'Spath',pwd,...
14+
'Sfile',[specs.Problem,'_mio'],...
15+
'Liostructure',true,...
16+
'Coutputnames',{'out'},...
17+
'Cinputnames',{'RV1','RV2'},...
18+
'Lfunction',false); % This flag specify if the .m file is a script or a function.
19+
20+
% Construct the Evaluator
21+
Xeval = Evaluator('Xmio',Xm,'Sdescription','Evaluator xmio');
22+
% Define Input object
23+
Xin = Input('Sdescription','Blackbox reliability challenge');
24+
Xthreshold = Parameter('value',0);
25+
Xin = Xin.add('Xmember',Xrvs,'Sname','Xrvs');
26+
Xin = Xin.add('Xmember',Xthreshold,'Sname','Xthreshold');
27+
% Define a Model
28+
Xmdl=Model('Xevaluator',Xeval,'Xinput',Xin);
29+
% Define performance function
30+
Xpf=PerformanceFunction('Scapacity','out','Sdemand','Xthreshold','Soutputname','Vg');
31+
% Construct the model
32+
Xpm=ProbabilisticModel('Xmodel',Xmdl,'XperformanceFunction',Xpf);
33+
% Define a Monte Carlo object
34+
% The montecarlo object defines the number of simulations to be used, the number of batches
35+
36+
Xsimulator = constructSimulator(specs,Xpm);
37+
%%
38+
[XpF, Xoutput] = Xpm.computeFailureProbability(Xsimulator);
39+
40+
makePlots
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
for j=1:length(Tinput)
2+
Toutput(j).out = 2.5 - 0.2357 * (Tinput(j).RV1 - Tinput(j).RV2) + 0.00463 * (Tinput(j).RV1 + Tinput(j).RV2 - 20)^4;
3+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
%% Problem Definition
2+
% Define random variables
3+
RV1=RandomVariable('Sdistribution','normal', 'mean',0,'std',1);
4+
RV2=RandomVariable('Sdistribution','normal', 'mean',0,'std',1);
5+
6+
% Define the RVset
7+
Xrvs = RandomVariableSet(...
8+
'Cmembers',{'RV1','RV2'},...
9+
'CXrv',{RV1 RV2}); %% Define the evaluator
10+
% Construct a Mio object
11+
Xm=Mio( 'Sdescription', 'Performance function', ...
12+
...'Sscript','for j=1:length(Tinput), Toutput(j).out1=sqrt(Tinput(j).RV1^2+Tinput(j).RV2^2); end', ...
13+
'Spath',pwd,...
14+
'Sfile',[specs.Problem,'_mio'],...
15+
'Liostructure',true,...
16+
'Coutputnames',{'out'},...
17+
'Cinputnames',{'RV1','RV2'},...
18+
'Lfunction',false); % This flag specify if the .m file is a script or a function.
19+
20+
% Construct the Evaluator
21+
Xeval = Evaluator('Xmio',Xm,'Sdescription','Evaluator xmio');
22+
% Define Input object
23+
Xin = Input('Sdescription','Blackbox reliability challenge');
24+
Xthreshold = Parameter('value',0);
25+
Xin = Xin.add('Xmember',Xrvs,'Sname','Xrvs');
26+
Xin = Xin.add('Xmember',Xthreshold,'Sname','Xthreshold');
27+
% Define a Model
28+
Xmdl=Model('Xevaluator',Xeval,'Xinput',Xin);
29+
% Define performance function
30+
Xpf=PerformanceFunction('Scapacity','out','Sdemand','Xthreshold','Soutputname','Vg');
31+
% Construct the model
32+
Xpm=ProbabilisticModel('Xmodel',Xmdl,'XperformanceFunction',Xpf);
33+
% Define a Monte Carlo object
34+
% The montecarlo object defines the number of simulations to be used, the number of batches
35+
36+
Xsimulator = constructSimulator(specs,Xpm);
37+
%%
38+
[XpF, Xoutput] = Xpm.computeFailureProbability(Xsimulator);
39+
40+
makePlots
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
for j=1:length(Tinput)
2+
Toutput(j).out = 2 - Tinput(j).RV2 + ( 4 * Tinput(j).RV1 )^4;
3+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
%% Problem Definition
2+
RV1=RandomVariable('Sdistribution','normal', 'mean',1.5,'std',1);
3+
RV2=RandomVariable('Sdistribution','normal', 'mean',2.5,'std',1);
4+
5+
% Define the RVset
6+
Xrvs = RandomVariableSet(...
7+
'Cmembers',{'RV1','RV2'},...
8+
'CXrv',{RV1 RV2}); %% Define the evaluator
9+
% Construct a Mio object
10+
Xm=Mio( 'Sdescription', 'Performance function', ...
11+
...'Sscript','for j=1:length(Tinput), Toutput(j).out1=sqrt(Tinput(j).RV1^2+Tinput(j).RV2^2); end', ...
12+
'Spath',pwd,...
13+
'Sfile',[specs.Problem,'_mio'],...
14+
'Liostructure',true,...
15+
'Coutputnames',{'out'},...
16+
'Cinputnames',{'RV1','RV2'},...
17+
'Lfunction',false); % This flag specify if the .m file is a script or a function.
18+
19+
% Construct the Evaluator
20+
Xeval = Evaluator('Xmio',Xm,'Sdescription','Evaluator xmio');
21+
% Define Input object
22+
Xin = Input('Sdescription','Blackbox reliability challenge');
23+
Xthreshold = Parameter('value',0);
24+
Xin = Xin.add('Xmember',Xrvs,'Sname','Xrvs');
25+
Xin = Xin.add('Xmember',Xthreshold,'Sname','Xthreshold');
26+
% Define a Model
27+
Xmdl=Model('Xevaluator',Xeval,'Xinput',Xin);
28+
% Define performance function
29+
Xpf=PerformanceFunction('Scapacity','out','Sdemand','Xthreshold','Soutputname','Vg');
30+
% Construct the model
31+
Xpm=ProbabilisticModel('Xmodel',Xmdl,'XperformanceFunction',Xpf);
32+
33+
Xsimulator = constructSimulator(specs,Xpm);
34+
%%
35+
[XpF, Xoutput] = Xpm.computeFailureProbability(Xsimulator);
36+
37+
makePlots
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
for j=1:length(Tinput)
2+
Toutput(j).out = sin(5 * Tinput(j).RV1/2) + 2 - ...
3+
( Tinput(j).RV1^2 + 4) * ( Tinput(j).RV2 - 1 )/20;
4+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
%% Problem Definition
2+
RV1 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
3+
RV2 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
4+
RV3 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
5+
RV4 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
6+
RV5 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
7+
RV6 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
8+
RV7 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
9+
RV8 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
10+
RV9 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
11+
RV10 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
12+
RV11 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
13+
RV12 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
14+
RV13 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
15+
RV14 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
16+
RV15 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
17+
RV16 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
18+
RV17 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
19+
RV18 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
20+
RV19 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
21+
RV20 = RandomVariable('Sdistribution','exponential', 'mean',1,'std',1);
22+
23+
% Define the RVset
24+
Xrvs = RandomVariableSet(...
25+
'Cmembers',{'RV1','RV2','RV3','RV4','RV5','RV6','RV7','RV8','RV9','RV10',...
26+
'RV11','RV12','RV13','RV14','RV15','RV16','RV17','RV18','RV19','RV20'},...
27+
'CXrv',{RV1 RV2 RV3 RV4 RV5 RV6 RV7 RV8 RV9 RV10 ...
28+
RV11 RV12 RV13 RV14 RV15 RV16 RV17 RV18 RV19 RV20}); %% Define the evaluator
29+
% Construct a Mio object
30+
Xm=Mio( 'Sdescription', 'Performance function', ...
31+
...'Sscript','for j=1:length(Tinput), Toutput(j).out1=sqrt(Tinput(j).RV1^2+Tinput(j).RV2^2); end', ...
32+
'Spath',pwd,...
33+
'Sfile',[specs.Problem,'_mio'],...
34+
'Liostructure',true,...
35+
'Coutputnames',{'out'},...
36+
'Cinputnames',{'RV1','RV2','RV3','RV4','RV5','RV6','RV7','RV8','RV9','RV10',...
37+
'RV11','RV12','RV13','RV14','RV15','RV16','RV17','RV18','RV19','RV20'},...
38+
'Lfunction',false); % This flag specify if the .m file is a script or a function.
39+
40+
% Construct the Evaluator
41+
Xeval = Evaluator('Xmio',Xm,'Sdescription','Evaluator xmio');
42+
% Define Input object
43+
Xin = Input('Sdescription','Blackbox reliability challenge');
44+
Xthreshold = Parameter('value',0);
45+
Xin = Xin.add('Xmember',Xrvs,'Sname','Xrvs');
46+
Xin = Xin.add('Xmember',Xthreshold,'Sname','Xthreshold');
47+
% Define a Model
48+
Xmdl=Model('Xevaluator',Xeval,'Xinput',Xin);
49+
% Define performance function
50+
Xpf=PerformanceFunction('Scapacity','out','Sdemand','Xthreshold','Soutputname','Vg');
51+
% Construct the model
52+
Xpm=ProbabilisticModel('Xmodel',Xmdl,'XperformanceFunction',Xpf);
53+
54+
Xsimulator = constructSimulator(specs,Xpm);
55+
%%
56+
[XpF, Xoutput] = Xpm.computeFailureProbability(Xsimulator);
57+
58+
makePlots
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
for j=1:length(Tinput)
2+
Toutput(j).out=Tinput(j).RV1+...
3+
Tinput(j).RV2+...
4+
Tinput(j).RV3+...
5+
Tinput(j).RV4+...
6+
Tinput(j).RV5+...
7+
Tinput(j).RV6+...
8+
Tinput(j).RV7+...
9+
Tinput(j).RV8+...
10+
Tinput(j).RV9+...
11+
Tinput(j).RV10+...
12+
Tinput(j).RV11+...
13+
Tinput(j).RV12+...
14+
Tinput(j).RV13+...
15+
Tinput(j).RV14+...
16+
Tinput(j).RV15+...
17+
Tinput(j).RV16+...
18+
Tinput(j).RV17+...
19+
Tinput(j).RV18+...
20+
Tinput(j).RV19+...
21+
Tinput(j).RV20-8.951;
22+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
%% Problem Definition
2+
RV1=RandomVariable('Sdistribution','normal', 'mean',0,'std',1);
3+
RV2=RandomVariable('Sdistribution','normal', 'mean',0,'std',1);
4+
5+
% Define the RVset
6+
Xrvs = RandomVariableSet(...
7+
'Cmembers',{'RV1','RV2'},...
8+
'CXrv',{RV1 RV2}); %% Define the evaluator
9+
% Construct a Mio object
10+
Xm=Mio( 'Sdescription', 'Performance function', ...
11+
...'Sscript','for j=1:length(Tinput), Toutput(j).out1=sqrt(Tinput(j).RV1^2+Tinput(j).RV2^2); end', ...
12+
'Spath',pwd,...
13+
'Sfile',[specs.Problem,'_mio'],...
14+
'Liostructure',true,...
15+
'Coutputnames',{'out'},...
16+
'Cinputnames',{'RV1','RV2'},...
17+
'Lfunction',false); % This flag specify if the .m file is a script or a function.
18+
19+
% Construct the Evaluator
20+
Xeval = Evaluator('Xmio',Xm,'Sdescription','Evaluator xmio');
21+
% Define Input object
22+
Xin = Input('Sdescription','Blackbox reliability challenge');
23+
Xthreshold = Parameter('value',0);
24+
Xin = Xin.add('Xmember',Xrvs,'Sname','Xrvs');
25+
Xin = Xin.add('Xmember',Xthreshold,'Sname','Xthreshold');
26+
% Define a Model
27+
Xmdl=Model('Xevaluator',Xeval,'Xinput',Xin);
28+
% Define performance function
29+
Xpf=PerformanceFunction('Scapacity','out','Sdemand','Xthreshold','Soutputname','Vg');
30+
% Construct the model
31+
Xpm=ProbabilisticModel('Xmodel',Xmdl,'XperformanceFunction',Xpf);
32+
33+
Xsimulator = constructSimulator(specs,Xpm);
34+
%%
35+
[XpF, Xoutput] = Xpm.computeFailureProbability(Xsimulator);
36+
37+
makePlots
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
for j=1:length(Tinput)
2+
Toutput(j).out = 3 - Tinput(j).RV1 * Tinput(j).RV2;
3+
end
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function [outputArg1,outputArg2,outputArg4,outputArg5] = computeFailureProbability(inputArg1,inputArg2)
2+
%UNTITLED4 Summary of this function goes here
3+
% Detailed explanation goes here
4+
specs = inputArg1;
5+
problem = inputArg2;
6+
specs.Problem = problem;
7+
run(fullfile(problem,[problem,'.m']))
8+
outputArg1 = XpF.pfhat;
9+
outputArg2 = -norminv(XpF.pfhat);
10+
outputArg4 = XpF;
11+
outputArg5 = Xoutput;
12+
end
13+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
function [outputArg1,outputArg2] = constructSimulator(inputArg1,inputArg2)
2+
%UNTITLED5 Summary of this function goes here
3+
% Detailed explanation goes here
4+
5+
specs = inputArg1;
6+
Xpm = inputArg2;
7+
8+
switch lower(specs.SimType)
9+
case 'mc'
10+
Xsimulator = MonteCarlo('Nsamples',specs.N,'Nbatches',1);
11+
case 'ls'
12+
Nlines = specs.N;
13+
XlsFD=LocalSensitivityFiniteDifference('Xtarget',Xpm,'Coutputnames',{'Vg'});
14+
XlsMC=LocalSensitivityMonteCarlo('Xtarget',Xpm,'Coutputnames',{'Vg'});
15+
XgFD = XlsFD.computeGradient;
16+
switch lower(specs.grad)
17+
case 'sns'
18+
XgSNS=XlsMC.computeGradientStandardNormalSpace;
19+
Xsimulator = LineSampling('Nlines',Nlines,'Xgradient',XgSNS,'Vset',specs.Vset);
20+
case 'phy'
21+
Xgrad = XlsFD.computeGradient;
22+
Xsimulator = LineSampling('Nlines',Nlines,'Xgradient',Xgrad,'Vset',specs.Vset);
23+
case 'ind'
24+
Xlsm=XlsFD.computeIndices;
25+
Xsimulator=LineSampling('Nlines',Nlines,'XlocalSensitivityMeasures',Xlsm,'Vset',specs.Vset);
26+
end
27+
case 'als'
28+
Xsimulator = AdaptiveLineSampling('Nlines',specs.N);
29+
case 'ss'
30+
Xsimulator = SubsetSimulation('Nsamples',specs.N,'Nbatches',1);
31+
end
32+
33+
outputArg1 = Xsimulator;
34+
% outputArg2 = inputArg2;
35+
end
36+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
RP24
3+
\eqalign{
4+
& {g_{\mathrm{comp}}}({\bf X}) = 2.5 - 0.2357 \cdot ({X_1} - {X_2}) + 0.00463 \cdot {({X_1} + {X_2} - 20)^4} \cr
5+
& {g_{\mathrm{sys}}}({\bf X}) = {g_{\mathrm{comp}}}({\bf X}) \cr}

0 commit comments

Comments
 (0)