Exemplo n.º 1
0
  /** Updates the reference point */
  private void updateReferencePoint(SolutionSet solutionSet) {
    double[] maxObjectives = new double[numberOfObjectives];
    for (int i = 0; i < numberOfObjectives; i++) {
      maxObjectives[i] = 0;
    }

    for (int i = 0; i < solutionSet.size(); i++) {
      for (int j = 0; j < numberOfObjectives; j++) {
        if (maxObjectives[j] < solutionSet.get(i).getObjective(j)) {
          maxObjectives[j] = solutionSet.get(i).getObjective(j);
        }
      }
    }

    for (int i = 0; i < referencePoint.getNumberOfObjectives(); i++) {
      referencePoint.setObjective(i, maxObjectives[i] + offset);
    }
  }
Exemplo n.º 2
0
  /**
   * Evaluates a solution
   *
   * @param solution The solution to evaluate
   * @throws org.uma.jmetal.util.JMetalException
   */
  public final void evaluate(Solution solution) throws JMetalException {
    float[] variables = new float[getNumberOfVariables()];
    XReal sol = new XReal(solution);
    double[] x = new double[numberOfVariables];

    for (int i = 0; i < numberOfVariables; i++) {
      x[i] = sol.getValue(i);
    }

    for (int i = 0; i < getNumberOfVariables(); i++) {
      variables[i] = (float) x[i];
    }

    float[] f = evaluate(variables);

    for (int i = 0; i < f.length; i++) {
      solution.setObjective(i, f[i]);
    }
  }