コード例 #1
0
ファイル: SMSEMOA2.java プロジェクト: javierferrer/jMetal
 @Override
 protected List<S> evaluatePopulation(List<S> population) {
   for (int i = 0; i < population.size(); i++) {
     problem.evaluate(population.get(i));
   }
   return population;
 }
コード例 #2
0
 @Override
 protected List<S> createInitialPopulation() {
   List<S> population = new ArrayList<>(populationSize);
   for (int i = 0; i < populationSize; i++) {
     S newIndividual = problem.createSolution();
     population.add(newIndividual);
   }
   return population;
 }
コード例 #3
0
ファイル: SolutionListUtils.java プロジェクト: jMetal/jMetal
 /**
  * Fills a population with new solutions until its size is maxListSize
  *
  * @param solutionList The list of solutions
  * @param problem The problem being solved
  * @param maxListSize The target size of the list
  * @param <S> The type of the solutions to be created
  */
 public static <S extends Solution<?>> void fillPopulationWithNewSolutions(
     List<S> solutionList, Problem<S> problem, int maxListSize) {
   while (solutionList.size() < maxListSize) {
     solutionList.add(problem.createSolution());
   }
 }
コード例 #4
0
ファイル: MOMBI2Runner.java プロジェクト: White-Chen/jMetal
  public static void singleRun(String pro, String referencePareto) {
    Problem<DoubleSolution> problem;
    Algorithm<List<DoubleSolution>> algorithm;
    CrossoverOperator<DoubleSolution> crossover;
    MutationOperator<DoubleSolution> mutation;
    SelectionOperator<List<DoubleSolution>, DoubleSolution> selection;
    String referenceParetoFront = "";

    String problemName;
    if (!pro.isEmpty()
        && !referencePareto.isEmpty()
        && pro.trim() != null
        && referencePareto.trim() != null) {
      problemName = pro;
      referenceParetoFront = referencePareto;
    } else {
      problemName = "problem.multiobjective.zdt.ZDT1";
      referenceParetoFront = "problem/src/test/resources/pareto_fronts/ZDT1.pf";
    }

    problem = ProblemUtils.<DoubleSolution>loadProblem(problemName);

    int iterations;
    String mobi;
    if (problem.getNumberOfObjectives() == 2) {
      iterations = 300;
      mobi = "mombi2-weights/weight/weight_02D_152.sld";
    } else {
      iterations = 500;
      mobi = "mombi2-weights/weight/weight_03D_12.sld";
    }

    double crossoverProbability = 0.9;
    double crossoverDistributionIndex = 20.0;
    crossover = new SBXCrossover(crossoverProbability, crossoverDistributionIndex);

    double mutationProbability = 1.0 / problem.getNumberOfVariables();
    double mutationDistributionIndex = 20.0;
    mutation = new PolynomialMutation(mutationProbability, mutationDistributionIndex);

    selection =
        new BinaryTournamentSelection<DoubleSolution>(
            new RankingAndCrowdingDistanceComparator<DoubleSolution>());

    algorithm =
        new MOMBI2<>(
            problem,
            iterations,
            crossover,
            mutation,
            selection,
            new SequentialSolutionListEvaluator<DoubleSolution>(),
            mobi);
    AlgorithmRunner algorithmRunner = new AlgorithmRunner.Executor(algorithm).execute();

    List<DoubleSolution> population = algorithm.getResult();
    long computingTime = algorithmRunner.getComputingTime();

    JMetalLogger.logger.info("Total execution time: " + computingTime + "ms");

    printFinalSolutionSet(population);
    if (!referenceParetoFront.equals("")) {
      printQualityIndicators(population, referenceParetoFront);
    }
  }