Beispiel #1
0
    def __init__(self, n_arguments: int, n_objectives: int, k: int):

        assert k % (n_objectives - 1) == 0
        assert k + 1 <= n_arguments

        self._n_arguments = n_arguments
        self._n_objectives = n_objectives
        self._k = k

        n = self._n_arguments
        M = self._n_objectives

        S = 2 * (np.arange(M) + 1)
        A = np.ones(M - 1)
        upper_bounds = 2 * (np.arange(n) + 1)

        self.domain = np.zeros((n, 2))
        self.domain[:, 1] = upper_bounds

        shapes: List[shape_functions.BaseShapeFunction]
        shapes = [shape_functions.ConcaveShapeFunction(M) for _ in range(M)]

        transformations: List[List[
            transformation_functions.BaseTransformations]]
        transformations = [[] for _ in range(2)]

        transformations[0] = [
            transformation_functions.IdenticalTransformation()
            for _ in range(k)
        ]
        for _ in range(n - k):
            transformations[0].append(
                transformation_functions.LinearShiftTransformation(0.35))

        def _input_converter(i: int, y: np.ndarray) -> np.ndarray:
            indices = np.arange(i * k // (M - 1), (i + 1) * k // (M - 1))
            return y[indices]

        # transformations[1] = []
        for i in range(M - 1):
            transformations[1].append(
                transformation_functions.NonSeparableReductionTransformation(
                    k // (M - 1), lambda y: _input_converter(i, y)))
        transformations[1].append(
            transformation_functions.NonSeparableReductionTransformation(
                n - k,
                lambda y: y[k:n],
            ))

        # transformations = [transformations[0], transformations[1]]

        self.wfg = BaseWFG(S, A, upper_bounds, shapes, transformations)
Beispiel #2
0
    def __init__(self, n_arguments: int, n_objectives: int, k: int):

        assert k % (n_objectives - 1) == 0
        assert k + 1 <= n_arguments

        self._n_arguments = n_arguments
        self._n_objectives = n_objectives
        self._k = k

        n = self._n_arguments
        M = self._n_objectives

        S = 2 * (np.arange(M) + 1)
        A = np.ones(M - 1)
        upper_bounds = 2 * (np.arange(n) + 1)

        self.domain = np.zeros((n, 2))
        self.domain[:, 1] = upper_bounds

        shapes: List[shape_functions.BaseShapeFunction]
        shapes = [shape_functions.ConcaveShapeFunction(M) for _ in range(M)]

        def _input_converter0(i: int, y: np.ndarray) -> np.ndarray:
            return y[i:n]

        transformations: List[List[
            transformation_functions.BaseTransformations]]
        transformations = [[] for _ in range(3)]

        transformations[0] = [
            transformation_functions.ParameterDependentBiasTransformation(
                np.ones(n - i),
                lambda y: _input_converter0(i, y),
                0.98 / 49.98,
                0.02,
                50,
                i,
            ) for i in range(n - 1)
        ]
        transformations[0].append(
            transformation_functions.IdenticalTransformation())

        transformations[1] = [
            transformation_functions.DeceptiveShiftTransformation(
                0.35, 0.001, 0.05) for _ in range(k)
        ]
        for _ in range(n - k):
            transformations[1].append(
                transformation_functions.MultiModalShiftTransformation(
                    30, 95, 0.35))

        def _input_converter(i: int, y: np.ndarray) -> np.ndarray:
            indices = np.arange(i * k // (M - 1), (i + 1) * k // (M - 1))
            return y[indices]

        transformations[2] = []
        for i in range(M - 1):
            transformations[2].append(
                transformation_functions.NonSeparableReductionTransformation(
                    k // (M - 1), lambda y: _input_converter(i, y)))
        transformations[2].append(
            transformation_functions.NonSeparableReductionTransformation(
                n - k,
                lambda y: y[k:n],
            ))

        # transformations = [transformations[0], transformations[1], transformations[2]]

        self.wfg = BaseWFG(S, A, upper_bounds, shapes, transformations)