Questions about SSE surrogate model

Dear Uqlab team:

Congratulations on the milestone work of your.

Here, I have a question to ask, when I use my own external dataset to construct the SSE surrogate model, the Uqlab always reports an error:the model property mFile, or mString or mHandle needs to be defined!

I’m sure my dataset is correct, because I used it and same code to build PCE and Kriging, which can run perfectly, and the LOO error is close to 0.

Therefore, I would like to ask you whether the dataset for constructing SSE model can be an external dataset (probabilistic finite element analysis results), or can it only be explicit function (like the example you gave)?

Here, I paste the code.
When SSE is replaced with PCE, it can run perfectly.

%% 1 - INITIALIZE UQLAB
clearvars
uqlab

%% 2 - FORWARD MODEL
FILELOCATION = fullfile(uq_rootPath, ‘Examples’, ‘SimpleDataSets’,…
‘supportbeam’);
load(fullfile(FILELOCATION,‘Supportbeam_DOE40.mat’), ‘X’, ‘Y’);
load(fullfile(FILELOCATION,‘Supportbeam_VAL30.mat’), ‘Xval’, ‘Yval’);

%% 3 - PRIOR DISTRIBUTION OF THE MODEL PARAMETERS
Input.Marginals(1).Name = ‘E’;
Input.Marginals(1).Type = ‘Lognormal’;
Input.Marginals(1).Moments = [30e9 4.5e9]; % (N/m^2)
%%
myInput = uq_createInput(Input);

%% 4 - STOCHASTIC SPECTRAL EMBEDDING (SSE) METAMODELS
metaOpts.Type = ‘Metamodel’;
metaOpts.MetaType = ‘SSE’;
metaOpts.ExpOptions.Degree = 0:2;
MetaOpts.ExpDesign.X = X;
MetaOpts.ExpDesign.Y = Y;
MetaOpts.ValidationSet.X = Xval;
MetaOpts.ValidationSet.Y = Yval;
mySSE = uq_createModel(MetaOpts);
uq_print(mySSE)
uq_display(mySSE)

%% 5 - VALIDATION OF THE RESULTS
Yval = uq_evalModel(mySSE,Xval);
YSSE = uq_evalModel(mySSE,Xval);

%%
fprintf(‘SSE metamodel validation error: %5.4e\n’, mySSE.Error.Val)
fprintf(‘SSE metamodel LOO error: %5.4e\n’, mySSE.Error.LOO)

However, when using the SSE meta model, the following errors are reported:

The model property mFile, or mString or mHandle needs to be defined!

uq_initialize_uq_default_model (line 30)
error(‘The model property mFile, or mString or mHandle needs to be defined!’)

uq_core_module/run_initialization_script (line 208)
initHandle(obj);

uq_core_model/add_module (line 100)
success = this.run_initialization_script(obj);

uq_createModel (line 116)
eval(str);

Copy_of_uq_Example_SSE_04_multipleOutputs (line 32)
mySSE = uq_createModel(MetaOpts);

I look forward to your help, and thank you very much.
Best regards

supportbeam.zip (2.0 KB)

Dear Felix,
There’s a simple error:

metaOpts.Type = ‘Metamodel’;
metaOpts.MetaType = ‘SSE’;
metaOpts.ExpOptions.Degree = 0:2;
MetaOpts.ExpDesign.X = X;
MetaOpts.ExpDesign.Y = Y;

As you can see, the first three lines are lowercase, while the following are uppercase. Matlab is case-sensitive, so you are not telling UQLab to create a Metamodel. It’s easily fixed by making the first three lines uppercase (metaOpts => MetaOpts).

Best
stefano

1 Like

Dear Porf. Marelli:
Thank you very much for your answer.
I’m sorry I overlooked this error when checking the code.
Have a nice weekend

Dear Porf. Marelli:

Here I want to report a possible small mistake.
When I run ‘Example_ SSE_ 01_ complexFunction’ with my own dataset(Multiple output),

myFigures = uq_display(mySSE, [1]); 
%% I used this code in PCE to specify that the output which can run perfectly

However, The system reports the following errors:

You can specify the outputs you want to be displayed with the syntax:
uq_display(SSEModule, OUTARRAY)
where OUTARRAY is the index of desired outputs, e.g. 1:3 for the first three

Error: Expected one output from a curly bracket or dot index expression, but the result was 10

Then I change the code as prompted:

myFigures = uq_display(mySSE, {1:3}); 
or
myFigures = uq_display(mySSE, [1:3]); 
or
myFigures = uq_display(mySSE, 1); 
or etc ; 

The results all reported the same error. I didn’t find a solution in the manual, so I can only ask again here.
I’m very sorry to disturb you and hope you have a nice weekend!

Best

1 Like

Dear Felix
thanks a lot for the feedback.

I can indeed reproduce the error you observe, and I confirm it’s a bug. To be fair, there are actually two separate issues, not just one:

  1. displaying a single output of choice, and
  2. displaying an array of outputs.

I can offer you a quick workaround for issue 1. :

  • open file uq_SSE_display.m with the following command:
    edit uq_SSE_display
  • now go to line 52, and change:
    nDim = SSEModel.SSE.Input.Dim;
    to:
    nDim = SSEModel.SSE(1).Input.Dim;

This should at least allow you to use the syntax:

myFigures = uq_display(mySSE,1);
myFigures = uq_display(mySSE,2);

In the meantime, I will alert the dev team and create a bugfix ticket for the whole issue, as it seems to be non-trivial.

Thanks a lot for reporting this and have a good weekend
Stefano

P.S.
No need to be formal: I’m not even a professor :wink:
s

1 Like

Dear Marelli:
I am very pleased with your answer, the program was able to run based on your tips.

However, Comparison of the results has error as follow:

error: Index exceeds the number of array elements (1).  Copy_of_uq_Example_SSE_01_complexFunction (line 190)
plotAx = myFigures{1}.Children(2);

I observed that my Figures in example 1 is 1*2 cell, but when I use

myFigures = uq_display(mySSE,1)

replaces

myFigures = uq_display(mySSE)

Unexpectedly, my Figures becomes 1*3 cell, so I know that I should modify the numbers in the following code, but always never debug successfully.

plotAx = myFigures{1}.Children(2);
plotPCEX = plotAx.Children(2).XData.';
plotPCEY = uq_evalModel(myPCE, plotPCEX);

So I think it might not be as simple as I thought, and maybe the problem gets complicated after having specified a single output of choice in the multiple output.

I hope you give me advice again, thank you very much.

Best regards

1 Like

Dear @felix ,
Thanks for your message.

Unfortunately I cannot dedicate time for individual custom requests, but I will ask the dev team to investigate the inconsistency.

Just two small comments:

  • returning figure handles from uq_display is a feature in its infancy, there was no time to properly design and propagate it throughout the various modules for this release, so I’m not surprised about inconsistencies. It will be addressed in the next UQLab releases.
  • uq_display is intended as a quick diagnostic/visualization tool, so I strongly recommend creatong your own visualization routines for publications/reports/etc.

Best regards and happy valentine’s day
Stefano

1 Like

Hi @felix,

I modified ‘Example_ SSE_ 01_ complexFunction’ to have multiple outputs, but I cannot reproduce your error. In my case, myFigures = uq_display(mySSE,1) is an array of dimension 1\times2 (the first figure is the partition of the input space, and the second one illustrates the tree). Note that myFigures = uq_display(mySSE) is equivalent to the previous case: if the output array is not specified, uq_display will plot only those of the first output. Besides, myFigures = uq_display(mySSE,1:3) produces an array of 1\times6, as every output is associated with two figures.

The line plotAx = myFigures{1}.Children(2) extracts the upper plot of the first figure that shows the training points and the SSE fit. When running this line, you should keep the window of the figures open.

Could you please try again? If the problem persists, could you please share your code here so that I can further look for the issue?

Best,
Xujia

3 Likes

Dear Marelli:

Thank you very much for your guidance, and I am very sorry to disturb you in your busy schedule.
Wish Uqlab to thrive :smile:

Best regards

1 Like

Dear Xu:
Thanks for your help.
I still failed to solve the problem, here I post the code.

In my code I used two sets of external datasets to construct the SSE.
The case1 is a single output and it works perfectly; the case2 is 10 D multiple output, the previous error pop up when I specify a single output use myFigures = uq_display(mySSE,1) , so that I can’t generate fit and compare plots for SSE and PCE.

%% case 1

FILELOCATION = fullfile(uq_rootPath, 'Examples', 'SimpleDataSets',...
    'supportbeam');
load(fullfile(FILELOCATION,'Supportbeam_DOE40.mat'), 'X', 'Y');
load(fullfile(FILELOCATION,'Supportbeam_VAL30.mat'), 'Xval', 'Yval');

%% 3 - PRIOR DISTRIBUTION OF THE MODEL PARAMETERS
Input.Marginals(1).Name = 'E';               % Young's modulus
Input.Marginals(1).Type = 'Lognormal';  
Input.Marginals(1).Moments = [30e9 4.5e9];   % (N/m^2)
myInput = uq_createInput(Input);

and

%% case 2
% FILELOCATION = fullfile(uq_rootPath, 'Examples', 'SimpleDataSets',...
%     'plate_shell');
% load(fullfile(FILELOCATION,'plate_shell_DOE25.mat'), 'X', 'Y');
% load(fullfile(FILELOCATION,'plate_shell_VAL20'), 'Xval', 'Yval');
% 
% InputOpts.Marginals(1).Name = 'E'; %Concrete modulus of elasticity
% InputOpts.Marginals(1).Type = 'Lognormal';
% InputOpts.Marginals(1).Moments = [7.1e8 7.1e7]; % (Pa)
% 
% InputOpts.Marginals(2).Name = 'D'; %Concrete modulus of elasticity
% InputOpts.Marginals(2).Type = 'Lognormal';
% InputOpts.Marginals(2).Moments = [2700 270]; % (Pa)
% 
% myInput = uq_createInput(InputOpts);

Thank you very much!

Bests

code.zip (8.3 KB)

Hi @felix,

Thanks for sharing the code. In Case 2, myFigures = uq_display(mySSE,1) indeed produces a cell of size 1\times 3: the first one is the “partition of quantile space”, the second one is “partition physical space” and the third one is the partition tree. As there is no subplot in the first figure (it shows only the partition of the quantile space), plotAx = myFigures{1}.Children(2) will not be able to access its second “children”.

The difference between Case 1 and Case 2 is the input dimension. In Case 1, we have only one input, and uq_display (Line 168) calls the function uq_SSE_display_partition_physical1D which plots both the partition and the fitted curve. That’s why there are two Children of this figure. In Case 2, however, we have two input variables. In this case, uq_display (Line 170) calls the function uq_SSE_display_partition_physical2D which plots the partition in the physical space. The difference is NOT a bug, as the figures are designed to work with different input dimensions, e.g., we cannot plot the “curve” for examples with more than one input variable (Case 2).

As @ste mentioned, I recommend creating your own routines for plotting.

Best,
Xujia

1 Like

Dear Xu:

Thank you very much for your patient reply, and under your explanation I probably understood the code of SEE.

Later, I will study uq_display to implement the functionality I need.

Thanks again for your outstanding contribution and wish uqlab better and better

Bests