UQWorld

After update receiving error in uq_blockwise_inverse

Hello, I am using UQlab 1.3.0, and using PCE to build a surrogate from existing data. It was functioning before the update, and some changes, I am receiving the following error when I try to execute

myPCE = uq_createModel(MetaOpts);

Warning: Warning: numerical instability!! Gamma for
LAR iteration 2 was set to 0 to prevent crashes.

In uq_lar (line 268)
In uq_PCE_lars (line 60)
In uq_PCE_calculate_coefficients_regression (line 197)
In uq_PCE_calculate_coefficients (line 47)
In uq_calculateMetamodel (line 18)
In uq_initialize_uq_metamodel (line 358)
In uq_core_module/run_initialization_script
In uq_core_model/add_module
In uq_createModel
In PCE_CE (line 66)
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_blockwise_inverse (line 26)
    SCinv = 1/(D - C*Ainv*B);

Error in uq_lar (line 214)
M = uq_blockwise_inverse(M,x,x’,r) ;

Error in uq_PCE_lars (line 60)
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 358)
success = uq_calculateMetamodel(current_model);

Error in PCE_CE (line 66)
myPCE = uq_createModel(MetaOpts);

I’ve tried to undo all the changes I’ve made, but this error keeps showing up. I should note, that the dimensions of my input are 12, and the output is 10. The coefficient for the first output variable solves, and the error is given when solving for the coefficients for the second output variable.

My appologies if I am unclear in explaining my problem, any help as to where I should troubleshoot would be appreciated. I’ve verified that the input and output data sets for training and validation match(MetaOpts.ExpDesign, MetaOpts.ValidationSet), and (InputOpts.Marginals) is appropriatly dimensioned as well.

1 Like

Hi @Farshud_Sorourifar, welcome to UQWorld!

Between UQLab Release 1.2.1 and 1.3.0 there were no changes in the PCE module, so the error must be caused by something else.

First, make sure that only one version of UQLab, the updated one, is on your Matlab path, so that older versions don’t interfere when you run your script.

If that doesn’t help, try to re-install UQLab, in case something went wrong during the update process. You can find the files and the installation instructions here: https://uqftp.ethz.ch/uqlab_releases/download.html Again, make sure that only this version of UQLab is on the Matlab path when you run your script.

If the error persists, please send us your code and if possible also the data, so that we can investigate the issue.

Good luck!

4 Likes

Thank you, I have been able to figure it out (sort of).

In case anyone is having similar issues:
There was an issue in uq_lar.m on line 234.
a_coeff = [a_coeff idx] was not being read. I corrected the issue by copying this line to 216 (just below M = uq_blockwise_inverse(M,x,x’,r)).

Additional comments:
What is strange is that this line(a_coeff = [a_coeff idx] ) has to be in both places for the code to work, but now I can only evaluate polynomials of 1. This is fine for me, since prior to these issues, the lowest validation error was using a a degree one polynomial anyways.
If anyone has any clue as to why this issue first occurred, I would be interested.

Thanks!
Farshud

Hi Farshud, good to hear that you could find a solution for your problem.
However, this is such a weird error that we would like to understand what exactly went wrong, and correct it if there is indeed a bug.

It sounds very strange that the code in line 234 should not be executed in your case. How did you test this? If this line is copied to both places as you describe, it might happen that the regressor is added twice, which can lead to further problems… so we would not recommend solving the problem this way. And what do you mean with “now I can only evaluate polynomials of [degree] 1”? Does the computation always stop at degree 1? This is maybe not such a good long-term solution then… :wink:

We would be very grateful if you could repeat your calculations with a fresh install of UQLab, just to make sure it is not an issue with the update process. You don’t need to delete your old version, just make a new folder and download the files there. You can use the same license.p file that you have already. Then, type uqlab_install in the core folder of the new version. When you are asked whether to remove other versions of UQLab from the Matlab path, click Yes. (You can switch back to your other UQLab version anytime by the same procedure, by typing uqlab_install in the core folder and removing all other versions of Matlab from the path.)

Thanks for your help in investigating this issue!

3 Likes

Hello Nora,

Before making any changes, I did delete uqlab and did a fresh install. I will try it again later this week and see if anything changes though.

I realized that line 231 was not being executed while trying to trace the error, and found the value of a_coeff to be unchanged in the iteration before the crash. It was changing in the two iterations before the crash.

As far as only evaluating degree one polynomials, I get an error on line 254 ( c = 1/sqrt((s’*M)*s) ) when setting MetaOpts.Degree=1:n, or MetaOpts.Degree=n for any n greater than 1, or using MetaOpts.PCE.Degree=n for any n, including 1. In the previous install, setting MetaOpts.Degree=n:m would only evaluate polynomials of degree n, now it crashes. I agree that this was not a good long term solution.

Additionally, I should mention I am using Matlab R2019a in Linux Mint. I can also send you my script and the data files if you would like to verify the problem.

Thanks for all your help,

Farshud Sorourifar

1 Like

Hi Farshud,

That’s a good idea. Once you have repeated the tests with a fresh install (with correct Matlab path and without any modifications), please let us know the result!

Then, if the error is still there, it would indeed be good if you could send us your script and the data, so that we can investigate the issue.

After a fresh install, I still have the same issue. Unfortunately, I can’t upload my code here(due to being a new user, and the training/validation sets are in .csv files). Is there an email address that I can send the files to?

Hi @Farshud_Sorourifar, if you zip all the files, how big is it? If it’s still below 4MB, I might be able to give you access to post your file here.

Thank you!
The zip is less than 1MB, so I could post here

You should be able to attach the file now, just drag and drop it to your post editor. Don’t forget to explain what’s what if they are not self-explanatory :slight_smile: . Let me know if it doesn’t work. Thanks!

Thank you! There is a readme.txt in the folder that explains what’s going on, but it is pretty straight forward.

uqlab_support.zip (692.8 KB)

Thanks Farshud! I will have a look at it and come back to you in a few days. :slight_smile:

1 Like

Hi Farshud,

You are right, there is a problem in uq_lar. For now, it should work if after line 224 of uq_lar.m
i_coeff(i_coeff == idx) = [];
you add the line
M = pinv(Psi(:,a_coeff)'*Psi(:,a_coeff));
(When a basis element is skipped due to instability, of course also the matrix M needs to be updated.)
We will fix this soon in the code for everyone. Thank you very much for bringing this to our attention!

With this change, your code runs on my computer without problems, also for higher degree PCE. Does it work for you as well?

2 Likes

Yep, that fixed my problems! Thank you so much!

1 Like

Great! :slight_smile: Good that it works now, and thanks again for making us aware of this issue!

2 Likes