Exemplo n.º 1
0
    def update_solutions(self, solution, aggregation_function, sub_problem):
        """
        Update solutions of the population and of the external archive ep

        :param solution: {:class:`~moead_framework.solution.one_dimension_solution.OneDimensionSolution`} the candidate solution also called offspring
        :param aggregation_function: {:class:`~moead_framework.aggregation.functions.AggregationFunction`} Aggregation function used to compare solution in a multi-objective context
        :param sub_problem: {integer} index of the sub-problem currently visited
        :return:
        """
        for j in self.b[sub_problem]:
            y_score = aggregation_function.run(
                solution=solution,
                number_of_objective=self.number_of_objective,
                weights=self.weights,
                sub_problem=j,
                z=self.z)

            pop_j_score = aggregation_function.run(
                solution=self.population[j],
                number_of_objective=self.number_of_objective,
                weights=self.weights,
                sub_problem=j,
                z=self.z)

            if aggregation_function.is_better(pop_j_score, y_score):
                self.population[j] = solution

                if not is_duplicated(
                        x=solution,
                        population=self.ep,
                        number_of_objective=self.number_of_objective):
                    self.ep.append(solution)
                    self.ep = get_non_dominated(self.ep)
Exemplo n.º 2
0
    def initial_population(self):
        """
        Initialize the population of solution

        :return: {List<:class:`~moead_framework.solution.one_dimension_solution.OneDimensionSolution`>}
        """
        p = []
        for i in range(self.number_of_weight):
            x_i = self.problem.generate_random_solution()
            p.append(x_i)
            if not is_duplicated(x=x_i,
                                 population=self.ep,
                                 number_of_objective=self.number_of_objective):
                self.ep.append(x_i)
                self.ep = get_non_dominated(self.ep)

        return p
Exemplo n.º 3
0
    def update_solutions(self, solution, aggregation_function, sub_problem):
        """
        Update solutions of the population and of the external archive ep.

        Integration of the parameter number_of_replacement (the maximal number of solutions replaced by each child solution
        to preserve the diversity)

        :param solution: {:class:`~moead_framework.solution.one_dimension_solution.OneDimensionSolution`} the candidate solution also called offspring
        :param aggregation_function: {:class:`~moead_framework.aggregation.functions.AggregationFunction`} Aggregation function used to compare solution in a multi-objective context
        :param sub_problem: {integer} index of the sub-problem currently visited
        :return:
        """
        c = 0

        while (c < self.number_of_replacement) & (len(self.mating_pool) > 0):
            # Step (1)
            random_j = random.randint(0, len(self.mating_pool) - 1)
            j = self.mating_pool[random_j]

            j_score = aggregation_function.run(
                solution=self.population[j],
                number_of_objective=self.number_of_objective,
                weights=self.weights,
                sub_problem=j,
                z=self.z)

            y_score = aggregation_function.run(
                solution=solution,
                number_of_objective=self.number_of_objective,
                weights=self.weights,
                sub_problem=j,
                z=self.z)

            # Step (2)
            if aggregation_function.is_better(j_score, y_score):
                c += 1
                self.population[j] = solution
                if not is_duplicated(
                        x=solution,
                        population=self.ep,
                        number_of_objective=self.number_of_objective):
                    self.ep.append(solution)
                    self.ep = get_non_dominated(self.ep)

            # Step (3)
            self.mating_pool.remove(j)