Error performing Sobol analysis with UQLink

I am linking a third party software to UQLabs using UQLink. The third party software is called Hi-sAFe which is used to simulate interactions between trees and crops for agriculture. This thid-party software simulates the growing of trees and crops over several years, I am currently similulating over 30 years so it takes a long time to run one interation of any kind of sensitivity analysis. I am running this on a HPC.

I have manged to succesfully get the link set up between the two softwares and get the output values from the simulation. However, I am struggling with performing any kind of sensitivity analysis.

I have attempted both Morris and Sobol’s methods as of now to see if it is working on a small scale. I would eventually like to use both to do a larger analysis with several input parameters using Morris, set the values which are least sensitive, and then run a Sobol method on the most sensitive. As of now, since it takes so long to run one iteration of Hi-sAFe, I just want to see if the sensitivity analysis is working although it will not necessarily get the correct values. Thus, I am doing very few iterations.

I will only discuss here the issues I have with Sobol. My inputs are set as:

InputOpts.Marginals(1).Name = 'Latitude'; 
InputOpts.Marginals(1).Type = 'Uniform';
InputOpts.Marginals(1).Parameters = [0, 90]; 

InputOpts.Marginals(2).Name = 'NorthOrientation'; 
InputOpts.Marginals(2).Type = 'Uniform';
InputOpts.Marginals(2).Parameters = [0, 180]; 

% Create the INPUT object
myInput = uq_createInput(InputOpts);

I have set up the Sobol analysis as below:

 SobolOpts.Type = 'Sensitivity';
 SobolOpts.Method = 'Sobol';
 SobolOpts.Sobol.SampleSize = 10;
 SobolOpts.Sobol.Order = 1;
 mySobolAnalysis = uq_createAnalysis(SobolOpts);
    
 % Print results in terminal
 uq_print(mySobolAnalysis);

As I said, I am doing it with very few iterations for now, even though I know the results will not be significant. For this analysis it ran a total of 12 realisations. However, I have tried running more realisations, up to 50, and it still gives the same error, so I think there is something else going on.

When I run this analysis, I get the following error:

Error using uq_sobol_indices
Unable to perform assignment because the size of the left side is 1-by-2 and
the size of the right side is 1-by-0.

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

Error in uq_analysis/run (line 84)
                    this.Results = eval([this.Type '(this)']);

Error in uq_runAnalysis (line 29)
    [varargout{1:nargout}] = current_analysis.run(current_analysis, varargin{:});

Error in uq_initialize_uq_sensitivity (line 889)
uq_runAnalysis(current_analysis);

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

Error in uq_core_analysis/add_module (line 96)
                success = this.run_initialization_script(obj);

Error in uq_createAnalysis (line 83)
eval(str);

Error in UQLink_v3Capsis_HPC_MC (line 166)
    mySobolAnalysis = uq_createAnalysis(SobolOpts);

As I stated, I have tried more iterations by changing SobolOpts.Sobol.SampleSize. I thought there may be an issue with my output parser, however I have double checked it and it is giving outputs as row vectors for each realisation. For this case I had a 12 x 3837 array. Is this maybe too much data to process?

I have been stuck with this for a while and am by no means an expert in this field so any new ideas or thoughts are more than welcome!

Dear @elisara1000

It is very difficult to debug this without an executable example. Can you provide a minimal repoducer by replacing Hi-sAFe with a dummy model that repoduces the error?

Best regards
Styfen

Dear @styfen.schaer

Thank you for your response.

Attached are the dummy model (dummyModel_hisafe.m), where I have basically implemented it as a lookup table based on the results I got previously. For ease of implementation, I have only indexed by one parameter. TestingDummy_hisafe.m is the impelmentation of the model, inputs, and sensitivity analysis.

The error is the same as stated in my initial question when running with the Hi-sAFe software.

Best,
Elisa

dummyModel_hisafe.m (4.9 KB)
TestingDummy_hisafe.m (865 Bytes)

Hi @elisara1000

The problem lies in some of your output quantities. Namely, those with zero variance (that ones that are always zero). UQLab cannot calculate the Sobol indices for these and therefore gives you this somewhat obscure error message.

Hi @styfen.schaer

Thanks for that. I have removed the 0s in the dummy model and indeed it fixes the error.

For more clarification on the output of this experiment, this is the amount of sunlight that is intercepted by trees in the filed. So in the winter and autumn when the trees have no leaves this value is going to be 0 regardless of my inputs. Do you have any advice on how to deal with this for the real simulations? I am thinking of cleaning the output to ignore the 0s. That way in the analysis would only calculate the sensitivites during spring and summer.

What do you think?

Thank you for your assistance!
Elisa

Without any experience in your field: Yes, from what you’ve explained, it sounds like a reasonable (or even better) choice to calculate the Sobol indices only in summer for these outputs. This also doesn’t conflict with the other outputs, since UQLab treats each output independently anyway.