简体   繁体   中英

Does SAlib (sensitivity analysis) package support only one column (vector) inputs?

The shape of output array of my model which i suppose to use as an argument for SAlib's analyse (SOBOL) does not fit the shape of array which sobol needs.

  1. I have a parameter array which has a shape of (28,13) that is produced by SAlib package's saltelli function.
  2. On the other hand, my model computes a solution at numerous time points, say 200. So in the end I have an output array of (28,200)
  3. I must use this output array as an argument for the SAlib's Sobol function.
  4. But as far as i understand from the example in the SAlib's doc , the input argument of Sobol must have a column array such as (28,)

The thing i want to learn is , do i infer correct conclusion from SAlib's document as SAlib's Sobol function needs only a column array ? or can i feed it with an array of (28,200) ?

PS : actually i tried (28,200) and got some error. But I am not sure if the SAlib supports array shape of (28,200) or if my code have an error.

from SALib.sample import saltelli
from SALib.analyze import sobol,morris
from SALib.test_functions import Ishigami  

input_dict = {}
problem = {'num_vars':13,'names': 
['Rp1','Ra','Rv','Rp2','Cla','Csa','Clv','Csv','Emin','Emax','R1','R2','C1'],\
       'bounds':[[1.0,2.0],[0.1,0.5],[0.01,0.1],[11.0,15.0],[0.1,1.5],[0.05,0.55],[30.0,50.0],[2.0,6.0],\
                 [0.001,0.45],[0.2,3.2],[25.0,42.0],[2.0,8.0],[15.0,19.0]]}

param_values = saltelli.sample(problem,1)
for count, param in enumerate(param_values):
    input_dict[count] = param

kwargs = {}
kwargs['newly_defined_parameters']= input_dict

sol_dict = main(**kwargs) # main function solves the model and returns a solution dictionary

My model produces 8 outputs. But i want to make sensitivity analysis for only 1 output. So i take that output data and load it into the my_sol array.

my_sol = np.zeros((28,200))
for ps in range(28):         #ps ---> parameter set
    for tp in range(200):    #tp ---> time point
        my_sol[ps][tp]=sol_dict[ps][1][tp] 

my_sol.shape
(28, 200)

And now the analyse part:

Si = sobol.analyze(problem,my_sol)

And now the error part:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-39-ab30c1d4df01> in <module>
----> 1 Si = sobol.analyze(problem,my_sol)

C:\ProgramData\Anaconda3\lib\site-packages\SALib\analyze\sobol.py in analyze(problem, Y, calc_second_order, num_resamples, conf_level, print_to_console, parallel, n_processors, seed)
    101 
    102         for j in range(D):
--> 103             S['S1'][j] = first_order(A, AB[:, j], B)
    104             S['S1_conf'][j] = Z * first_order(A[r], AB[r, j], B[r]).std(ddof=1)
105             S['ST'][j] = total_order(A, AB[:, j], B)

ValueError: setting an array element with a sequence.

With SAlib i was not able to make a sensitivity analysis to the time series output of my model which was an array of (28,200). Instead i tried 2 different ways.

1st: I made SA for evey time point so i was able to graph sensitivity changes of a parameter during the model run time. And also i computed the mean of sensitivity indices by this way i got a final SA indice.

2nd: I computed mean of each time series and made SA for those final mean values.

(The 1st option ended up with more reasonable solutions)

https://github.com/SALib/SALib/issues/233

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM