예제 #1
0
def _parallel_analyze(index, method, problem, samples, data, seed):
    if method == 'sobol':
        result = sobol.analyze(problem,
                               data,
                               calc_second_order=True,
                               print_to_console=False,
                               seed=seed)
    elif method == 'fast':
        result = fast.analyze(problem, data, print_to_console=False, seed=seed)
    elif method == 'rbd-fast':
        result = rbd_fast.analyze(problem,
                                  samples,
                                  data,
                                  print_to_console=False,
                                  seed=seed)
    elif method == 'morris':
        result = morris_analyze(problem,
                                samples,
                                data,
                                print_to_console=False,
                                seed=seed)
    elif method == 'delta':
        result = delta.analyze(problem,
                               samples,
                               data,
                               print_to_console=False,
                               seed=seed)
    elif method == 'dgsm':
        result = dgsm.analyze(problem,
                              samples,
                              data,
                              print_to_console=False,
                              seed=seed)
    elif method == 'frac':
        result = ff_analyze(problem,
                            samples,
                            data,
                            second_order=True,
                            print_to_console=False,
                            seed=seed)
    else:
        return 0

    for key in result.keys():
        result[key] = result[key].tolist()

    with open('{:s}.json'.format(index), 'w') as outfile:
        json.dump(result, outfile)

    return 0
예제 #2
0
def _parallel_analyze(data):
    seed = int(opts['seed'])
    samples = population['problem', 'samples']
    problem = population['problem', 'definition']

    if opts['method'] == 'sobol':
        return sobol.analyze(problem,
                             data,
                             calc_second_order=True,
                             print_to_console=False)
    elif opts['method'] == 'fast':
        return fast.analyze(problem, data, print_to_console=False, seed=seed)
    elif opts['method'] == 'rbd-fast':
        return rbd_fast.analyze(problem,
                                samples,
                                data,
                                print_to_console=False,
                                seed=seed)
    elif opts['method'] == 'morris':
        return morris_analyze(problem,
                              samples,
                              data,
                              print_to_console=False,
                              seed=seed)
    elif opts['method'] == 'delta':
        return delta.analyze(problem,
                             samples,
                             data,
                             print_to_console=False,
                             seed=seed)
    elif opts['method'] == 'dgsm':
        return dgsm.analyze(problem,
                            samples,
                            data,
                            print_to_console=False,
                            seed=seed)
    elif opts['method'] == 'frac':
        return ff_analyze(problem,
                          samples,
                          data,
                          second_order=True,
                          print_to_console=False,
                          seed=seed)
    else:
        return 0
예제 #3
0
        'ax2_lable': 'Parameter index',
    }
    Si_con = fast.analyze(problem, Y_con, print_to_console=False)
    f1, (ax1, ax2) = plt.subplots(2, 1, sharex=True)
    SS1 = (np.array(Si_con['S1'][1:])) / np.array(Si['S1'][1:])
    SS2 = (np.array(Si_con['ST'][1:])) / np.array(Si['ST'][1:])
    sns.barplot(np.arange(2, 22), np.abs(SS1), ax=ax1)
    sns.barplot(np.arange(2, 22), np.abs(SS2), ax=ax2)
    ax1.set_title('SS1')
    ax2.set_title('SST')
    ax2.set_xlabel('Sensitivity')

elif method_flag == 5:
    Si = ff_analyze(problem,
                    param_values,
                    Y,
                    second_order=True,
                    print_to_console=False)

elif method_flag == 6:
    Si = morris.analyze(problem,
                        param_values,
                        Y,
                        conf_level=0.95,
                        print_to_console=False,
                        num_levels=4,
                        grid_jump=2,
                        num_resamples=100)
    figure_keys = {
        'ax1_title': 'mu',
        'ax2_title': 'sigma',