/**
   * Returns a new single-objective {@link DE/rand/1/bin} instance.
   *
   * @param properties the properties for customizing the new {@code DE/rand/1/bin} instance
   * @param problem the problem
   * @return a new {@code DE/rand/1/bin} instance
   */
  private Algorithm newDifferentialEvolution(TypedProperties properties, Problem problem) {
    if (!checkType(RealVariable.class, problem)) {
      throw new FrameworkException("unsupported decision variable type");
    }

    int populationSize = (int) properties.getDouble("populationSize", 100);
    double[] weights = properties.getDoubleArray("weights", new double[] {1.0});
    String method = properties.getString("method", "linear");

    AggregateObjectiveComparator comparator = null;

    if (method.equalsIgnoreCase("linear")) {
      comparator = new LinearDominanceComparator(weights);
    } else if (method.equalsIgnoreCase("min-max")) {
      comparator = new MinMaxDominanceComparator(weights);
    } else {
      throw new FrameworkException("unrecognized weighting method: " + method);
    }

    Initialization initialization = new RandomInitialization(problem, populationSize);

    DifferentialEvolutionSelection selection = new DifferentialEvolutionSelection();

    DifferentialEvolutionVariation variation =
        (DifferentialEvolutionVariation)
            OperatorFactory.getInstance().getVariation("de", properties, problem);

    return new DifferentialEvolution(problem, comparator, initialization, selection, variation);
  }
  /**
   * Returns a new single-objective {@link RepeatedSingleObjective} instance.
   *
   * @param properties the properties for customizing the new {@code RepeatedSingleObjective}
   *     instance
   * @param problem the problem
   * @return a new {@code RepeatedSingleObjective} instance
   */
  private Algorithm newRSO(TypedProperties properties, Problem problem) {
    String algorithmName = properties.getString("algorithm", "GA");
    int instances = (int) properties.getDouble("instances", 100);

    if (!properties.contains("method")) {
      properties.setString("method", "min-max");
    }

    return new RepeatedSingleObjective(
        problem, algorithmName, properties.getProperties(), instances);
  }
  /**
   * Returns a new {@link CMAES} instance.
   *
   * @param properties the properties for customizing the new {@code CMAES} instance
   * @param problem the problem
   * @return a new {@code CMAES} instance
   */
  private Algorithm newCMAES(TypedProperties properties, Problem problem) {
    if (!checkType(RealVariable.class, problem)) {
      throw new FrameworkException("unsupported decision variable type");
    }

    int lambda = (int) properties.getDouble("lambda", 100);
    double cc = properties.getDouble("cc", -1.0);
    double cs = properties.getDouble("cs", -1.0);
    double damps = properties.getDouble("damps", -1.0);
    double ccov = properties.getDouble("ccov", -1.0);
    double ccovsep = properties.getDouble("ccovsep", -1.0);
    double sigma = properties.getDouble("sigma", -1.0);
    int diagonalIterations = (int) properties.getDouble("diagonalIterations", 0);
    String indicator = properties.getString("indicator", "crowding");
    double[] initialSearchPoint = properties.getDoubleArray("initialSearchPoint", null);
    NondominatedPopulation archive = null;
    FitnessEvaluator fitnessEvaluator = null;

    if (problem.getNumberOfObjectives() == 1) {
      archive = new NondominatedPopulation();
    } else {
      archive =
          new EpsilonBoxDominanceArchive(
              properties.getDoubleArray(
                  "epsilon", new double[] {EpsilonHelper.getEpsilon(problem)}));
    }

    if ("hypervolume".equals(indicator)) {
      fitnessEvaluator = new HypervolumeFitnessEvaluator(problem);
    } else if ("epsilon".equals(indicator)) {
      fitnessEvaluator = new AdditiveEpsilonIndicatorFitnessEvaluator(problem);
    }

    CMAES cmaes =
        new CMAES(
            problem,
            lambda,
            fitnessEvaluator,
            archive,
            initialSearchPoint,
            false,
            cc,
            cs,
            damps,
            ccov,
            ccovsep,
            sigma,
            diagonalIterations);

    return cmaes;
  }
  /**
   * Returns a new {@link SMSEMOA} instance.
   *
   * @param properties the properties for customizing the new {@code SMSEMOA} instance
   * @param problem the problem
   * @return a new {@code SMSEMOA} instance
   */
  private Algorithm newSMSEMOA(TypedProperties properties, Problem problem) {
    int populationSize = (int) properties.getDouble("populationSize", 100);
    double offset = properties.getDouble("offset", 100.0);
    String indicator = properties.getString("indicator", "hypervolume");
    FitnessEvaluator fitnessEvaluator = null;

    Initialization initialization = new RandomInitialization(problem, populationSize);

    Variation variation = OperatorFactory.getInstance().getVariation(null, properties, problem);

    if ("hypervolume".equals(indicator)) {
      fitnessEvaluator = new HypervolumeContributionFitnessEvaluator(problem, offset);
    }

    return new SMSEMOA(problem, initialization, variation, fitnessEvaluator);
  }
  /**
   * Returns a new single-objective {@link GeneticAlgorithm} instance.
   *
   * @param properties the properties for customizing the new {@code GeneticAlgorithm} instance
   * @param problem the problem
   * @return a new {@code GeneticAlgorithm} instance
   */
  private Algorithm newGeneticAlgorithm(TypedProperties properties, Problem problem) {
    int populationSize = (int) properties.getDouble("populationSize", 100);
    double[] weights = properties.getDoubleArray("weights", new double[] {1.0});
    String method = properties.getString("method", "linear");

    AggregateObjectiveComparator comparator = null;

    if (method.equalsIgnoreCase("linear")) {
      comparator = new LinearDominanceComparator(weights);
    } else if (method.equalsIgnoreCase("min-max")) {
      comparator = new MinMaxDominanceComparator(weights);
    } else {
      throw new FrameworkException("unrecognized weighting method: " + method);
    }

    Initialization initialization = new RandomInitialization(problem, populationSize);

    Selection selection = new TournamentSelection(2, comparator);

    Variation variation = OperatorFactory.getInstance().getVariation(null, properties, problem);

    return new GeneticAlgorithm(problem, comparator, initialization, selection, variation);
  }
  /**
   * Returns a new {@link IBEA} instance.
   *
   * @param properties the properties for customizing the new {@code IBEA} instance
   * @param problem the problem
   * @return a new {@code IBEA} instance
   */
  private Algorithm newIBEA(TypedProperties properties, Problem problem) {
    if (problem.getNumberOfConstraints() > 0) {
      throw new ProviderNotFoundException(
          "IBEA", new ProviderLookupException("constraints not supported"));
    }

    int populationSize = (int) properties.getDouble("populationSize", 100);
    String indicator = properties.getString("indicator", "hypervolume");
    IndicatorFitnessEvaluator fitnessEvaluator = null;

    Initialization initialization = new RandomInitialization(problem, populationSize);

    Variation variation = OperatorFactory.getInstance().getVariation(null, properties, problem);

    if ("hypervolume".equals(indicator)) {
      fitnessEvaluator = new HypervolumeFitnessEvaluator(problem);
    } else if ("epsilon".equals(indicator)) {
      fitnessEvaluator = new AdditiveEpsilonIndicatorFitnessEvaluator(problem);
    } else {
      throw new IllegalArgumentException("invalid indicator: " + indicator);
    }

    return new IBEA(problem, null, initialization, variation, fitnessEvaluator);
  }