def test_optimal_sample_with_groups():
    '''
    Tests that the combinatorial optimisation approach matches
    that of the brute force approach
    '''
    param_file = "SALib/tests/test_param_file_w_groups_prime.txt"
    problem = read_param_file(param_file)

    N = 10
    num_levels = 8
    grid_jump = 4
    k_choices = 4    
    num_params = problem['num_vars']
    
    sample = sample_oat(problem,
                        N,
                        num_levels,
                        grid_jump)

    actual = return_max_combo(sample,
                              N,
                              num_params,
                              k_choices)

    desired = find_optimum_combination(sample,
                                        N,
                                        num_params,
                                        k_choices)

    assert_equal(actual, desired)
def test_optimised_trajectories_with_groups():
    """
    Tests that the optimisation problem gives
    the same answer as the brute force problem
    (for small values of `k_choices` and `N`)
    with groups
    """

    N = 11
    param_file = "SALib/tests/test_param_file_w_groups_prime.txt"
    problem = read_param_file(param_file)
    num_levels = 4
    grid_jump = num_levels / 2
    k_choices = 4

    num_params = problem['num_vars']
    groups = problem['groups']

    input_sample = sample_groups(problem, N, num_levels, grid_jump)

    # From gurobi optimal trajectories
    actual = return_max_combo(input_sample, N, num_params, k_choices, groups)

    desired = find_optimum_combination(input_sample, N, num_params, k_choices,
                                       groups)
    assert_equal(actual, desired)
def test_optimised_trajectories_with_groups():
    """
    Tests that the optimisation problem gives
    the same answer as the brute force problem
    (for small values of `k_choices` and `N`)
    with groups
    """
    
    N = 11
    param_file = "SALib/tests/test_param_file_w_groups_prime.txt"
    problem = read_param_file(param_file)
    num_levels = 4
    grid_jump = num_levels / 2
    k_choices = 4
    
    num_params = problem['num_vars']
    groups = problem['groups']

    input_sample = sample_groups(problem, N, num_levels, grid_jump)

    # From gurobi optimal trajectories     
    actual = return_max_combo(input_sample,
                              N,
                              num_params,
                              k_choices,
                              groups)

    desired = find_optimum_combination(input_sample,
                                       N,
                                       num_params,
                                       k_choices,
                                       groups)
    assert_equal(actual, desired)
def test_optimised_trajectories_without_groups():
    """
    Tests that the optimisation problem gives
    the same answer as the brute force problem
    (for small values of `k_choices` and `N`),
    particularly when there are two or more identical
    trajectories
    """
    
    N = 6
    param_file = "SALib/tests/test_params.txt"
    problem = read_param_file(param_file)
    num_levels = 4
    k_choices = 4

    num_params = problem['num_vars']
    groups = problem['groups']

    # 6 trajectories, with 5th and 6th identical
    input_sample = np.array([[ 0.33333333,  0.66666667],
                             [ 1.          ,0.66666667],
                             [ 1.          ,0.        ],
                             [ 0.          ,0.33333333],
                             [ 0.          ,1.        ],
                             [ 0.66666667  ,1.        ],
                             [ 0.66666667  ,0.33333333],
                             [ 0.66666667  ,1.        ],
                             [ 0.          ,1.        ],
                             [ 0.66666667  ,1.        ],
                             [ 0.66666667  ,0.33333333],
                             [ 0.          ,0.33333333],
                             [ 1.          ,1.        ],
                             [ 1.          ,0.33333333],
                             [ 0.33333333  ,0.33333333],
                             [ 1.          ,1.        ],
                             [ 1.          ,0.33333333],
                             [ 0.33333333  ,0.33333333]], dtype=np.float32)

    print(input_sample)

    # From gurobi optimal trajectories     
    actual = return_max_combo(input_sample,
                              N,
                              num_params,
                              k_choices,
                              groups)

    desired = find_optimum_combination(input_sample,
                                       N,
                                       num_params,
                                       k_choices,
                                       groups)
    
    assert_equal(actual, desired)
def test_optimal_combinations():

    N = 6
    param_file = "SALib/tests/test_params.txt"
    problem = read_param_file(param_file)
    num_params = problem['num_vars']
    num_levels = 10
    grid_jump = num_levels / 2
    k_choices = 4

    morris_sample = sample_oat(problem, N, num_levels, grid_jump)

    actual = return_max_combo(morris_sample, N, num_params, k_choices)

    desired = find_optimum_combination(morris_sample, N, num_params, k_choices)

    assert_equal(actual, desired)
def test_optimal_sample_with_groups():
    '''
    Tests that the combinatorial optimisation approach matches
    that of the brute force approach
    '''
    param_file = "SALib/tests/test_param_file_w_groups_prime.txt"
    problem = read_param_file(param_file)

    N = 10
    num_levels = 8
    grid_jump = 4
    k_choices = 4
    num_params = problem['num_vars']

    sample = sample_oat(problem, N, num_levels, grid_jump)

    actual = return_max_combo(sample, N, num_params, k_choices)

    desired = find_optimum_combination(sample, N, num_params, k_choices)

    assert_equal(actual, desired)
def test_optimal_combinations():

    N = 6
    param_file = "SALib/tests/test_params.txt"
    problem = read_param_file(param_file)
    num_params = problem['num_vars']
    num_levels = 10
    grid_jump = num_levels / 2
    k_choices = 4

    morris_sample = sample_oat(problem, N, num_levels, grid_jump)

    actual = return_max_combo(morris_sample,
                              N,
                              num_params,
                              k_choices)

    desired = find_optimum_combination(morris_sample,
                                        N,
                                        num_params,
                                        k_choices)

    assert_equal(actual, desired)
def test_optimised_trajectories_without_groups():
    """
    Tests that the optimisation problem gives
    the same answer as the brute force problem
    (for small values of `k_choices` and `N`),
    particularly when there are two or more identical
    trajectories
    """

    N = 6
    param_file = "SALib/tests/test_params.txt"
    problem = read_param_file(param_file)
    num_levels = 4
    k_choices = 4

    num_params = problem['num_vars']
    groups = problem['groups']

    # 6 trajectories, with 5th and 6th identical
    input_sample = np.array([
        [0.33333333, 0.66666667], [1., 0.66666667], [1., 0.], [0., 0.33333333],
        [0., 1.], [0.66666667, 1.], [0.66666667, 0.33333333], [0.66666667, 1.],
        [0., 1.], [0.66666667, 1.], [0.66666667, 0.33333333], [0., 0.33333333],
        [1., 1.], [1., 0.33333333], [0.33333333, 0.33333333], [1., 1.],
        [1., 0.33333333], [0.33333333, 0.33333333]
    ],
                            dtype=np.float32)

    print(input_sample)

    # From gurobi optimal trajectories
    actual = return_max_combo(input_sample, N, num_params, k_choices, groups)

    desired = find_optimum_combination(input_sample, N, num_params, k_choices,
                                       groups)

    assert_equal(actual, desired)