示例#1
0
  @Override
  public void evaluate(Solution solution) {
    double x = EncodingUtils.getReal(solution.getVariable(0));
    double y = EncodingUtils.getReal(solution.getVariable(1));
    double f1 = 1.5 - x * (1.0 - y);
    double f2 = 2.25 - x * (1.0 - Math.pow(y, 2.0));
    double f3 = 2.625 - x * (1.0 - Math.pow(y, 3.0));
    double c1 = -Math.pow(x, 2.0) - Math.pow(y - 0.5, 2.0) + 9.0;
    double c2 = Math.pow(x - 1.0, 2.0) + Math.pow(y - 0.5, 2.0) - 6.25;

    solution.setObjective(0, f1);
    solution.setObjective(1, f2);
    solution.setObjective(2, f3);
    solution.setConstraint(0, c1 <= 0.0 ? 0.0 : c1);
    solution.setConstraint(1, c2 <= 0.0 ? 0.0 : c2);
  }
示例#2
0
文件: DTLZ6.java 项目: nh295/MOHEA
  @Override
  public void evaluate(Solution solution) {
    double[] theta = new double[numberOfObjectives - 1];

    double[] f = new double[numberOfObjectives];
    double[] x = EncodingUtils.getReal(solution);

    int k = numberOfVariables - numberOfObjectives + 1;

    double g = 0.0;
    for (int i = numberOfVariables - k; i < numberOfVariables; i++) {
      g += java.lang.Math.pow(x[i], 0.1);
    }

    double t = java.lang.Math.PI / (4.0 * (1.0 + g));
    theta[0] = x[0] * java.lang.Math.PI / 2;
    for (int i = 1; i < (numberOfObjectives - 1); i++) {
      theta[i] = t * (1.0 + 2.0 * g * x[i]);
    }

    for (int i = 0; i < numberOfObjectives; i++) {
      f[i] = 1.0 + g;

      for (int j = 0; j < numberOfObjectives - (i + 1); j++) {
        f[i] *= java.lang.Math.cos(theta[j]);
      }
      if (i != 0) {
        int aux = numberOfObjectives - (i + 1);
        f[i] *= java.lang.Math.sin(theta[aux]);
      }

      solution.setObjective(i, f[i]);
    }
  }
示例#3
0
    /**
     * Extracts the decision variables from the solution, evaluates the Rosenbrock function, and
     * saves the resulting objective value back to the solution.
     */
    @Override
    public void evaluate(Solution solution) {
      double[] x = EncodingUtils.getReal(solution);
      double[] f = new double[numberOfObjectives];

      int k = numberOfVariables - numberOfObjectives + 1;

      double g = 0.0;
      for (int i = numberOfVariables - k; i < numberOfVariables; i++) {
        g += Math.pow(x[i] - 0.5, 2.0);
      }

      for (int i = 0; i < numberOfObjectives; i++) {
        f[i] = 1.0 + g;

        for (int j = 0; j < numberOfObjectives - i - 1; j++) {
          f[i] *= Math.cos(0.5 * Math.PI * x[j]);
        }

        if (i != 0) {
          f[i] *= Math.sin(0.5 * Math.PI * x[numberOfObjectives - i - 1]);
        }
      }

      solution.setObjectives(f);
    }
示例#4
0
  @Override
  public void evaluate(Solution solution) {
    double[] x = EncodingUtils.getReal(solution);
    double[] psum = new double[numberOfObjectives];
    double[] zz = new double[numberOfVariables];

    // apply transform to convert from UF11 to DTLZ2
    CEC2009.transform(
        x,
        zz,
        psum,
        numberOfVariables == 10 ? M_10D : M_30D,
        numberOfVariables == 10 ? lamda_l_10D : lamda_l_30D,
        numberOfVariables,
        numberOfObjectives);

    // evaluate the transformed solution with DTLZ2
    Solution transformedSolution = problem.newSolution();
    EncodingUtils.setReal(transformedSolution, zz);
    problem.evaluate(transformedSolution);

    // convert the DTLZ2 results back to UF11
    for (int i = 0; i < numberOfObjectives; i++) {
      solution.setObjective(
          i, 2.0 / (1.0 + Math.exp(-psum[i])) * (transformedSolution.getObjective(i) + 1));
    }
  }
示例#5
0
  @Override
  public void evaluate(Solution solution) {
    double[] x = EncodingUtils.getReal(solution);
    double x1 = Math.cos(Math.PI / 12.0) * x[0] - Math.sin(Math.PI / 12.0) * x[1];
    double x2 = Math.sin(Math.PI / 12.0) * x[0] + Math.cos(Math.PI / 12.0) * x[1];

    solution.setObjective(0, x1);
    solution.setObjective(
        1,
        Math.sqrt(2.0 * Math.PI)
            - Math.sqrt(Math.abs(x1))
            + 2.0 * Math.pow(Math.abs(x2 - 3.0 * Math.cos(x1) - 3), 1.0 / 3.0));
  }