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)
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.ConvexShapeFunction(M) for _ in range(M - 1)] shapes.append( shape_functions.MixedConvexOrConcaveShapeFunction(M, 1, 5)) transformations: List[List[ transformation_functions.BaseTransformations]] transformations = [[] for _ in range(4)] transformations[0] = [ transformation_functions.IdenticalTransformation() for _ in range(k) ] # transformations[0] = [lambda y: y for _ in range(k)] for _ in range(n - k): transformations[0].append( transformation_functions.LinearShiftTransformation(0.35)) # transformations[1] = [lambda y: y for _ in range(k)] transformations[1] = [ transformation_functions.IdenticalTransformation() for _ in range(k) ] for _ in range(n - k): transformations[1].append( transformation_functions.FlatRegionBiasTransformation( 0.8, 0.75, 0.85)) transformations[2] = [ transformation_functions.PolynomialBiasTransformation(0.02) for _ in range(n) ] 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[3] = [ transformation_functions.WeightedSumReductionTransformation( 2 * np.arange(i * k // (M - 1) + 1, (i + 1) * k // (M - 1) + 1), lambda y: _input_converter(i, y), ) for i in range(M - 1) ] transformations[3].append( transformation_functions.WeightedSumReductionTransformation( 2 * np.arange(k, n) + 1, lambda y: y[k:n], )) self.wfg = BaseWFG(S, A, upper_bounds, shapes, transformations)
def __init__(self, n_arguments: int, n_objectives: int, k: int): assert k % (n_objectives - 1) == 0 assert k + 1 <= n_arguments // 2 assert (n_arguments - k) % 2 == 0 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.zeros(M - 1) A[0] = 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.LinearShapeFunction(M) for _ in range(M)] transformations: List[List[ transformation_functions.BaseTransformations]] transformations = [[] for _ in range(3)] transformations[0] = [ transformation_functions.IdenticalTransformation() for _ in range(k) ] for _ in range(n - k): transformations[0].append( transformation_functions.LinearShiftTransformation(0.35)) def _input_converter0(i: int, y: np.ndarray) -> np.ndarray: indices = [k + 2 * (i + 1 - k) - 2, k + 2 * (i - k + 1) - 1] return y[indices] transformations[1] = [ transformation_functions.IdenticalTransformation() for _ in range(k) ] for i in range(k, n // 2): transformations[1].append( transformation_functions.NonSeparableReductionTransformation( 2, lambda y: _input_converter0(i, y))) def _input_converter1(i: int, y: np.ndarray) -> np.ndarray: indices = np.arange(i * k // (M - 1), (i + 1) * k // (M - 1)) return y[indices] transformations[2] = [ transformation_functions.WeightedSumReductionTransformation( np.ones(k // (M - 1)), lambda y: _input_converter1(i, y), ) for i in range(M - 1) ] transformations[2].append( transformation_functions.WeightedSumReductionTransformation( np.ones(n // 2 - k), lambda y: y[k:n // 2], )) # transformations = [transformations[0], transformations[1], transformations[2]] self.wfg = BaseWFG(S, A, upper_bounds, shapes, transformations)