Пример #1
0
    def get_extreme_points(self, number_of_generations):
        """This method should be used to find the extreme points of particular generation across all the algorithms"""
        from Techniques.flatten_list import flatten
        points = []
        points.extend(
            flatten([
                d.get_frontiers_collection(number_of_generations)
                for d in self.data
            ]))
        print len(points)
        objectives = [point.objectives for point in points]
        maps_objectives = [[-1 for _ in objectives] for _ in objectives]
        from Techniques.euclidean_distance import euclidean_distance
        for i, ii in enumerate(objectives):
            for j, jj in enumerate(objectives):
                if maps_objectives[i][j] == -1:
                    maps_objectives[i][j] = euclidean_distance(ii, jj)
                    maps_objectives[j][i] = euclidean_distance(ii, jj)
                elif i == j:
                    maps_objectives[i][j] = 0

        print maps_objectives
        max_distance = max(
            [max(maps_objective) for maps_objective in maps_objectives])
        indexes = [[(i, j) for j, distance in enumerate(distances)
                    if distance == max_distance]
                   for i, distances in enumerate(maps_objectives)]
        index = [index for index in indexes
                 if len(index) > 0][-1][-1]  # Hack: To handle list of lists
        # indexes should always be a multiple of 2. And if there more than 2 entries in indexes just use any one.

        return objectives[index[0]], objectives[index[1]]
Пример #2
0
    def get_extreme_points(self, number_of_generations):
        """This method should be used to find the extreme points of particular generation across all the algorithms"""
        from Techniques.flatten_list import flatten
        points = []
        points.extend(flatten([d.get_frontiers_collection(number_of_generations) for d in self.data]))
        print len(points)
        objectives = [point.objectives for point in points]
        maps_objectives = [[-1 for _ in objectives] for _ in objectives]
        from Techniques.euclidean_distance import euclidean_distance
        for i, ii in enumerate(objectives):
            for j, jj in enumerate(objectives):
                if maps_objectives[i][j] == -1:
                    maps_objectives[i][j] = euclidean_distance(ii, jj)
                    maps_objectives[j][i] = euclidean_distance(ii, jj)
                elif i == j:
                    maps_objectives[i][j] = 0

        print maps_objectives
        max_distance = max([max(maps_objective) for maps_objective in maps_objectives])
        indexes = [[(i, j) for j, distance in enumerate(distances) if distance == max_distance] for i, distances in
                   enumerate(maps_objectives)]
        index = [index for index in indexes if len(index) > 0][-1][-1]  # Hack: To handle list of lists
        # indexes should always be a multiple of 2. And if there more than 2 entries in indexes just use any one.

        return objectives[index[0]], objectives[index[1]]
Пример #3
0
    def get_reference_point(self, number_of_generations):
        """This method should be used to find the reference point or the nadir point"""
        reference_point = [-1 for _ in self.problem.objectives]
        from Techniques.flatten_list import flatten
        points = flatten(
            [d.get_frontiers_collection(number) for number in xrange(number_of_generations) for d in self.data])

        objectives = [point.objectives for point in points]
        for count, objective in enumerate(self.problem.objectives):
            one_objective = [point[count] for point in objectives]
            if objective.lismore is True:
                reference_point[count] = max(one_objective)
            else:
                reference_point[count] = min(one_objective)
        return reference_point