Esempio n. 1
0
def test_generate_oa_no_field():
    oa_gen = OrthogonalArrayGenerator(num_values=6,
                                      degree=2,
                                      dtype=DEFAULT_NDARRAY_TYPE)
    oa = oa_gen.generate_oa()
    oa_expected = np.array([
        [1, 1, 1],
        [1, 2, 2],
        [1, 3, 3],
        [1, 4, 4],
        [1, 5, 5],
        [1, 6, 6],
        [2, 1, 2],
        [2, 2, 3],
        [2, 3, 4],
        [2, 4, 5],
        [2, 5, 6],
        [2, 6, 1],
        [3, 1, 3],
        [3, 2, 4],
        [3, 3, 5],
        [3, 4, 6],
        [3, 5, 1],
        [3, 6, 2],
        [4, 1, 4],
        [4, 2, 5],
        [4, 3, 6],
        [4, 4, 1],
        [4, 5, 2],
        [4, 6, 3],
        [5, 1, 5],
        [5, 2, 6],
        [5, 3, 1],
        [5, 4, 2],
        [5, 5, 3],
        [5, 6, 4],
        [6, 1, 6],
        [6, 2, 1],
        [6, 3, 2],
        [6, 4, 3],
        [6, 5, 4],
        [6, 6, 5],
    ],
                           dtype=DEFAULT_NDARRAY_TYPE)

    assert np.array_equal(oa, oa_expected)
Esempio n. 2
0
def test_generate_oa_has_field():
    oa_gen = OrthogonalArrayGenerator(num_values=3,
                                      degree=2,
                                      dtype=DEFAULT_NDARRAY_TYPE)
    oa = oa_gen.generate_oa()
    oa_expected = np.array([
        [1, 1, 1, 1],
        [1, 2, 2, 2],
        [1, 3, 3, 3],
        [2, 1, 2, 3],
        [2, 2, 3, 1],
        [2, 3, 1, 2],
        [3, 1, 3, 2],
        [3, 2, 1, 3],
        [3, 3, 2, 1],
    ],
                           dtype=DEFAULT_NDARRAY_TYPE)

    assert np.array_equal(oa, oa_expected)
Esempio n. 3
0
    def build_configurations(self) -> np.ndarray:
        oa_gen = OrthogonalArrayGenerator(num_values=self.square_size,
                                          degree=self.coverage_degree,
                                          dtype=self.ndarray_type)
        final_grid = None
        basic_capacity = self.group_repeat_factor[self.num_rounds - 1] \
            * self.round_group_size[self.num_rounds - 1]
        for round_num in range(0, self.num_rounds):
            extra_parameters_grid = None
            repeat_factor = basic_capacity // (
                self.group_repeat_factor[round_num] *
                self.round_group_size[round_num])
            if round_num == 0:
                add_grid = oa_gen.generate_oa()
            elif self.round_group_size[round_num] == self.square_size:
                add_grid = oa_gen.reduced_array(
                    self.group_repeat_factor[round_num])
                extra_parameters_grid = oa_gen.extra_parameter_block(
                    len(final_grid), self.extra_parms_per_round[round_num])
            elif self.round_group_size[round_num] == self.square_size + 1:
                add_grid = oa_gen.basic_array(
                    self.group_repeat_factor[round_num])
            else:
                raise ValueError("Error in internal construction")

            if final_grid is not None:
                if extra_parameters_grid is not None:
                    final_grid = np.hstack([final_grid, extra_parameters_grid])
            else:
                final_grid = extra_parameters_grid

            round_grid = np.tile(add_grid, reps=repeat_factor)

            for prior_round in range(1, round_num):
                num_groups = self.extra_parms_per_round[prior_round] // (
                    self.extra_parms_repeat_factor[prior_round][round_num] *
                    self.round_group_size[prior_round])
                add_grid = oa_gen.reduced_array(
                    self.extra_parms_repeat_factor[prior_round][prior_round])
                round_grid = np.hstack(
                    [round_grid,
                     np.tile(add_grid, reps=num_groups)])

            two_to_n_block = oa_gen.two_to_n_block(
                self.extra_parms_per_round[round_num])
            if two_to_n_block is not None:
                round_grid = np.hstack([round_grid, two_to_n_block])

            if final_grid is not None:
                final_grid = np.vstack([final_grid, round_grid])
            else:
                final_grid = round_grid

        offset = len(final_grid[0]) - self.num_parms

        over_sized_grid = \
            oa_gen.oversized_parameter(
                self.max_num_values,
                self.max_index + offset,
                len(final_grid[0]),
                self.second_max_num_values)
        if over_sized_grid is not None:
            final_grid = np.vstack([final_grid, over_sized_grid])

        config_grid = self.adjust_values(
            final_grid[:, offset:],
            self.square_size - self.second_max_num_values + 1)

        return config_grid