Error while performing PCE methodology

Hi,
I have frequently bumped into this issue which I am not sure why and I would like to have some advise on what can be the issue and how can I solve them. I have two models, one is a simpler with 5 parameter uncertainty and the other one with 8 parameters.
My issue that I am facing is that I have been running the different methods to obtain the PCE coefficients. When I ran for the simpler model, it does seem to work. But then when I ran again, the methods such as the OMP and OLS were not working. I get error message such as this below but then it did work at another time which was weird. So for now only the LARS, SP and BCS is working to produce results for this model:
Matrix dimensions must agree.
Error in uq_omp (line 153)
** h = abs(r’.PsiNorm);*
Error in uq_PCE_omp (line 52)
omp_results = uq_omp(Psi, Y, omp_options);
Error in uq_PCE_calculate_coefficients_regression (line 218)
** omp_results = uq_PCE_omp(univ_p_val, current_model);**
Error in uq_PCE_calculate_coefficients (line 47)
** uq_PCE_calculate_coefficients_regression(current_model);**
Error in uq_calculateMetamodel (line 18)
** success = uq_PCE_calculate_coefficients(current_model);**
Error in uq_initialize_uq_metamodel (line 362)
success = uq_calculateMetamodel(current_model);
Error in AbsXXX_PCEtest (line 235)
myPCE_OMP = uq_createModel(MetaOpts);

But then, when I ran for the complex model, all the methods does not seem to work (OLS, OMP, LARS, SP, BCS) and I get error messages quite similar with each methods such as below:

Incorrect dimensions for matrix multiplication. Check that the number of columns
in the first matrix matches the number of rows in the second matrix. To perform
elementwise multiplication, use ‘.*’.
Error in uq_lar (line 231)
** cj = Psi’*(Y - mu);**
Error in uq_PCE_lars (line 64)
lar_results = uq_lar(Psi, Y, lar_options);
Error in uq_PCE_calculate_coefficients_regression (line 197)
** lars_results = uq_PCE_lars(univ_p_val, current_model);**
Error in uq_PCE_calculate_coefficients (line 47)
** uq_PCE_calculate_coefficients_regression(current_model);**
Error in uq_calculateMetamodel (line 18)
** success = uq_PCE_calculate_coefficients(current_model);**
Error in uq_initialize_uq_metamodel (line 362)
success = uq_calculateMetamodel(current_model);
Error in Abs_XX_DistributionRun (line 158)
myPCE_sparse = uq_createModel(MetaOpts);

I am quite confused to why some methods are working at some times and some are not working at all. Can you guys help me out for this problem?
Thanks!
Best regards,
Visha

To add on, the LRA method worked on the simpler model, but on the complex model, I get an error message as below: My complex model output results are 101 x 1 double values not just a single output values as per the simple model. Does this affect the methods in any way?

