Пример #1
0
def solution_comparator(problem: Problem, x: Solution, y: Solution) -> int:
    val1 = problem.evaluate(x).objectives[0]
    val2 = problem.evaluate(y).objectives[0]
    if val1 > val2:
        return 1
    elif val2 > val1:
        return -1
    else:
        return 0
Пример #2
0
    def load_initial_solutions(self, warm_startup_info: Mapping,
                               problem: Problem) -> None:
        self.warm_startup_info = warm_startup_info
        if warm_startup_info and 'paths' in self.warm_startup_info.keys(
        ) and len(self.warm_startup_info['paths']) > 0:
            from jmetal.util.generator import InjectorGenerator
            one_sol_variables = self.warm_startup_info['paths'][0]
            solution = PermutationSolution(
                number_of_variables=problem.number_of_variables,
                number_of_objectives=problem.number_of_objectives)
            solution.variables = one_sol_variables
            self._initial_solutions.append(problem.evaluate(solution))

            for one_sol_variables in self.warm_startup_info['paths'][1:]:
                solution = copy(solution)
                solution.variables = one_sol_variables
                self._initial_solutions.append(problem.evaluate(solution))
            generator = InjectorGenerator(solutions=self._initial_solutions)

        else:
            from jmetal.util.generator import RandomGenerator
            generator = RandomGenerator()
        self._solution_generator = generator
Пример #3
0
 def evaluate_solution(solution: S, problem: Problem) -> None:
     problem.evaluate(solution)
Пример #4
0
    def evaluate(self, solution_list: List[S], problem: Problem) -> List[S]:
        solutions_to_evaluate = self.spark_context.parallelize(solution_list)

        return solutions_to_evaluate \
            .map(lambda s: problem.evaluate(s)) \
            .collect()
Пример #5
0
 def evaluate_solution(solution: S, problem: Problem) -> None:
     problem.evaluate(solution)
     if problem.number_of_constraints > 0:
         problem.evaluate_constraints(solution)
Пример #6
0
 def evaluate_solution(solution: S, problem: Problem) -> None:
     problem.evaluate(solution)
     if problem.number_of_constraints > 0:
         problem.evaluate_constraints(solution)
Пример #7
0
    def evaluate(self, solution_list: List[S], problem: Problem) -> List[S]:
        for solution in solution_list:
            problem.evaluate(solution)

        return solution_list