Beispiel #1
0
  /** EvaluateConstraints() method */
  @Override
  public void evaluateConstraints(DoubleSolution solution) {
    double[] constraint = new double[this.getNumberOfConstraints()];

    double x1, x2, x3, x4, x5, x6;
    x1 = solution.getVariableValue(0);
    x2 = solution.getVariableValue(1);
    x3 = solution.getVariableValue(2);
    x4 = solution.getVariableValue(3);
    x5 = solution.getVariableValue(4);
    x6 = solution.getVariableValue(5);

    constraint[0] = (x1 + x2) / 2.0 - 1.0;
    constraint[1] = (6.0 - x1 - x2) / 6.0;
    constraint[2] = (2.0 - x2 + x1) / 2.0;
    constraint[3] = (2.0 - x1 + 3.0 * x2) / 2.0;
    constraint[4] = (4.0 - (x3 - 3.0) * (x3 - 3.0) - x4) / 4.0;
    constraint[5] = ((x5 - 3.0) * (x5 - 3.0) + x6 - 4.0) / 4.0;

    double overallConstraintViolation = 0.0;
    int violatedConstraints = 0;
    for (int i = 0; i < getNumberOfConstraints(); i++) {
      if (constraint[i] < 0.0) {
        overallConstraintViolation += constraint[i];
        violatedConstraints++;
      }
    }

    overallConstraintViolationDegree.setAttribute(solution, overallConstraintViolation);
    numberOfViolatedConstraints.setAttribute(solution, violatedConstraints);
  }
Beispiel #2
0
  private double g(DoubleSolution solution) {
    double result = 0.0;

    for (int i = 1; i < solution.getNumberOfVariables(); i++) {
      double value =
          solution.getVariableValue(i)
              - Math.sin(
                  2 * Math.PI * solution.getVariableValue(0)
                      + i * Math.PI / solution.getNumberOfVariables());

      result += value * value;
    }

    return result;
  }
Beispiel #3
0
 @Override
 public void evaluate(DoubleSolution solution) {
   solution.setObjective(0, (1.0 + g(solution)) * solution.getVariableValue(0));
   if (solution.getObjective(0) < 0.05) {
     solution.setObjective(1, (1.0 + g(solution)) * (1.0 - 19.0 * solution.getVariableValue(0)));
   } else {
     solution.setObjective(
         1, (1.0 + g(solution)) * (1.0 / 19.0 - solution.getVariableValue(0) / 19.0));
   }
 }
Beispiel #4
0
  /** Evaluate() method */
  @Override
  public void evaluate(DoubleSolution solution) {
    double[] fx = new double[getNumberOfObjectives()];

    double x1, x2, x3, x4, x5, x6;
    x1 = solution.getVariableValue(0);
    x2 = solution.getVariableValue(1);
    x3 = solution.getVariableValue(2);
    x4 = solution.getVariableValue(3);
    x5 = solution.getVariableValue(4);
    x6 = solution.getVariableValue(5);

    fx[0] =
        -(25.0 * (x1 - 2.0) * (x1 - 2.0)
            + (x2 - 2.0) * (x2 - 2.0)
            + (x3 - 1.0) * (x3 - 1.0)
            + (x4 - 4.0) * (x4 - 4.0)
            + (x5 - 1.0) * (x5 - 1.0));

    fx[1] = x1 * x1 + x2 * x2 + x3 * x3 + x4 * x4 + x5 * x5 + x6 * x6;

    solution.setObjective(0, fx[0]);
    solution.setObjective(1, fx[1]);
  }