Beispiel #1
0
def test_two_to_n_block():
    oa_gen = OrthogonalArrayGenerator(num_values=3,
                                      degree=2,
                                      dtype=DEFAULT_NDARRAY_TYPE)
    ttn = oa_gen.two_to_n_block(repeat_factor=4)
    ttn_expected = np.array([
        [2, 2, 2, 2],
        [2, 2, 2, 2],
        [2, 2, 2, 2],
        [3, 3, 3, 3],
        [3, 3, 3, 3],
        [3, 3, 3, 3],
    ],
                            dtype=DEFAULT_NDARRAY_TYPE)

    assert np.array_equal(ttn, ttn_expected)
Beispiel #2
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