rng(100,'twister')
uqlab  

ModelOpts.mHandle = @(X) uq_evalModel(myPCE, X) - 4;
 
myModel = uq_createModel(ModelOpts);
 
RBDOOpts.LimitState.Model = myModel ;
 
RBDOOpts.Cost.mString = '3.1415.*100.*X(:,1).*(200 + 100./X(:,2)).*(100./X(:,2))';
% Design variables
RBDOOpts.Input.DesVar(1).Name = 'LR';
RBDOOpts.Input.DesVar(1).Type = 'Uniform';
RBDOOpts.Input.DesVar(1).Moments  = [3 20];

RBDOOpts.Input.DesVar(2).Name = 'RT';
RBDOOpts.Input.DesVar(2).Type = 'Uniform';
RBDOOpts.Input.DesVar(2).Moments  = [20.1 30];

RBDOOpts.Input.DesVar(3).Name = 'A1';
RBDOOpts.Input.DesVar(3).Type = 'Uniform';
RBDOOpts.Input.DesVar(3).Moments  = [0 90];

RBDOOpts.Input.DesVar(4).Name = 'A2';
RBDOOpts.Input.DesVar(4).Type = 'Uniform';
RBDOOpts.Input.DesVar(4).Moments  = [0 90];

InputOpts.Marginals(1).Name = 'E1' ;   
InputOpts.Marginals(1).Type = 'Gaussian';
InputOpts.Marginals(1).Moments = [102000, 10200];
% RBDOOpts.Input.EnvVar(5).Cov = 0.1;

Input = uq_createInput(InputOpts);   

RBDOOpts.Input.EnvVar = Input;

RBDOOpts.Optim.Bounds = [3 20.1 0 0; 20 30 90 90];
RBDOOpts.Optim.StartingPoint = [4 25 45 45];
% RBDOOpts.TargetPf = 0.05;
RBDOOpts.TargetBeta = 2;
RBDOOpts.Optim.MaxIter = 500;

RBDOOpts.Type = 'RBDO';
RBDOOpts.Method = 'two-level';
MCCOpts = RBDOOpts;
MCCOpts.Reliability.Simulation.MaxSampleSize = 5e4;
MCCOpts.Optim.MaxIter = 350;
myRBDO_MCC = uq_createAnalysis(MCCOpts);
uq_print(myRBDO_MCC)
uq_display(myRBDO_MCC)

