Uqlink and PCK

Hello everyone,

I am having a problem using UQlab that I am trying to solve, until now not successfully. I coupled UQlab with abaqus. I defined my inputs (matrix 200x5) and then rund 200 simulations with abaqus. I got then the output data (matrix 200x2). I already performed successfully PCE. I would like to use other technique, such as PCK. When performing the analysis, I get this error:

Index in position 2 exceeds array bounds (must not exceed 4).
Error in uq_PCK_eval (line 14)
X = X(:,current_model.Internal.Input.nonConst);

Error in uq_eval_uq_metamodel (line 14)
        [varargout{1:nargout}] = uq_PCK_eval(current_model, X);

Error in uq_sobol_indices (line 88)
AllValues = uq_evalModel(Options.Model,[Sample1; Sample2; Pick2Freeze1]);

Error in uq_sensitivity (line 85)
            results = uq_sobol_indices(CurrentAnalysis);

Error in uq_initialize_uq_sensitivity (line 863)

Error in beammc2 (line 112)
PCESobolAnalysis = uq_createAnalysis(PCESobol) ;

I tried to load the sample that I want to use as experimental set for the metamodel in a separate code file, but then I get another error, different this time:

Dot indexing is not supported for variables of this type.

Error in uq_PCK_calculate_coefficients (line 44)
Xred = current_model.ExpDesign.X(:,current_model.Internal.Input.nonConst);

Error in uq_calculateMetamodel (line 24)
        success = uq_PCK_calculate_coefficients(current_model);

Error in uq_initialize_uq_metamodel (line 362)
success = uq_calculateMetamodel(current_model);

Error in Untitled2 (line 47)
myPCE = uq_createModel(metaopts)

Can someone help me in understading what I am doing wrong?

Thank you!


Does the same piece of code works with the PCE, but not for the PCK ?
For me it usually works fine when switching from PCE to PCK.
Based on my experience, the second error appears when I forget to start uqlab at the begining of the file.


1 Like

Hi, thank you for your answer.

Yes, that’s the same piece of code that does not work if I switch it to PCK.
I tried to run another self-made example without UQLink and it works. It is that specific file that does not work with PCK. With PCE everything runs smoothly.

For the second error, I started uqlab at the beginning of the code.

If you send your code, with the reproductible errors, maybe I can take a look if you want. You can save your experimental design in .mat variables, and save the programs in a .zip file.
Best regards,

Hi, thanks for the answer and for the offered help. Here attached the code. Please note that line 59-63 loads the experimental design, you just need to change that line in your local path. Thank you if you will have the time to look at it.
UQLabBeam.zip (2.7 KB)

Dear @DorotC,
I was able to run your code, thanks. There is a small issue, when I switch from PCE to PCK in line 76. I am not really sure where it comes from, but to fix this issue: you just need to define which model and which input you want to use, when you define the Sobol and the Reliability analysis.

It means the end of your could should looks like :
For the sensitivity :

PCESobol.Type = ‘Sensitivity’;
PCESobol.Method = ‘Sobol’;
PCESobol.Input = myInput ;
PCESobol.Model = myPCK ;
PCESobol.Sobol.Order = 2;
PCESobolAnalysis = uq_createAnalysis(PCESobol) ;

And for the reliabiility :

MCSopt.Type = ‘Reliability’ ;
MCSopt.Method = ‘AKMCS’ ;
MCSopt.Input = myInput ;
MCSopt.Model = myPCK ;
MCSopt.LimitState.Threshold = 0;
MCSopt.LimitState.CompOp = ‘<=’ ;
myMCS = uq_createAnalysis(MCSopt) ;

I hope this helps,

1 Like

I have two smalls remark on your code, more about UQ :

  • 20 samples in your experimental design is, I think, a too small sample size, specially with 5 inputs. I recommand to use a little bit more.
  • You do a PCK, and then AKMCS. Based on a PCK, I recommand to do the reliability analysis with Monte Carlo (AKMCS uses a metamodel, so you are doing a metamodel on a metamodel : it is not really relevant). To do your reliability analysis, you can get 10^6 samples and count how much are smaller than 0 :

X = uq_getSample(myInput,1000000);
Y = uq_evalModel(myPCK, X);
length(find(Y < 0))/length(Y)

I think this last point is quite related to your recent post.



thanks for your time. I get everything you said, and I think I makes sense.

I just have few comments, I hope we can generate a discussion on that:

  1. What is the rule to decide the initial number of samples of experimental design? Honestly, I looked at some papers and 20 points with more or less the same amount of input parameters was decided; (see Structural reliability analysis based on ensemble learning of surrogate models - ScienceDirect). So I am a bit confused here…

  2. My aim was to perform AKMCS using a metamodel constructed with PCK. As far as I understood, the algoritm has to update the metamodel using new point that it found using the learning function. The doubt that I had was that in the code that I sent you, the metamodel is defined “outside” the structure of AKMCS and I was not sure was the same thing as defining the analysis as you just did.

  3. Yesterday I tried to exclude the constant from the inputs and I worked. It is not returning anymore any mistake. Of course, I defined a model for AKMCS as well.

Thanks again,


Hi @DorotC ,

Thank you @M_Groslambert for pointing out the problem in the codes Dorotea shared.

I think issue is that the problem is not well set-up in UQLab. Generally UQLab uses by default the latest input and model objects created. In this case, the latest model defined is the PC-Kriging model. UQLab will then refer to it to do both the sensitivity analysis and reliability analysis.

For AK-MCS, I assume this is probably not what you intended to do. When you do AK-MCS, you would like the algorithm to call the original model (in this case the one in Abaqus through UQLink). Instead what happens is that the AK-MCS algorithm thinks the original model is the PC-Kriging model and calls it to enich the ED for the Kriging model, which doesn’t make sense obviously. I guess what you wanted to do was to define PC-Kriging as the metamodel used in AK-MCS. In this case, the proper way to set this in UQLab is to use the option:

MCSopt.AKMCS.Metamodel = 'PCK'

So you still need to keep the definitoin of the UQLink model somewhere in the session. Furthermore, since your QoI is not directly the result of the Abaqus run but is post-processed in lines 65-70, you need to define a wrapper function that will i. take as input the random variables X and the UQLink model, ii. do the post-processing, and iii. eventually return the final response (Gtruss).
This model should then be the one fed to AK-MCS to perform enrichment.

I will let you have a look first. If you still have issues setting your problem I can guide you further.

I think once you fix this you won’t have problems with constants anymore. The error is probably due to a use-case that we did not anticipate.

Now to reply to your other questions:

  1. I think 20 points are enough to start the algorithm, you just need to make sure that you don’t have a premature convergence by properly setting your convergence criterion.

  2. Yes exactly, that was the issue. As an additional point: Instead of using AK-MCS directly, you can also try the new active learning module where you have much more possibilities (i.e., not only limited to Kriging/PC-Kriging and Monte Carlo simulation).

Please let me know if that is helpful or if you have other questions.