# RBDO error based on data-driven surrogate

**URL:** <https://uqworld.org/t/rbdo-error-based-on-data-driven-surrogate/1926>\
**Category:** Community Q&A and How To\
**Created:** [June 26, 2023, 8:47am UTC](https://uqworld.org/t/rbdo-error-based-on-data-driven-surrogate/1926 "2023-06-26T08:47:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![AmosJoseph](https://uqworld.org/user_avatar/uqworld.org/amosjoseph/32/821_2.png) [@AmosJoseph](https://uqworld.org/u/AmosJoseph)\
**Post date:** [June 26, 2023, 8:47am UTC](https://uqworld.org/t/rbdo-error-based-on-data-driven-surrogate/1926/1 "2023-06-26T08:47:37Z")

</div>

[PCE\_RBDO.m](https://uqworld.org/uploads/short-url/6vspQ1UQ94P7k8z4oZ8GllVDJPG.m) (3.4 KB)  
[RBDO.m](https://uqworld.org/uploads/short-url/hdiPRZ22M8Q5fDaXTbTDTuUBGFQ.m) (2.0 KB)

Hi, I build a PCE and conduct RBDO based on PCE. I use PCE for the probabilistic constraint. Above PCE\_RBDO.m is the built PCE. RBDO.m is code for RBDO. Below is the error.

Could you please give some advice? Is there any example for data-driven surrogate (without explicit expression) for RBDO?

error when running RBDO:

Try to use SCRIPT PCE\_RBDO as a function

error: uq\_eval\_uq\_default\_model (line 62)  
[varargout{1:num\_of\_out\_args}] = model\_handle(X);

error: uq\_evalModel (line 121)  
[varargout{1:nargout}] = current\_model.eval(current\_model,varargin{:});

error: uq\_evalPfMC (line 69)  
M\_X = uq\_evalModel( Options.Constraints.Model,Cq ) ;

error: uq\_runReliability (line 52)  
LocalAnalysis.Results = uq\_evalPfMC(d, current\_analysis) ;

error: uq\_twolevel\_evalConstraints (line 6)  
myLocalAnalysis = uq\_runReliability (d, current\_analysis ) ;

error: uq\_cmaesnonlconwrapper (line 7)  
hc = uq\_twolevel\_evalConstraints( d, current\_analysis ) ;

error: uq\_runRBDOptimizer\>@(X)uq\_cmaesnonlconwrapper(X,current\_analysis) (line 140)  
nonlcon = @(X)uq\_cmaesnonlconwrapper( X, current\_analysis ) ;

error: uq\_runRBDOptimizer\>@(x)nonlcon(x) (line 147)  
[Xstar,Fstar,exitflag,output] =  
uq\_c1p1cmaes(@(x)fun(x),x0,sigma0,lb,ub,@(x)nonlcon(x),optim\_options) ;

error: uq\_c1p1cmaes\>@(x)nonlcon(x’) (line 202)  
nonlconfcn = @(x) nonlcon(x’);

error: uq\_c1p1cmaes (line 336)  
g = nonlconfcn(x\_current);

error: uq\_runRBDOptimizer (line 147)  
[Xstar,Fstar,exitflag,output] =  
uq\_c1p1cmaes(@(x)fun(x),x0,sigma0,lb,ub,@(x)nonlcon(x),optim\_options) ;

error: uq\_rbdo (line 52)  
results = uq\_runRBDOptimizer(current\_analysis) ;

error: uq\_analysis/run (line 84)  
this.Results = eval([this.Type ‘(this)’]);

error: uq\_runAnalysis (line 29)  
[varargout{1:nargout}] = current\_analysis.run(current\_analysis, varargin{:});

error: uq\_initialize\_uq\_rbdo (line 1675)  
uq\_runAnalysis(current\_analysis);

error: uq\_core\_module/run\_initialization\_script (line 208)  
initHandle(obj);

error: uq\_core\_analysis/add\_module (line 96)  
success = this.run\_initialization\_script(obj);

error: uq\_createAnalysis (line 83)  
eval(str);

error: RBDO (line 44)  
myRBDO\_MCC = uq\_createAnalysis(MCCOpts);

---

<div class="post-metadata">

**Author:** ![styfen.schaer](https://uqworld.org/user_avatar/uqworld.org/styfen.schaer/32/849_2.png) [@styfen.schaer](https://uqworld.org/u/styfen.schaer)\
**Post date:** [June 27, 2023, 9:26am UTC](https://uqworld.org/t/rbdo-error-based-on-data-driven-surrogate/1926/2 "2023-06-27T09:26:03Z")

</div>

Dear @AmosJoseph

I can’t run your code because the data is missing. However, after a quick look, I suspect you have the same problem as in this post, namely an invalid mFile: [Errors in retrieving the m-file handle for a developed PCE metamodel - #7 by styfen.schaer](https://uqworld.org/t/errors-in-retrieving-the-m-file-handle-for-a-developed-pce-metamodel/1912/7)

Best regards  
Styfen

---

<div class="post-metadata">

**Author:** ![AmosJoseph](https://uqworld.org/user_avatar/uqworld.org/amosjoseph/32/821_2.png) [@AmosJoseph](https://uqworld.org/u/AmosJoseph)\
**Post date:** [June 27, 2023, 9:51am UTC](https://uqworld.org/t/rbdo-error-based-on-data-driven-surrogate/1926/3 "2023-06-27T09:51:35Z")

</div>

[PCE-data.zip](https://uqworld.org/uploads/short-url/yb7VHsaCBltIicGYcNxC6XMa8ow.zip) (27.0 KB)

Hi, above is the data. Please check. Could you help me find the error?

And there is another error:

% RBDOOpts.TargetPf = 0.05;  
RBDOOpts.TargetBeta = 2;

Only failure probability or index can be used, but why?

---

<div class="post-metadata">

**Author:** ![styfen.schaer](https://uqworld.org/user_avatar/uqworld.org/styfen.schaer/32/849_2.png) [@styfen.schaer](https://uqworld.org/u/styfen.schaer)\
**Post date:** [June 27, 2023, 3:30pm UTC](https://uqworld.org/t/rbdo-error-based-on-data-driven-surrogate/1926/4 "2023-06-27T15:30:17Z")

</div>

Dear @AmosJoseph

Did you already test the solution I send you in my previous post and can you confirm that this is not the problem?

You can calculate `RBDOOpts.TargetPf` from `RBDOOpts.TargetBeta` and vice versa as it is also stated in the manual. Therefore, to prevent mistakes you must specify only one of them.

Best regards  
Styfen

---

<div class="post-metadata">

**Author:** ![AmosJoseph](https://uqworld.org/user_avatar/uqworld.org/amosjoseph/32/821_2.png) [@AmosJoseph](https://uqworld.org/u/AmosJoseph)\
**Post date:** [June 30, 2023, 8:05am UTC](https://uqworld.org/t/rbdo-error-based-on-data-driven-surrogate/1926/6 "2023-06-30T08:05:17Z")

</div>

ModelOpts.mHandle = @(X) uq\_evalModel(myPCE, X) - 4;

myModel = uq\_createModel(ModelOpts);

RBDOOpts.LimitState.Model = myModel ;

I change the code like above, the problem seems to be solved.

I define the Design Variables and Environment Variables as below, but with error: “The input dimension is inconsistent with the data.” How should the input be defined to be different from that in PCE?

% 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;

[PCE.m](https://uqworld.org/uploads/short-url/ZMZpFhlvuURbJJew3I9eN6rx1G.m) (1.0 KB)  
[RBDOnew.m](https://uqworld.org/uploads/short-url/Ad1I5C0xN1YrSAphVaXk4H4Bghi.m) (1.5 KB)

---

<div class="post-metadata">

**Author:** ![styfen.schaer](https://uqworld.org/user_avatar/uqworld.org/styfen.schaer/32/849_2.png) [@styfen.schaer](https://uqworld.org/u/styfen.schaer)\
**Post date:** [June 30, 2023, 2:37pm UTC](https://uqworld.org/t/rbdo-error-based-on-data-driven-surrogate/1926/7 "2023-06-30T14:37:03Z")

</div>

Dear @AmosJoseph

I suspect you are messing up your Matlab workspace. If you run the `PCE.m` script first and then `RBDOnew.m` without cleaning up the workspace, the creation of `InputOpts` in `RBDOnew.m` does not create a new struct but modifies the `InputOpts` from `PCE.m` instead. This struct defines already 5 marginals and you’re simply overwriting the first one, which then results in inconsistent dimensions.

So you would better save the `myPCE` variable from `PCE.m`, clear the workspace and then load it when running `RBDOnew.m`.

Best regards  
Styfen

---

<div class="post-metadata">

**Author:** ![AmosJoseph](https://uqworld.org/user_avatar/uqworld.org/amosjoseph/32/821_2.png) [@AmosJoseph](https://uqworld.org/u/AmosJoseph)\
**Post date:** [July 3, 2023, 11:27am UTC](https://uqworld.org/t/rbdo-error-based-on-data-driven-surrogate/1926/8 "2023-07-03T11:27:22Z")

</div>

Hi, the problem has been solved! Many thanks for your help!

Accuracy of built PCE is not good. So I change to Kriging which is better for RBDO. Code is shown below:  
[kriging.m](https://uqworld.org/uploads/short-url/7SwVI0CxINgh81qs3GkYx9cSxdS.m) (907 Bytes)  
[RBDOkriging.m](https://uqworld.org/uploads/short-url/kkOkM6g6gqpvnIfpqtNcD9g4H1K.m) (1.7 KB)

However, running RBDO is slow without result.  
Generally speaking, how long will the RBDO running take?

Then I try [UQLab Examples ➜](https://www.uqlab.com/examples)[RBDO ➜](https://www.uqlab.com/examples) Surrogate-assisted RBDO. Code is shown below, and also the Warning and error obtained very soon:  
[RBDOkrigingSurrogate.m](https://uqworld.org/uploads/short-url/ap67rrzJgVtr7pjwFVJZYSZhG8j.m) (2.0 KB)

Warning: The limit state margin is too small or empty. The entire sample set is taken as candidate for  
enrichment.

> In uq\_enrichED (line 130)  
> In uq\_activeMetamodel (line 146)  
> In uq\_initialize\_uq\_rbdo (line 1663)  
> In uq\_core\_module/run\_initialization\_script (line 208)  
> In uq\_core\_analysis/add\_module (line 96)  
> In uq\_createAnalysis (line 83)  
> In RBDOkrigingSurrogate (line 70)

No feasible solution found!

But how shall the built Kriging be used in Surrogate-assisted RBDO? Could you please provide some help?
