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.
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)
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.