Index in position 1 exceeds array bounds (must not exceed 100).
Error in uq_LRA_CV (line 93)
U_train = U_ED(ind_train,:);
Error in uq_LRA_initialize>@(U,Y,CVOpts)uq_LRA_CV(U,Y,CVOpts) (line 284)
@(U ,Y , CVOpts) uq_LRA_CV(U ,Y , CVOpts);
Error in uq_LRA_adaptive_all_d_adapt_r (line 65)
ComputationalOptions.RankSelectionOpts.ScoreFunction(…
Error in uq_LRA_initialize>@(strat,U,Y)uq_LRA_adaptive_all_d_adapt_r(strat,U,Y)
(line 367)
@(strat,U,Y) uq_LRA_adaptive_all_d_adapt_r(strat,U,Y);
Error in uq_LRA_calculate_coefficients (line 66)
ComputationalOptions.SelectionStrategy.SelectionFunction(…
Error in uq_calculateMetamodel (line 20)
success = uq_LRA_calculate_coefficients(current_model);
Error in uq_initialize_uq_metamodel (line 362)
success = uq_calculateMetamodel(current_model);
Error in Abs_XX (line 274)
myLRA = uq_createModel(MetaOpts);

Final input to this topic, I ran the OMP method on the simpler 5 parameter UC model, and it worked fine! However, at this moment, seems like as I mentioned in the first message, applying the different PCE methods on the simpler model, the rest of the methods except the OLS and OMP is not working. I am getting error as below for the OMP now for the simpler model and I am not sure why. Any help for me to move forward could be great!
Matrix dimensions must agree.
Error in uq_omp (line 153)
h = abs(r’.*PsiNorm);
Error in uq_PCE_omp (line 52)
omp_results = uq_omp(Psi, Y, omp_options);
Error in uq_PCE_calculate_coefficients_regression (line 218)
omp_results = uq_PCE_omp(univ_p_val, current_model);
Error in uq_PCE_calculate_coefficients (line 47)
uq_PCE_calculate_coefficients_regression(current_model);
Error in uq_calculateMetamodel (line 18)
success = uq_PCE_calculate_coefficients(current_model);
Error in uq_initialize_uq_metamodel (line 362)
success = uq_calculateMetamodel(current_model);
Error in AbsXX_PCEtest (line 228)
myPCE_OMP = uq_createModel(MetaOpts);

Thank you very much!
Visha

Hi @Vishashalu,
I am a bit confused by your question.

At first glance, it could be that the input and output vectors for the computation of the PCE are not set correctly. The experimental design vector should be as many rows as the number of simulations (Ns) and as many columns as dimensions of the input domain (M=5 in your first case, and M=8 in the second). Similarly, the output vector has as many rows as simulation results (Ns) and as many columns as the number of outputs you want to model with your surrogate (Nout).

Maybe, try to paste part of your code so that it can be easier to identify the problem.

Hi Gian,
Yes maybe too many inputs at the same time, sorry about that. Which part of the code would you like me to show? The main file where I have made the set up for the PCE coefficient computations?
It is actually two different models. I have tried running most of the functionalities for PCE computations on the simpler model and it seem to work fine. I re-installed UQLab and it works. However when I try to accomplish on the other model (as I mentioned the output/quantity of interest for this complex model) has 101 x 1 values not just a single value because of how it is computed. It is not working. I am not sure what is wrong here. But when I ran a simple Monte Carlo simulation on this model, it worked fine and able to produce a histogram.
Thanks! I really need advise for this part.
Best regards,
Visha

Hi Visha,

So we can consider the first model’s problems as solved, right?

As for the second and more complex model, do you mean that the model produces a vector of results of dimensions 101x1 for each computation? If this is true, you should transpose that, so it becomes 1x101 for each model computation. When computing the PCE, then, you will have an outcome of dimensions Nsx101, in agreement with the input experimental design matrix of dimensions NsxM (M=8 here, I suppose). Note that Ns is the size of the experimental design you select at the beginning. In addition, if I got this right, you are building 101 PCEs, one for each model output.

It would be nice to see the part of the code where you set the Input, the Model, and the Metamodel options. Maybe there is something inaccurate there, and it would help find a solution faster.

Hi Gian,

Yes that is correct. The simple model is solved which is great. The second one. Yes that’s correct, this model produces a vector of results of dimensions of 101 x 1 each computation. Here is the code, removed all unwanted description part of it. I used the same code to compute for the simple model:

clearvars

uqlab

rng(100, ‘twister’)

ModelOpts.mFile = ‘uq_AbsSolvResult’;

ModelOpts.isVectorized = false;

myModel = uq_createModel(ModelOpts);

% Specify the marginals:

InputOpts.Marginals(1).Name = ‘X1’;

InputOpts.Marginals(1).Type = ‘Gaussian’;

InputOpts.Marginals(1).Parameters = [1 0.086];

InputOpts.Marginals(2).Name = ‘X2’;

InputOpts.Marginals(2).Type = ‘Gaussian’;

InputOpts.Marginals(2).Parameters = [1 0.05];

InputOpts.Marginals(3).Name = ‘X3’;

InputOpts.Marginals(3).Type = ‘Gaussian’;

InputOpts.Marginals(3).Parameters = [1 0.085];

InputOpts.Marginals(4).Name = ‘X4’;

InputOpts.Marginals(4).Type = ‘Gaussian’;

InputOpts.Marginals(4).Parameters = [1 0.116];

InputOpts.Marginals(5).Name = ‘X5’;

InputOpts.Marginals(5).Type = ‘Gaussian’;

InputOpts.Marginals(5).Parameters = [1 0.06];

InputOpts.Marginals(6).Name = ‘X6’;

InputOpts.Marginals(6).Type = ‘Gaussian’;

InputOpts.Marginals(6).Parameters = [1 0.11];

InputOpts.Marginals(7).Name = ‘X7’;

InputOpts.Marginals(7).Type = ‘Gaussian’;

InputOpts.Marginals(7).Parameters = [1 0.25];

InputOpts.Marginals(8).Name = ‘X8’;

InputOpts.Marginals(8).Type = ‘Gaussian’;

InputOpts.Marginals(8).Parameters = [1 0.2];

myInput = uq_createInput(InputOpts);

MetaOpts.Type = ‘Metamodel’;

MetaOpts.MetaType = ‘PCE’;

MetaOpts.FullModel = myModel;

MetaOpts.Method = ‘LARS’;

MetaOpts.Degree = 3:15;

MetaOpts.ExpDesign.NSamples = 500;

MetaOpts.ExpDesign.Sampling = ‘MC’;

myPCE_sparse = uq_createModel(MetaOpts);

uq_print(myPCE_sparse);

uq_display(myPCE_sparse)

and this always returns error message as below:

Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform
elementwise multiplication, use '.’.
Error in uq_lar (line 231)
cj = Psi’
(Y - mu);
Error in uq_PCE_lars (line 64)
lar_results = uq_lar(Psi, Y, lar_options);
Error in uq_PCE_calculate_coefficients_regression (line 197)
lars_results = uq_PCE_lars(univ_p_val, current_model);
Error in uq_PCE_calculate_coefficients (line 47)
uq_PCE_calculate_coefficients_regression(current_model);
Error in uq_calculateMetamodel (line 18)
success = uq_PCE_calculate_coefficients(current_model);
Error in uq_initialize_uq_metamodel (line 362)
success = uq_calculateMetamodel(current_model);
Error in AbsSolv1_new (line 110)
myPCE_sparse = uq_createModel(MetaOpts);

Thanks Gian for your guidance!
Visha

Nice, have you tried to transpose the output vector of the model?
I think that, given

function Y=uq_AbsSolvResult(X)

where Y is the output vector of dimension 101x1 and X is the input vector of dimension 1x8. Try to add this line

Y = Y';

at bottom of the file uq_AbsSolvResult.m.

I think this should work.

1 Like

Hi Gian,
I tried your solution and I think it worked!! I got this message at the end after the main output results of the coefficients.
------------ Polynomial chaos output ------------
Number of input variables: 8
Maximal degree: 3
q-norm: 1.00
Size of full basis: 165
Size of sparse basis: 6
Full model evaluations: 100
Leave-one-out error: 7.4082817e-01
Modified leave-one-out error: 8.6072384e-01
Mean value: 90.1753
Standard deviation: 1.2525
Coef. of variation: 1.389%
--------------------------------------------------
Warning: The selected PCE has more than 1 output. Only the 1st output will be
printed

In uq_PCE_display (line 20)
In uq_display_uq_metamodel (line 10)
In uq_module/Display
In uq_display (line 4)
In AbsSolv1_new (line 119)
You can specify the outputs you want to be displayed with the syntax:
uq_display(PCEModule, OUTARRAY)
where OUTARRAY is the index of desired outputs, e.g. 1:3 for the first three

Can you tell me if this is something that I have to deal with? Or can I proceed to run sensitivity analysis methodologies and etc?
Thanks a lot for your help Gian!Finally getting somewhere.
Visha

1 Like

Excellent, I am happy it works :slight_smile:

I think there is nothing left to do. For visualization, maybe, since you call the uq_display() function, you will only visualize the first component of your output by writing uq_display(myPCE_sparse), and the next 130 components will be neglected. This is a default option given by UQlab. If you wish to visualize one of them, e.g., the 3rd component, just write uq_display(myPCE_sparse,3).

You can continue with sensitivity analysis I suppose :slight_smile: :grin:

Hi Gian,
Thanks a lot for your help! I will proceed further with the rest and see if its going to work.
Best regards,
Visha

1 Like