rng(100,'twister')
uqlab  

ModelOpts.mHandle = @(X) uq_evalModel(myKriging, X) - 5;
 
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(1).Type = 'constant';

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

RBDOOpts.Input.DesVar(3).Name = 'A1';
RBDOOpts.Input.DesVar(3).Type = 'constant';

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

InputOpts.Marginals(1).Name = 'E1' ;   
InputOpts.Marginals(1).Type = 'Gaussian';
% InputOpts.Marginals(1).Cov = 0.1;
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.01;
RBDOOpts.TargetBeta = 2;


RBDOOpts.Optim.MaxIter = 500;

RBDOOpts.Type = 'RBDO';
RBDOOpts.Method = 'QMC';

RBDO_KrgOpts = RBDOOpts;

RBDO_KrgOpts.Metamodel.Type = 'Kriging';

KrgOpts.EstimMethod = 'ML';
KrgOpts.Corr.Family = 'matern-5_2';
KrgOpts.Corr.Isotropic = false;
KrgOpts.Optim.Method = 'HGA';
KrgOpts.ExpDesign.NSamples = 10;

RBDO_KrgOpts.Metamodel.KRIGING = KrgOpts;

RBDO_KrgOpts.Metamodel.Enrichment.Convergence = {'stopSign','stopDf'};
RBDO_KrgOpts.Metamodel.Enrichment.ConvThreshold = 0.001;
RBDO_KrgOpts.Metamodel.Enrichment.MaxAdded = 50;
RBDO_KrgOpts.Metamodel.Enrichment.Points = 2;

%  'CCMAES'
RBDO_KrgOpts.Optim.Method = 'HGA';

myRBDO_Krg = uq_createAnalysis(RBDO_KrgOpts);

uq_print(myRBDO_Krg)

uq_display(myRBDO_Krg)